Opened 10 years ago
Closed 8 years ago
#4233 closed defect (fixed)
FFmpeg adds 3 frames on reencode with timecode burnin
Reported by: | Steve Dierker | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | mov |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Hello,
I have a mp4 source file and reencode it to mp4 with a different resolution and a burned in timecode. Afterwards the new file has 3 additional frames which leads to a miss matching timecode.
How to reproduce:
% ffmpeg -t 15.182 -i "163304323.mp4" -r 23.976 -pix_fmt yuv420p -aspect 640/360 -vf "scale='ceil(iw*sar/2)*2':'ceil(ih/2)*2',pad='max(iw,ih*(640/360))':'ow/(640/360)':'(ow-iw)/2':'(oh-ih)/2':black,scale=640:360" -c:v libx264 -b:v 1500k -c:a libfdk_aac -b:a 128k -g 50 -keyint_min 50 -movflags faststart -y "out.mp4"
FFmpeg version:
% ffmpeg version N-68933-gad465e7 Copyright (c) 2000-2015 the FFmpeg developers built on Jan 7 2015 15:54:46 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) configuration: --prefix=/opt/sb4/stage --extra-cflags=-I/opt/sb4/stage/include --extra-ldflags=-L/opt/sb4/stage/lib --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfaac --enable-libx264 --enable-libfreetype --enable-pthreads --enable-libvpx --enable-libvorbis --enable-libfdk-aac libavutil 54. 16.100 / 54. 16.100 libavcodec 56. 20.100 / 56. 20.100 libavformat 56. 18.100 / 56. 18.100 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 6.100 / 5. 6.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100
Information about the input file:
% ffprobe input.mp4 ffprobe version N-68933-gad465e7 Copyright (c) 2007-2015 the FFmpeg developers built on Jan 7 2015 15:54:46 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) configuration: --prefix=/opt/sb4/stage --extra-cflags=-I/opt/sb4/stage/include --extra-ldflags=-L/opt/sb4/stage/lib --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfaac --enable-libx264 --enable-libfreetype --enable-pthreads --enable-libvpx --enable-libvorbis --enable-libfdk-aac libavutil 54. 16.100 / 54. 16.100 libavcodec 56. 20.100 / 56. 20.100 libavformat 56. 18.100 / 56. 18.100 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 6.100 / 5. 6.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '163304323.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41isomavc1 creation_time : 2013-05-08 19:56:14 Duration: 00:00:15.18, start: 0.042667, bitrate: 2418 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2256 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default) Metadata: creation_time : 2013-05-08 19:56:14 handler_name : L-SMASH Video Handler encoder : AVC Coding Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s (default) Metadata: creation_time : 2013-05-08 19:56:14 handler_name : L-SMASH Audio Handler
Information about the output file:
% ffprobe out.mp4 ffprobe version N-68933-gad465e7 Copyright (c) 2007-2015 the FFmpeg developers built on Jan 7 2015 15:54:46 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) configuration: --prefix=/opt/sb4/stage --extra-cflags=-I/opt/sb4/stage/include --extra-ldflags=-L/opt/sb4/stage/lib --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfaac --enable-libx264 --enable-libfreetype --enable-pthreads --enable-libvpx --enable-libvorbis --enable-libfdk-aac libavutil 54. 16.100 / 54. 16.100 libavcodec 56. 20.100 / 56. 20.100 libavformat 56. 18.100 / 56. 18.100 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 6.100 / 5. 6.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '163304323.mp4.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.18.100 Duration: 00:00:15.28, start: 0.042667, bitrate: 1609 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 1476 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
You also changed the framerate, which could account for the difference. Omit -r and see if it still happens.
comment:3 by , 10 years ago
I checked the framerate again and mediainfo and ffprobe are slightly different. Mediainfo gives 23.976 and ffprobe gives 23.98 as a framerate.
So I re-ran the commands once with ommiting the framerate as below and still have one frame more then in the source file.
% ffmpeg -t 15.182 -i "163304323.mp4" -pix_fmt yuv420p -aspect 640/360 -vf "scale='ceil(iw*sar/2)*2':'ceil(ih/2)*2',pad='max(iw,ih*(640/360))':'ow/(640/360)':'(ow-iw)/2':'(oh-ih)/2':black,scale=640:360" -c:v libx264 -b:v 1500k -c:a libfdk_aac -b:a 128k -g 50 -keyint_min 50 -movflags faststart -y "out.mp4"
ffprobe:
% ffprobe out.mp4 ffprobe version N-68933-gad465e7 Copyright (c) 2007-2015 the FFmpeg developers built on Jan 7 2015 15:54:46 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) configuration: --prefix=/opt/sb4/stage --extra-cflags=-I/opt/sb4/stage/include --extra-ldflags=-L/opt/sb4/stage/lib --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfaac --enable-libx264 --enable-libfreetype --enable-pthreads --enable-libvpx --enable-libvorbis --enable-libfdk-aac libavutil 54. 16.100 / 54. 16.100 libavcodec 56. 20.100 / 56. 20.100 libavformat 56. 18.100 / 56. 18.100 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 6.100 / 5. 6.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.18.100 Duration: 00:00:15.23, start: 0.042667, bitrate: 1599 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 1465 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler
I also reran the command with 23.98 as the destination framerate and still have one additional frame:
% ffmpeg -t 15.182 -i "163304323.mp4" -r 23.98 -pix_fmt yuv420p -aspect 640/360 -vf "scale='ceil(iw*sar/2)*2':'ceil(ih/2)*2',pad='max(iw,ih*(640/360))':'ow/(640/360)':'(ow-iw)/2':'(oh-ih)/2':black,scale=640:360" -c:v libx264 -b:v 1500k -c:a libfdk_aac -b:a 128k -g 50 -keyint_min 50 -movflags faststart -y "out.mp4"
% ffprobe out.mp4 ffprobe version N-68933-gad465e7 Copyright (c) 2007-2015 the FFmpeg developers built on Jan 7 2015 15:54:46 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11) configuration: --prefix=/opt/sb4/stage --extra-cflags=-I/opt/sb4/stage/include --extra-ldflags=-L/opt/sb4/stage/lib --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfaac --enable-libx264 --enable-libfreetype --enable-pthreads --enable-libvpx --enable-libvorbis --enable-libfdk-aac libavutil 54. 16.100 / 54. 16.100 libavcodec 56. 20.100 / 56. 20.100 libavformat 56. 18.100 / 56. 18.100 libavdevice 56. 3.100 / 56. 3.100 libavfilter 5. 6.100 / 5. 6.100 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.18.100 Duration: 00:00:15.23, start: 0.042667, bitrate: 1599 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 1465 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler
It is one additional frame less then with the framerate mediainfo proposes, but still one additional frame compared to the original.
comment:4 by , 8 years ago
Component: | ffmpeg → avformat |
---|---|
Keywords: | mov added |
Resolution: | → fixed |
Status: | new → closed |
I believe this was fixed by Marton Balint in 65efcaeb8467f5aff25eaf02b20dae43d5ca9dc7
Sample file is available here http://dl.flavoursys.com/samples/ffmpeg/input.mp4