Opened 13 months ago

Closed 7 months ago

Last modified 7 months ago

#8909 closed defect (invalid)

Copying an AV1 stream from an MKV container to an MP4 container changes the reported framerate

Reported by: veikk0 Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: Copying some AV1 streams from an MKV container to an MP4 container changes the reported framerate and changes it from CFR to VFR.

How to reproduce:
Download the Sintel trailer, encode 10 seconds of it in AV1, print fps with ffprobe:

wget https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4 && ffmpeg -i sintel_trailer-480p.mp4 -an -c:v libsvtav1 -t 10 -preset 8 sintel.mkv && ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 sintel.mkv

Frame rate is the same as the source (24/1).

Now to copy the freshly encoded video stream from the Matroska container to an MP4 container, and check out the frame rate:

ffmpeg -i sintel.mkv -c:v copy sintel.mp4 && ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 sintel.mp4

It has changed to 80000/3333. Furthermore, the mediainfo program will now report that the file is variable frame rate instead of constant (not sure how to check this with ffprobe).

Version info:

ffmpeg version N-99352-gd8ce8e8
built with gcc 8 (Ubuntu 8.4.0-1ubuntu1~18.04)

If your FFmpeg isn't built with SVT-AV1 or libaom, I was also able to reproduce the issue by copying an existing AV1 file not authored with FFmpeg (as far as I know): http://download.opencontent.netflix.com.s3.amazonaws.com/AV1/Chimera/Old/Chimera-AV1-8bit-1920x1080-6736kbps.mp4. Copy video stream to an MKV, then copy that stream to an MP4. Same issue.

The issue doesn't seem to crop up when going from other containers to an MP4, or when encoding directly to an MP4. Seems like this is specific to Matroska.

Attachments (4)

1-sintel-mkv-creation.txt (3.9 KB ) - added by veikk0 13 months ago.
CLI output when creating the MKV file
2-sintel-mp4-creation.txt (2.7 KB ) - added by veikk0 13 months ago.
CLI output when creating the problematic MP4 file from previously created MKV
sintel.mkv (76.5 KB ) - added by veikk0 13 months ago.
MKV file from which copying the AV1 stream to an MP4 container is an issue
sintel.mp4 (77.1 KB ) - added by veikk0 13 months ago.
MP4 file which exhibits the frame rate problem after the AV1 stream was copied from the MKV file

Download all attachments as: .zip

Change History (9)

comment:1 by Carl Eugen Hoyos, 13 months ago

Keywords: AV1 MKV MP4 Matroska fps removed

Please provide the command line and the complete, uncut console output of the command line that you tested and please provide the input sample to make this a valid ticket.

by veikk0, 13 months ago

Attachment: 1-sintel-mkv-creation.txt added

CLI output when creating the MKV file

by veikk0, 13 months ago

Attachment: 2-sintel-mp4-creation.txt added

CLI output when creating the problematic MP4 file from previously created MKV

comment:2 by veikk0, 13 months ago

Complete CLI output of the two FFmpeg commands – including the commands themselves – are now attached as separate text files.

Input sample file (sintel_trailer-480p.mp4) is already provided in the first "how to reproduce" cli. It's larger than the attachment size limit, so I'm instructing to download it directly from Blender's download server with wget. However, if this suddenly becomes unreachable, the other sample file linked to at the end of the ticket also works, and without the need to encode to AV1 yourself; only copying it to an MKV container and then to and MP4 container also reproduces the issue.

AFAIK any input file with a constant frame rate should work when you're creating the AV1 file yourself with the commands provided.

edit: I'm also attaching the resulting MKV and MP4 files, for easier diagnosis and in case recreating them becomes a problem.

Last edited 13 months ago by veikk0 (previous) (diff)

by veikk0, 13 months ago

Attachment: sintel.mkv added

MKV file from which copying the AV1 stream to an MP4 container is an issue

by veikk0, 13 months ago

Attachment: sintel.mp4 added

MP4 file which exhibits the frame rate problem after the AV1 stream was copied from the MKV file

comment:3 by Balling, 8 months ago

This happens because your original sintel.mkv is recognized as VFR by ffmpeg.

ffmpeg -i sintel.mkv -vf vfrdet -an -f null -

I doubt it is true and it is a bug in mkv parser. Should be, at least, see https://trac.ffmpeg.org/ticket/4768#comment:13

We can close #9124, because

Frame rate mode             : Variable
Frame rate                  : 24.000 FPS
Minimum frame rate          : 23.810 FPS
Maximum frame rate          : 24.390 FPS

is like that on that file too. Maximum frame rate especially.

Last edited 7 months ago by Balling (previous) (diff)

comment:4 by Carl Eugen Hoyos, 7 months ago

Resolution: invalid
Status: newclosed

I doubt that this can be improved.

in reply to:  4 comment:5 by Balling, 7 months ago

Replying to cehoyos:

I doubt that this can be improved.

Let me quote again:

Just for the record the H264 spec (Annex C) and the MPEG-TS spec does cover the case of rounded timestamps. Blu-Ray files are still CFR irrespective of the precision of the timestamps.

Last edited 7 months ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.