Setting -output_ts_offset always adds 2 frames

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting -output_ts_offset always adds 2 frames

Julien De Luca
Hello all,

I'm trying to set the initial pkt_pts_time using output_ts_offset. On
streams encoded using ffmpeg, it always sets the offset + 0.08s, which is 2
frames. Here is the command I use :

```
ffmpeg -i input.ts -acodec aac -vcodec libx264 -f mpegts -preset veryfast
-filter:v scale=640:-1 -framerate 25 -profile:v main -b:v 1200000 -level
3.1 -b:a 96000 -g 75 -bf 3 -output_ts_offset 10 -muxdelay 0 -muxpreload 0
output.ts
```

And the output from ffprobe for the first video frame :
```
{
  "media_type": "video",
  "stream_index": 0,
  "key_frame": 1,
  "pkt_pts": 907200,
  "pkt_pts_time": "10.080000",
  "pkt_dts": 907200,
  "pkt_dts_time": "10.080000",
  "best_effort_timestamp": 907200,
  "best_effort_timestamp_time": "10.080000",
  "pkt_duration": 3600,
  "pkt_duration_time": "0.040000",
  "pkt_pos": "1128",
  "pkt_size": "4872",
  "width": 640,
  "height": 360,
  "pix_fmt": "yuv420p",
  "sample_aspect_ratio": "1:1",
  "pict_type": "I",
  "coded_picture_number": 0,
  "display_picture_number": 0,
  "interlaced_frame": 0,
  "top_field_first": 0,
  "repeat_pict": 0,
  "chroma_location": "left"
}
```

The input is a ts file from a segmented stream created using hls options of
ffmpeg.

On another input created using AWS Mediaconvert, pkt_pts_time is set
correctly, at exactly 10.

Is there any known reason this may happen ?

Thank you !
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Setting -output_ts_offset always adds 2 frames

kumowoon1025
> On Feb 6, 2019, at 5:17 PM, Julien De Luca <[hidden email]> wrote:
>
> I'm trying to set the initial pkt_pts_time using output_ts_offset. On
> streams encoded using ffmpeg, it always sets the offset + 0.08s, which is 2
> frames.

The encoder must be setting the starting timestamp to 0.08s, and then the 10s offset being added to it. You could add 9.92 if it’s important? Or if the start is different for other files you could use setpts=expr=10-STARTPTS+PTS as a filter.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Setting -output_ts_offset always adds 2 frames

Julien De Luca
I tried using setpts filter, but it has no effect the output first frame
pkt_pts_time is 1.480000 :
ffmpeg -i vs0/out2.ts -y -filter_complex "setpts=expr=10-STARTPTS+PTS"
-acodec aac -vcodec libx264 -f mpegts test.ts

The goal is to make this work whatever the input is, and manually adding
0.08 would imply to have the control on the encoder, which I would try to
avoid.

On Thu, Feb 7, 2019 at 3:58 PM Ted Park <[hidden email]> wrote:

> > On Feb 6, 2019, at 5:17 PM, Julien De Luca <
> [hidden email]> wrote:
> >
> > I'm trying to set the initial pkt_pts_time using output_ts_offset. On
> > streams encoded using ffmpeg, it always sets the offset + 0.08s, which
> is 2
> > frames.
>
> The encoder must be setting the starting timestamp to 0.08s, and then the
> 10s offset being added to it. You could add 9.92 if it’s important? Or if
> the start is different for other files you could use
> setpts=expr=10-STARTPTS+PTS as a filter.
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Setting -output_ts_offset always adds 2 frames

kumowoon1025
> On Feb 7, 2019, at 3:46 PM, Julien De Luca <[hidden email]> wrote:
>
> I tried using setpts filter, but it has no effect the output first frame
> pkt_pts_time is 1.480000 :
> ffmpeg -i vs0/out2.ts -y -filter_complex "setpts=expr=10-STARTPTS+PTS"
> -acodec aac -vcodec libx264 -f mpegts test.ts
>
> The goal is to make this work whatever the input is, and manually adding
> 0.08 would imply to have the control on the encoder, which I would try to
> avoid.

Sorry… 10 should have been multiplied by the timebase denominator, 10/TB-STARTPTS+PTS. Though obviously it’s not doing anything regardless, which I now realize is probably because your muxing to mpeg transport streams... Are you trying to have playback start 10 seconds into the stream? Because I may have misunderstood then.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Setting -output_ts_offset always adds 2 frames

Gyan
In reply to this post by Julien De Luca


On 07-02-2019 03:47 AM, Julien De Luca wrote:

