Some mysterious about adding PTS to a variable frame rate mp4 video

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

Some mysterious about adding PTS to a variable frame rate mp4 video

Sean Feng
Hi all,

I have a mp4 video which is in VFR, and also a few negative frames
before I cut it from another video. So the PTS of this video looks like
this

    pts_time=-1.812278
    pts_time=-1.223744
    pts_time=-1.201211
    pts_time=-0.899378
    pts_time=-0.882033
    pts_time=0.000000
    pts_time=0.113378
    pts_time=0.129322
    pts_time=0.146244
    pts_time=0.211711
    pts_time=0.243133
    pts_time=0.390133
    pts_time=0.406111

Now, I want to add the timestamp to the video itself, I used this command

    fmpeg -nostdin -i input.mp4 -c:v libx264 -profile:v baseline -vf
    "drawtext=x=(w-(max_glyph_w*13))/2:
    y=H-h/10:fontcolor=white:fontsize=h/14:box=1:boxcolor=0x000000AA:text='%{pts\\:hms}'"
    -y -vsync 0 output.mp4

I used vsync 0 because I didn't want to lose any of those frames, and it
looked fine in terms of number of the frames.

The problem is, when I use a media player to play the output video, I
can see some of frames felt into the same timestamp. What I mean is the
frame itself has the correct PTS as they had been drawn, however the
timestamp of video isn't correct. If I get the PTS of the output video,
I see this

    pts_time=0.000000
    pts_time=0.000000
    pts_time=0.251053
    pts_time=0.251053
    pts_time=0.251054
    pts_time=0.251054
    pts_time=0.502106
    pts_time=0.502106
    pts_time=1.004213
    pts_time=1.004213
    pts_time=1.004213
    pts_time=1.004213
    pts_time=1.004213
    pts_time=1.004214

Hope I am clear and any help is greatly appreciated!

Thanks!

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Some mysterious about adding PTS to a variable frame rate mp4 video

Moritz Barsnick
On Fri, Jan 10, 2020 at 15:06:12 -0500, Sean Feng wrote:
> I have a mp4 video which is in VFR, and also a few negative frames
> before I cut it from another video. So the PTS of this video looks like
> this
[...]

> The problem is, when I use a media player to play the output video, I
> can see some of frames felt into the same timestamp. What I mean is the
> frame itself has the correct PTS as they had been drawn, however the
> timestamp of video isn't correct. If I get the PTS of the output video,
> I see this
>
>     pts_time=0.000000
>     pts_time=0.000000
>     pts_time=0.251053
>     pts_time=0.251053
>     pts_time=0.251054
>     pts_time=0.251054

As I understand, ffmpeg is not capable of writing fully compliant VFR
MP4 files. This is probably a side effect of this.

If you write to a different container, suck as MKV, it should work.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Some mysterious about adding PTS to a variable frame rate mp4 video

Sean Feng
Thanks Moritz.

Still the same issue though with mkv.

However I used to see a lot of warnings like

[mp4 @ 0x556dc3300700] Non-monotonous DTS in output stream 0:0;
previous: 7456280, current: 7456278; changing to 7456281. This may
result in incorrect timestamps in the output file.
[mp4 @ 0x556dc3300700] Non-monotonous DTS in output stream 0:0;
previous: 7456281, current: 7456278; changing to 7456282. This may
result in incorrect timestamps in the output file.
[mp4 @ 0x556dc3300700] Non-monotonous DTS in output stream 0:0;
previous: 7456282, current: 7456278; changing to 7456283. This may
result in incorrect timestamps in the output file.

by using mp4 container, and they were gone with mkv.

On 2020-01-10 3:38 p.m., Moritz Barsnick wrote:

> On Fri, Jan 10, 2020 at 15:06:12 -0500, Sean Feng wrote:
>> I have a mp4 video which is in VFR, and also a few negative frames
>> before I cut it from another video. So the PTS of this video looks like
>> this
> [...]
>> The problem is, when I use a media player to play the output video, I
>> can see some of frames felt into the same timestamp. What I mean is the
>> frame itself has the correct PTS as they had been drawn, however the
>> timestamp of video isn't correct. If I get the PTS of the output video,
>> I see this
>>
>>      pts_time=0.000000
>>      pts_time=0.000000
>>      pts_time=0.251053
>>      pts_time=0.251053
>>      pts_time=0.251054
>>      pts_time=0.251054
> As I understand, ffmpeg is not capable of writing fully compliant VFR
> MP4 files. This is probably a side effect of this.
>
> If you write to a different container, suck as MKV, it should work.
>
> Cheers,
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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