Opened 12 years ago
Closed 12 years ago
#2108 closed defect (invalid)
empty frame add the end of the video
Reported by: | ben | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | h264 mov |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug: the re-encoding will add 0.05 sec in the duration putting an empty frame at the end.
How to reproduce:
% ffmpeg -i myinput.mp4 -acodec copy -vcodec h264 -b:v 500k output.mp4 ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers built on Nov 16 2012 18:07:20 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Attachments (1)
Change History (10)
by , 12 years ago
Attachment: | myinput.mp4 added |
---|
comment:1 by , 12 years ago
Component: | FFmpeg → undetermined |
---|---|
Keywords: | empty frame removed |
Priority: | important → normal |
To make this a valid ticket, please add the complete, uncut console output together with your command line.
Is the problem also reproducible if you do not use an external library (x264) but -vcodec mpeg4 ?
Please test current git head.
comment:2 by , 12 years ago
so here is the verbose console:
input info
╰─ ffmpeg -i myinput.mp4
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 16 2012 18:07:20 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myinput.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2013-01-02 23:11:34
Duration: 00:00:02.85, start: 0.013333, bitrate: 1039 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 480x480, 975 kb/s, 29.98 fps, 30 tbr, 600 tbn, 1200 tbc
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Video
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 63 kb/s
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Audio
At least one output file must be specified
[1] 34864 exit 1 ffmpeg -i myinput.mp4
reencoding
╰─ ffmpeg -i myinput.mp4 -acodec copy -vcodec h264 -b:v 500k output.mp4 1 ↵
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 16 2012 18:07:20 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myinput.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2013-01-02 23:11:34
Duration: 00:00:02.85, start: 0.013333, bitrate: 1039 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 480x480, 975 kb/s, 29.98 fps, 30 tbr, 600 tbn, 1200 tbc
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Video
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 63 kb/s
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Audio
[libx264 @ 0x7fc05b02fc00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x7fc05b02fc00] profile High, level 3.0
[libx264 @ 0x7fc05b02fc00] 264 - core 125 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
encoder : Lavf54.29.104
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 480x480, q=-1--1, 500 kb/s, 30 tbn, 30 tbc
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Video
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, 63 kb/s
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Audio
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, ? for help
frame= 85 fps= 69 q=-1.0 Lsize= 173kB time=00:00:02.93 bitrate= 483.0kbits/s
video:146kB audio:23kB subtitle:0 global headers:0kB muxing overhead 2.479425%
[libx264 @ 0x7fc05b02fc00] frame I:1 Avg QP:29.58 size: 3150
[libx264 @ 0x7fc05b02fc00] frame P:38 Avg QP:24.70 size: 3014
[libx264 @ 0x7fc05b02fc00] frame B:46 Avg QP:26.62 size: 681
[libx264 @ 0x7fc05b02fc00] consecutive B-frames: 17.6% 23.5% 21.2% 37.6%
[libx264 @ 0x7fc05b02fc00] mb I I16..4: 46.0% 49.8% 4.2%
[libx264 @ 0x7fc05b02fc00] mb P I16..4: 7.8% 2.9% 0.5% P16..4: 52.6% 9.4% 5.4% 0.0% 0.0% skip:21.4%
[libx264 @ 0x7fc05b02fc00] mb B I16..4: 0.1% 0.1% 0.0% B16..8: 39.2% 1.5% 0.1% direct: 1.5% skip:57.3% L0:42.2% L1:55.8% BI: 2.0%
[libx264 @ 0x7fc05b02fc00] final ratefactor: 22.95
[libx264 @ 0x7fc05b02fc00] 8x8 transform intra:31.0% inter:75.4%
[libx264 @ 0x7fc05b02fc00] coded y,uvDC,uvAC intra: 15.4% 59.1% 12.2% inter: 8.9% 24.0% 0.5%
[libx264 @ 0x7fc05b02fc00] i16 v,h,dc,p: 19% 30% 10% 40%
[libx264 @ 0x7fc05b02fc00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 23% 36% 2% 3% 4% 4% 2% 2%
[libx264 @ 0x7fc05b02fc00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 27% 15% 3% 8% 9% 6% 3% 2%
[libx264 @ 0x7fc05b02fc00] i8c dc,h,v,p: 57% 21% 19% 3%
[libx264 @ 0x7fc05b02fc00] Weighted P-Frames: Y:23.7% UV:5.3%
[libx264 @ 0x7fc05b02fc00] ref P L0: 74.5% 8.6% 13.8% 2.7% 0.5%
[libx264 @ 0x7fc05b02fc00] ref B L0: 93.1% 6.3% 0.6%
[libx264 @ 0x7fc05b02fc00] ref B L1: 96.2% 3.8%
[libx264 @ 0x7fc05b02fc00] kb/s:420.75
output info using x264 codec
╰─ ffmpeg -i output.mp4
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 16 2012 18:07:20 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa39181c400] multiple edit list entries, a/v desync might occur, patch welcome
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.29.104
Duration: 00:00:02.92, start: 0.000000, bitrate: 485 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x480, 422 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 63 kb/s
Metadata:
handler_name : SoundHandler
At least one output file must be specified
[1] 35022 exit 1 ffmpeg -i output.mp4
reencoding using mpeg4 codec
╰─ ffmpeg -i myinput.mp4 -acodec copy -vcodec mpeg4 -b:v 500k output.mp4 1 ↵
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 16 2012 18:07:20 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myinput.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2013-01-02 23:11:34
Duration: 00:00:02.85, start: 0.013333, bitrate: 1039 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 480x480, 975 kb/s, 29.98 fps, 30 tbr, 600 tbn, 1200 tbc
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Video
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 63 kb/s
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Audio
File 'output.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
encoder : Lavf54.29.104
Stream #0:0(und): Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 480x480, q=2-31, 500 kb/s, 30 tbn, 30 tbc
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Video
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, 63 kb/s
Metadata:
creation_time : 2013-01-02 23:11:34
handler_name : Core Media Audio
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mpeg4)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, ? for help
frame= 85 fps=0.0 q=4.2 Lsize= 310kB time=00:00:02.93 bitrate= 862.9kbits/s
video:283kB audio:23kB subtitle:0 global headers:0kB muxing overhead 1.194474%
output info using mpeg4 codec
then it's the same the duration time goes to 2.92sec instead of 2.85sec
╰─ ffmpeg -i output.mp4
ffmpeg version 1.0 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 16 2012 18:07:20 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.0 --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa10a01c400] multiple edit list entries, a/v desync might occur, patch welcome
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf54.29.104
Duration: 00:00:02.92, start: 0.000000, bitrate: 866 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x480 [SAR 1:1 DAR 1:1], 818 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 63 kb/s
Metadata:
handler_name : SoundHandler
At least one output file must be specified
[1] 35478 exit 1 ffmpeg -i output.mp4
comment:3 by , 12 years ago
I tested the following command line:
ffmpeg -i myinput.mp4 -acodec copy -vcodec mpeg4 -b:v 500k output.mp4
Could you explain what is wrong with the output file? It looks fine here.
comment:4 by , 12 years ago
look at the duration of both files,
for me the original is Duration: 00:00:02.85, start: 0.013333, bitrate: 1039 kb/s
and the output is Duration: 00:00:02.92, start: 0.000000, bitrate: 485 kb/s
comment:5 by , 12 years ago
The duration of the audio stream seems to be >=2:90 afaict (and faad), why do you think the file is 2:85?
comment:6 by , 12 years ago
how do you check the duration of each channel?
is there a way to make sure I don't have any empty video frame?
comment:7 by , 12 years ago
Iirc, I tested the following:
$ ffmpeg -i input out.wav
(ffmpeg's output will tell you the duration, but the duration of a wav file is generally known.)
I also tested the following iirc:
$ ffmpeg -i input -acodec copy out.aac
$ faad out.aac
The duration of the resulting wav file was very similar to the duration of the wav file produced by FFmpeg.
If you talk about video frames (it was not clear for me from your report), it is even simpler:
The following command line tells you how many video frames a media files contains and outputs every single frame as png:
$ ffmpeg -vsync 0 -i input out%3d.png
Please allow me to repeat my question: Why do you believe the file is 2:85 long?
follow-up: 9 comment:8 by , 12 years ago
I thought it was 2:85 because ffmpeg -i myinput.mp4 says:
Duration: 00:00:02.85, start: 0.013333, bitrate: 1039 kb/s
now I'm not sure what those two values means. and also why is 29.98 fps getting changed to 30 fps after re-encoding?
shouldn't it stay the same?
comment:9 by , 12 years ago
Keywords: | mov added |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Replying to ben:
I thought it was 2:85 because ffmpeg -i myinput.mp4 says:
Duration: 00:00:02.85,
Afair, this is an informational value stored in the header of the file.
start: 0.013333, bitrate: 1039 kb/s
now I'm not sure what those two values means. and also why is 29.98 fps getting changed to 30 fps after re-encoding?
shouldn't it stay the same?
Without testing, I assume the original file is vfr (variable frame rate) which is not supported by the FFmpeg mov muxer, it has to choose a framerate.
Since no frames get dropped or duplicated (this would be visible in ffmpeg's output), the framechoice seems to be ok. You can add -r 30000/1001 to your command line if you prefer. Also consider testing a longer sample to see if frames will be dropped / duplicated with one of the choices.
Please reopen if you encounter A/V desync (or similar problems), the fact that the duration in the mov header does not exactly match the output file is no bug imo.
mp4 file recorded on an iphone