> Hello all,
>
> I'm trying to set the initial pkt_pts_time using output_ts_offset. On
> streams encoded using ffmpeg, it always sets the offset + 0.08s, which is 2
> frames. Here is the command I use :
>
> ```
> ffmpeg -i input.ts -acodec aac -vcodec libx264 -f mpegts -preset veryfast
> -filter:v scale=640:-1 -framerate 25 -profile:v main -b:v 1200000 -level
> 3.1 -b:a 96000 -g 75 -bf 3 -output_ts_offset 10 -muxdelay 0 -muxpreload 0
> output.ts
> ```
>
> And the output from ffprobe for the first video frame :
> ```
> {
>    "media_type": "video",
>    "stream_index": 0,
>    "key_frame": 1,
>    "pkt_pts": 907200,
>    "pkt_pts_time": "10.080000",
>    "pkt_dts": 907200,
>    "pkt_dts_time": "10.080000",
>    "best_effort_timestamp": 907200,
>    "best_effort_timestamp_time": "10.080000",
>    "pkt_duration": 3600,
>    "pkt_duration_time": "0.040000",
>    "pkt_pos": "1128",
>    "pkt_size": "4872",
>    "width": 640,
>    "height": 360,
>    "pix_fmt": "yuv420p",
>    "sample_aspect_ratio": "1:1",
>    "pict_type": "I",
>    "coded_picture_number": 0,
>    "display_picture_number": 0,
>    "interlaced_frame": 0,
>    "top_field_first": 0,
>    "repeat_pict": 0,
>    "chroma_location": "left"
> }
> ```
>
> The input is a ts file from a segmented stream created using hls options of
> ffmpeg.
>
> On another input created using AWS Mediaconvert, pkt_pts_time is set
> correctly, at exactly 10.
>
> Is there any known reason this may happen ?
>

What's the output with

ffmpeg -i input.ts -an -vcodec libx264 -f mpegts -preset veryfast
-filter:v scale=640:-1 -profile:v main -b:v 1200000 -level
3.1 -g 75 -bf 3 -output_ts_offset 10 -muxdelay 0 -muxpreload 0
output.ts

Gyan

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Setting -output_ts_offset always adds 2 frames

Julien De Luca
After several tries, I noticed that doing :

ffmpeg -i clip.ts -c copy -y -copyts -mpegts_copyts 1 -ss -14
clip-correct-pts.ts

shifts the pts without modifyijng the video. So I did 2 passes after
retrieving the pts of the first frame to calculate the offset.

On Fri, Feb 8, 2019 at 8:14 AM Gyan <[hidden email]> wrote:

>
>
> On 07-02-2019 03:47 AM, Julien De Luca wrote:
> > Hello all,
> >
> > I'm trying to set the initial pkt_pts_time using output_ts_offset. On
> > streams encoded using ffmpeg, it always sets the offset + 0.08s, which
> is 2
> > frames. Here is the command I use :
> >
> > ```
> > ffmpeg -i input.ts -acodec aac -vcodec libx264 -f mpegts -preset veryfast
> > -filter:v scale=640:-1 -framerate 25 -profile:v main -b:v 1200000 -level
> > 3.1 -b:a 96000 -g 75 -bf 3 -output_ts_offset 10 -muxdelay 0 -muxpreload 0
> > output.ts
> > ```
> >
> > And the output from ffprobe for the first video frame :
> > ```
> > {
> >    "media_type": "video",
> >    "stream_index": 0,
> >    "key_frame": 1,
> >    "pkt_pts": 907200,
> >    "pkt_pts_time": "10.080000",
> >    "pkt_dts": 907200,
> >    "pkt_dts_time": "10.080000",
> >    "best_effort_timestamp": 907200,
> >    "best_effort_timestamp_time": "10.080000",
> >    "pkt_duration": 3600,
> >    "pkt_duration_time": "0.040000",
> >    "pkt_pos": "1128",
> >    "pkt_size": "4872",
> >    "width": 640,
> >    "height": 360,
> >    "pix_fmt": "yuv420p",
> >    "sample_aspect_ratio": "1:1",
> >    "pict_type": "I",
> >    "coded_picture_number": 0,
> >    "display_picture_number": 0,
> >    "interlaced_frame": 0,
> >    "top_field_first": 0,
> >    "repeat_pict": 0,
> >    "chroma_location": "left"
> > }
> > ```
> >
> > The input is a ts file from a segmented stream created using hls options
> of
> > ffmpeg.
> >
> > On another input created using AWS Mediaconvert, pkt_pts_time is set
> > correctly, at exactly 10.
> >
> > Is there any known reason this may happen ?
> >
>
> What's the output with
>
> ffmpeg -i input.ts -an -vcodec libx264 -f mpegts -preset veryfast
> -filter:v scale=640:-1 -profile:v main -b:v 1200000 -level
> 3.1 -g 75 -bf 3 -output_ts_offset 10 -muxdelay 0 -muxpreload 0
> output.ts
>
> Gyan
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".