I'm trying to concatenate 2 videos, while at the same time adding some text to the second one. I'm using php-ffmpeg to do this, with the Sharapov extension, but I have the actual ffmpeg commands.
To do this it seems to encode the first video, then the second one with the text separately, and then joins them together. Problem is the text appears in the encoded (but un-joined) second video, but as soon as they are joined together it disappears.
Here are the commands:
ffmpeg '-y' '-i' 'video_in/first_vid.mp4' '-threads' '8' '-vcodec' 'libx264' '-acodec' 'aac' '-max_muxing_queue_size' '400' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '256k' '-ac' '2' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5b73814fa1e29qjif7/pass-5b73814fa1f5b' '/data/tmp/ffmpeg-7a580007c010377da19305b0836e7a4d-5b73814f9ff35.mp4'
2% 2% 2% 4% 4% 6% 6% 6% 8% 8% 10% 10% 10% 12% 12% 12% 14% 14% 14% 16% 16% 18% 18% 18% 20% 20% 22% 22% 22% 24% 24% 24% 26% 26% 26% 28% 28% 28% 30% 30% 30% 32% 32% 34% 34% 34% 36% 36% 36% 38% 38% 38% 40% 40% 40% 42% 44% 44% 44% 46% 46% 46% 48% 48% 48%
ffmpeg '-y' '-i' 'video_in/first_vid.mp4' '-threads' '8' '-vcodec' 'libx264' '-acodec' 'aac' '-max_muxing_queue_size' '400' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '256k' '-ac' '2' '-pass' '2' '-passlogfile' '/tmp/ffmpeg-passes5b73814fa1e29qjif7/pass-5b73814fa1f5b' '/data/tmp/ffmpeg-7a580007c010377da19305b0836e7a4d-5b73814f9ff35.mp4'
50% 50% 50% 52% 52% 52% 52% 52% 52% 54% 54% 54% 54% 54% 54% 56% 56% 56% 56% 56% 56% 58% 58% 58% 58% 58% 58% 60% 60% 60% 60% 60% 60% 62% 62% 62% 62% 62% 62% 64% 64% 64% 64% 64% 66% 66% 66% 66% 66% 66% 66% 68% 68% 68% 68% 68% 70% 70% 70% 70% 70% 72% 72% 72% 72% 72% 72% 72% 74% 74% 74% 74% 74% 74% 74% 76% 76% 76% 76% 76% 76% 76% 78% 78% 78% 78% 78% 78% 80% 80% 80% 80% 80% 80% 82% 82% 82% 82% 82% 84% 84% 84% 84% 84% 84% 84% 84% 84% 84% 86% 86% 86% 86% 86% 86% 88% 88% 88% 88% 88% 88% 88% 90% 90% 90% 90% 90% 90% 90% 90% 92% 92% 92% 92% 94% 94% 94% 94% 94% 94% 94% 94% 94% 96% 96% 96% 96% 96% 96% 96% 96% 98% 98% 98% 98% 98% 98%
ffmpeg '-y' '-i' 'video/second_vid.mp4' '-filter_complex' '[0:v]drawtext=fontfile=/usr/share/fonts/truetype/msttcorefonts/arial.ttf:text='test text':fontcolor='ffffff#1':fontsize=30:x=(w-tw)/2:y=50:alpha='if(lt(t,2),0,if(lt(t,4),(t-2)/2,if(lt(t,24),1,if(lt(t,26),(2-(t-24))/2,0))))'' '-threads' '8' '-vcodec' 'libx264' '-acodec' 'aac' '-max_muxing_queue_size' '400' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '256k' '-ac' '2' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5b738244e22e0b38pp/pass-5b738244e2412' '/data/tmp/ffmpeg-ed6a389106090a6a9f9c71c7c357400b-5b738244e2215.mp4'
2% 2% 4% 6% 8% 10% 12% 14% 14% 16% 18% 18% 20% 22% 22% 24% 26% 28% 30% 30% 32% 34% 34% 36% 38% 40% 42% 44% 44% 46% 48%
ffmpeg '-y' '-i' 'video/second_vid.mp4' '-filter_complex' '[0:v]drawtext=fontfile=/usr/share/fonts/truetype/msttcorefonts/arial.ttf:text='test text':fontcolor='ffffff#1':fontsize=30:x=(w-tw)/2:y=50:alpha='if(lt(t,2),0,if(lt(t,4),(t-2)/2,if(lt(t,24),1,if(lt(t,26),(2-(t-24))/2,0))))'' '-threads' '8' '-vcodec' 'libx264' '-acodec' 'aac' '-max_muxing_queue_size' '400' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '256k' '-ac' '2' '-pass' '2' '-passlogfile' '/tmp/ffmpeg-passes5b738244e22e0b38pp/pass-5b738244e2412' '/data/tmp/ffmpeg-ed6a389106090a6a9f9c71c7c357400b-5b738244e2215.mp4'
52% 52% 54% 54% 56% 56% 58% 58% 60% 60% 62% 64% 66% 68% 70% 70% 72% 74% 76% 76% 78% 80% 82% 84% 86% 86% 88% 88% 90% 90% 92% 94% 96% 98%
ffmpeg '-y' '-f' 'concat' '-safe' '0' '-i' '/data/tmp/ffmpeg-concat-5b73814f9fe10' '-c' 'copy' 'video_out/done_vid.mp4'
(For some reason it seems to run the encoding of each video command again at 50%)
So when I play ffmpeg-ed6a389106090a6a9f9c71c7c357400b-5b738244e2215.mp4, the text is in there, but when I play the output file (done_vid.mp4), the text isn't there.
What's going on?
UPDATE: Here are the ffprobes of the 2 temp files in case they help:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'data/tmp/ffmpeg-7a580007c010377da19305b0836e7a4d-5b73814f9ff35.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:02:25.17, start: 0.000000, bitrate: 1247 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 999 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 242 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'data/tmp/ffmpeg-ed6a389106090a6a9f9c71c7c357400b-5b738244e2215.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Duration: 00:01:30.03, start: 0.000000, bitrate: 322 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], 61 kb/s, 23.98 fps, 23.98 tbr, 19184 tbn, 47.96 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 258 kb/s (default)
Metadata:
handler_name : SoundHandler
The problem
Your first video output is yuv420p, but your second video output is yuv444p. Both should be yuv420p, so add format=yuv420p to the end of your filterchain:
'-filter_complex' '[0:v]drawtext=fontfile=/usr/share/fonts/truetype/msttcorefonts/arial.ttf:text='test text':fontcolor='ffffff#1':fontsize=30:x=(w-tw)/2:y=50:alpha='if(lt(t,2),0,if(lt(t,4),(t-2)/2,if(lt(t,24),1,if(lt(t,26),(2-(t-24))/2,0))))',format=yuv420p'
Other stuff
Since you're re-encoding everything anyway use the concat filter, then you can do everything in one command.
Do you really want to perform two passes? Use one pass with -crf instead of -b:v unless you are targeting a specific output file size. See FFmpeg Wiki: H.264.
You don't need to declare -threads. The encoder will automatically choose an appropriate value.
Use the encoding presets (see wiki link above). Then you can stop encoding like it is 2006 and you can remove all of this: '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1'.
I'll assume you're making videos to be played via progressive download. If that's the case add the -movflags +faststart output option so it can begin playback before it is completely downloaded by the viewer.
Related
I'm trying to convert a VideoCD MPEG to MP4 using:
FFMPEG 5.1
ffmpeg.exe -nostdin -y -loglevel info -hide_banner -i "ITEM0010.DAT" -c:v libx264 -crf 18 -qscale:v 3 -c:a aac -ar 96000 -map_metadata -1 "output.mp4"
I'm getting:
[mpeg # 0000024b81bf4480] start time for stream 1 is not set in estimate_timings_from_pts
[mpeg # 0000024b81bf4480] stream 1 : no TS found at start of file, duration not set
[mpeg # 0000024b81bf4480] Could not find codec parameters for stream 1 (Audio: mp2, 0 channels, s16p): unspecified frame size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mpeg, from 'C:\Concierge\ITEM0010.DAT':
Stream #0:1[0x1c0]: Audio: mp2, 0 channels, s16p
Stream #0:2[0x1e2]: Video: mpeg1video, yuv420p(tv), 704x576 [SAR 178:163 DAR 1958:1467], 1100 kb/s, 25 tbr, 90k tbn
Stream mapping:
Stream #0:2 -> #0:0 (mpeg1video (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
[libx264 # 0000024b81c86000] -qscale is ignored, -crf is recommended.
[libx264 # 0000024b81c86000] using SAR=178/163
[libx264 # 0000024b81c86000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000024b81c86000] profile High, level 3.0, 4:2:0, 8-bit
[libx264 # 0000024b81c86000] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - 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=18 lookahead_threads=3 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=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[abuffer # 0000024b84979880] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
Last message repeated 1 times
[abuffer # 0000024b84979880] Error setting option time_base to value 1/0.
[graph_1_in_0_1 # 0000024b85187c00] Error applying options to the filter.
Error reinitializing filters!
Error while filtering: Result too large
Finishing stream 0:1 without any data written to it.
[abuffer # 0000024b84979880] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
Last message repeated 1 times
[abuffer # 0000024b84979880] Error setting option time_base to value 1/0.
[graph_1_in_0_1 # 0000024b85186b00] Error applying options to the filter.
Error configuring filter graph
[libx264 # 0000024b81c86000] frame I:1 Avg QP:22.68 size: 40674
[libx264 # 0000024b81c86000] mb I I16..4: 3.8% 72.3% 23.9%
[libx264 # 0000024b81c86000] 8x8 transform intra:72.3%
[libx264 # 0000024b81c86000] coded y,uvDC,uvAC intra: 88.4% 81.1% 50.3%
[libx264 # 0000024b81c86000] i16 v,h,dc,p: 43% 13% 0% 43%
[libx264 # 0000024b81c86000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 16% 20% 5% 5% 6% 5% 7% 6%
[libx264 # 0000024b81c86000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 20% 8% 5% 9% 8% 8% 6% 4%
[libx264 # 0000024b81c86000] i8c dc,h,v,p: 42% 23% 28% 7%
[libx264 # 0000024b
81c86000] kb/s:8134.80
Conversion failed!
The same command using FFMPEG 4.1 works fine.
I am trying to generate a periodic intra refresh h264 stream with only P frames using ffmpeg and x264 but I always get an I frame at the start.
Is there a way with x264 to create a P frame only stream?
Commands I am using:
ffmpeg -f lavfi -re -i testsrc=duration=5:size=1920x1080:rate=30000/1001 -s 1920x1080 -pix_fmt yuv420p -f rawvideo out.yuv
x264 --input-res 1920x1080 --intra-refresh out.yuv --b-pyramid none -b 0 --ref 0 -o out.264
Verification:
ffprobe -show_frames out.264 |grep pict_type=I
Or just looking at the x264 output e.g.
yuv [info]: 1920x1080p 0:0 # 25/1 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.0, 4:2:0, 8-bit
x264 [info]: frame I:1 Avg QP:13.63 size: 12189
x264 [info]: frame P:149 Avg QP:13.59 size: 874
x264 [info]: mb I I16..4: 78.7% 18.6% 2.7%
x264 [info]: mb P I16..4: 2.3% 0.1% 0.0% P16..4: 3.2% 0.3% 0.0% 0.0% 0.0% skip:94.1%
x264 [info]: 8x8 transform intra:7.6% inter:91.5%
x264 [info]: coded y,uvDC,uvAC intra: 1.3% 18.9% 3.6% inter: 0.1% 1.1% 0.1%
x264 [info]: i16 v,h,dc,p: 86% 6% 1% 7%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 22% 36% 0% 0% 0% 0% 0% 0%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 30% 32% 3% 1% 3% 0% 3% 0%
x264 [info]: i8c dc,h,v,p: 28% 7% 55% 9%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: kb/s:189.96
encoded 150 frames, 66.76 fps, 189.96 kb/s
Thanks to #Gyan and #nobody555 this works:
ffmpeg -f lavfi -re -i testsrc=duration=60:size=1920x1080:rate=30000/1001 -s 1920x1080 -pix_fmt yuv420p -f rawvideo -|x264 --input-res 1920x1080 --intra-refresh -o - -|ffmpeg -r "30000/1001" -fflags +genpts -i - -c copy -movflags frag_keyframe+empty_moov -f mp4 -|ffmpeg -i - -ss 200ms -c copy -f mpegts out.ts -y
So, I'm using this code to compress my *mp4 file. I need to get lower quality and decrease bitrate:
ffmpeg -i input.mp4 -c:v libx264 output.mp4
The problem is: the last frame of footage is dropped after ffmpeg compression.
Screenshot is here: screenshot_ffmpeg_drop frame
I tried to use full preferences I need, but the problem is the same.
ffmpeg -i input.mp4 -c:v libx264 -vf scale=1280:720 -preset fast -crf 29 -r 25 -c:a copy output.mp4
logfile during ffmpeg encoding:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '\input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2018-10-28T11:06:03.000000Z
Duration: 00:00:12.76, start: 0.000000, bitrate: 5374 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 5368 kb/s, 25 fps, 25 tbr, 50k tbn, 50 tbc (default)
Metadata:
creation_time : 2018-10-28T11:06:03.000000Z
handler_name : Alias Data Handler
encoder : AVC Coding
Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264
(libx264)) Press [q] to stop, [?] for help [libx264 #
000002fae8b50780] using SAR=1/1 [libx264 # 000002fae8b50780] using cpu
capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 #
000002fae8b50780] profile High, level 3.1 [libx264 # 000002fae8b50780]
264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft
2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=2
deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=12
lookahead_threads=2 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=1 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf
mbtree=1 crf=29.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 : 0
compatible_brands: mp42mp41
encoder : Lavf58.17.100
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25
tbc (default)
Metadata:
creation_time : 2018-10-28T11:06:03.000000Z
handler_name : Alias Data Handler
encoder : Lavc58.19.104 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 318 fps=127 q=-1.0 Lsize= 855kB time=00:00:12.60 bitrate=
556.0kbits/s speed=5.05x video:851kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.534683% [libx264 #
0000015d5cef0500] frame I:2 Avg QP:26.18 size: 67800 [libx264 #
0000015d5cef0500] frame P:80 Avg QP:27.93 size: 5439 [libx264 #
0000015d5cef0500] frame B:236 Avg QP:32.44 size: 1269 [libx264 #
0000015d5cef0500] consecutive B-frames: 0.9% 0.0% 0.9% 98.1%
[libx264 # 0000015d5cef0500] mb I I16..4: 10.6% 62.5% 26.8% [libx264
# 0000015d5cef0500] mb P I16..4: 0.5% 1.0% 0.2% P16..4: 36.1%
5.1% 3.6% 0.0% 0.0% skip:53.6% [libx264 # 0000015d5cef0500] mb B I16..4: 0.6% 0.5% 0.0% B16..8: 22.2% 0.6% 0.0% direct: 2.0%
skip:74.2% L0:44.9% L1:54.5% BI: 0.6% [libx264 # 0000015d5cef0500]
8x8 transform intra:55.0% inter:86.2% [libx264 # 0000015d5cef0500]
coded y,uvDC,uvAC intra: 48.1% 54.9% 27.0% inter: 3.2% 5.2% 0.2%
[libx264 # 0000015d5cef0500] i16 v,h,dc,p: 19% 56% 10% 15% [libx264 #
0000015d5cef0500] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 25% 18% 5% 6%
5% 8% 5% 8% [libx264 # 0000015d5cef0500] i4
v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 24% 9% 5% 8% 7% 9% 5% 7%
[libx264 # 0000015d5cef0500] i8c dc,h,v,p: 60% 20% 15% 4% [libx264 #
0000015d5cef0500] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 #
0000015d5cef0500] ref P L0: 67.7% 32.3% [libx264 # 0000015d5cef0500]
ref B L0: 80.4% 19.6% [libx264 # 0000015d5cef0500] ref B L1: 92.1%
7.9% [libx264 # 0000015d5cef0500] kb/s:547.35
Use
ffmpeg -ignore_editlist 1 -i input.mp4 ... output.mp4
I am trying to convert a stack of 447 still images (jpg) to video using avconv on ubuntu 14.04
avconv -f image2 -i aligned_%04d.tif.jpg -r 10 movie.mkv
Output:
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, image2, from 'aligned_%04d.tif.jpg':
Duration: 00:00:17.84, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mjpeg, yuvj420p, 792x514 [PAR 150:150 DAR 396:257], 25 fps, 25 tbr, 25 tbn
File 'movie.mkv' already exists. Overwrite ? [y/N] y
[libx264 # 0x1811dc0] using SAR=1/1
[libx264 # 0x1811dc0] using cpu capabilities: MMX2 SSE2Fast LZCNT
[libx264 # 0x1811dc0] profile High, level 3.1
[libx264 # 0x1811dc0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=3 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=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
Output #0, matroska, to 'movie.mkv':
Metadata:
encoder : Lavf54.20.4
Stream #0.0: Video: libx264, yuvj420p, 792x514 [PAR 150:150 DAR 396:257], q=-1--1, 1k tbn, 10 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libx264)
Press ctrl-c to stop encoding
frame= 179 fps= 53 q=32766.0 Lsize= 158kB time=17.70 bitrate= 73.1kbits/s s
video:154kB audio:0kB global headers:0kB muxing overhead 2.300587%
[libx264 # 0x1811dc0] frame I:1 Avg QP:17.62 size: 87993
[libx264 # 0x1811dc0] frame P:46 Avg QP:16.44 size: 1477
[libx264 # 0x1811dc0] frame B:132 Avg QP:22.30 size: 26
[libx264 # 0x1811dc0] consecutive B-frames: 1.7% 0.0% 0.0% 98.3%
[libx264 # 0x1811dc0] mb I I16..4: 4.1% 88.4% 7.5%
[libx264 # 0x1811dc0] mb P I16..4: 0.1% 0.6% 0.1% P16..4: 2.8% 0.4% 0.4% 0.0% 0.0% skip:95.6%
[libx264 # 0x1811dc0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.2% 0.0% 0.0% direct: 0.0% skip:99.8% L0:42.2% L1:57.8% BI: 0.0%
[libx264 # 0x1811dc0] 8x8 transform intra:82.7% inter:98.4%
[libx264 # 0x1811dc0] coded y,uvDC,uvAC intra: 87.0% 81.3% 53.6% inter: 0.4% 0.8% 0.2%
[libx264 # 0x1811dc0] i16 v,h,dc,p: 7% 84% 3% 6%
[libx264 # 0x1811dc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 29% 18% 17% 4% 3% 4% 5% 12%
[libx264 # 0x1811dc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 19% 9% 12% 6% 5% 4% 9% 11%
[libx264 # 0x1811dc0] i8c dc,h,v,p: 36% 45% 15% 3%
[libx264 # 0x1811dc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1811dc0] ref P L0: 96.3% 0.0% 1.9% 1.9%
[libx264 # 0x1811dc0] ref B L0: 78.5% 12.5% 9.0%
[libx264 # 0x1811dc0] ref B L1: 95.0% 5.0%
[libx264 # 0x1811dc0] kb/s:71.22
The resulting video runs about 18s, but seems to contain only the first frame. Changing the framerate will still end up with ~18s and only the first frame.
My expectation was: Every image would be used for one frame and the higher the framerate the shorter the video. And of course: The video should contain all images.
Is my expectation wrong? Or what could be the cause for my problem?
My command is mainly based on: https://libav.org/avconv.html#toc-image2-1
I would much rather like to delete the question.
When converting the input frames from tif (which were not accepted by avconv) to jpg, I must have hosed them up. All 447 images were actually a copy of the first one. That explains the video issues, which were no issues really.
I am trying to convert a flv video to mp4 using a264, but the result video has a out of sync audio/video. The audio seems ok but the video seems slow and therefore out of sync with the audio.
Here is the command I am running:
/opt/local/bin/ffmpeg -i complaint.flv -f mp4 -vcodec libx264 -acodec aac -copyts -strict experimental -fpre /opt/local/share/ffmpeg/libx264-lossless_slow.ffpreset -ab 44k -threads 0 -crf 23 complaint.mp4
And the output:
Desktop /opt/local/bin/ffmpeg -i complaint.flv -f mp4 -vcodec libx264 -acodec aac -copyts -strict experimental -fpre /opt/local/share/ffmpeg/libx264-lossless_slow.ffpreset -ab 44k -threads 0 -crf 23 complaint.mp4
ffmpeg version 0.7.8, Copyright (c) 2000-2011 the FFmpeg developers
built on Jan 12 2012 21:12:26 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
configuration: --prefix=/opt/local --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libopenjpeg --enable-libxvid --enable-libx264 --enable-libvpx --enable-libspeex --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/gcc-4.2 --arch=x86_64 --enable-yasm
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.123. 0 / 52.123. 0
libavformat 52.111. 0 / 52.111. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
[flv # 0x7fe57a04ac00] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'complaint.flv':
Metadata:
duration : 7
creationdate : Thu Jan 12 23:47:24
description : Recorded using VideoRecording example.
Duration: 00:00:06.61, start: 0.000000, bitrate: N/A
Stream #0.0: Video: flv, yuv420p, 288x288, 1k tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: nellymoser, 11025 Hz, mono, s16
File 'complaint.mp4' already exists. Overwrite ? [y/N] y
[buffer # 0x7fe579c32cc0] w:288 h:288 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
[libx264 # 0x7fe57a044600] using cpu capabilities: none!
[libx264 # 0x7fe57a044600] profile High, level 4.2
[libx264 # 0x7fe57a044600] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x33 me=umh subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, mp4, to 'complaint.mp4':
Metadata:
duration : 7
creationdate : Thu Jan 12 23:47:24
description : Recorded using VideoRecording example.
encoder : Lavf52.111.0
Stream #0.0: Video: libx264, yuv420p, 288x288, q=0-69, 200 kb/s, 1k tbn, 1k tbc
Stream #0.1: Audio: aac, 11025 Hz, mono, s16, 44 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
frame= 6557 fps=106 q=-1.0 Lsize= 685kB time=00:00:03.62 bitrate=1549.1kbits/s dup=6367 drop=0
video:615kB audio:17kB global headers:0kB muxing overhead 8.361360%
frame I:27 Avg QP:19.98 size: 8242
[libx264 # 0x7fe57a044600] frame P:6530 Avg QP:30.71 size: 62
[libx264 # 0x7fe57a044600] mb I I16..4: 11.1% 79.3% 9.6%
[libx264 # 0x7fe57a044600] mb P I16..4: 0.1% 0.2% 0.0% P16..4: 1.2% 0.2% 0.3% 0.0% 0.0% skip:98.0%
[libx264 # 0x7fe57a044600] 8x8 transform intra:77.8% inter:64.9%
[libx264 # 0x7fe57a044600] coded y,uvDC,uvAC intra: 75.3% 81.3% 33.3% inter: 0.5% 0.7% 0.1%
[libx264 # 0x7fe57a044600] i16 v,h,dc,p: 78% 9% 10% 3%
[libx264 # 0x7fe57a044600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 11% 32% 3% 4% 5% 2% 5% 4%
[libx264 # 0x7fe57a044600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 56% 7% 9% 3% 4% 7% 3% 7% 3%
[libx264 # 0x7fe57a044600] i8c dc,h,v,p: 45% 15% 34% 6%
[libx264 # 0x7fe57a044600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7fe57a044600] ref P L0: 80.5% 9.5% 10.0%
[libx264 # 0x7fe57a044600] kb/s:767.20
Is there something I'm missing to make sure the video and audio line up perfectly?
For those who may be trying this, I was better of recording flash in h264 right away, instead of using yuv420p for audio codec. That worked like a charm. Adding the flag -async 1 also helped.
Update: Check out this bit from the ffmpeg documentation (http://ffmpeg.org/ffmpeg.html):
-async: Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps, the parameter is the maximum samples per second by which the audio is changed. -async 1 is a special case where only the start of the audio stream is corrected without any later correction. This option has been deprecated. Use the aresample audio filter instead.
You can read about the aresample filter here: http://ffmpeg.org/trac/ffmpeg/wiki/FilteringGuide