[FFmpeg-user] ffmpeg optimization question:
John Crossman
johncrossman at berkeley.edu
Tue Jul 23 01:53:26 CEST 2013
The performance improvement I received from previous suggestions on merging
video and audio tracks makes me thing other ffmpeg operations could be
faster.
*The use case*. Our system publishes videos to YouTube and uses ffmpeg in
two separate steps:
1. Join video1 and video2 sources into one side-by-side composition
2. Encode merged video. We want to publish HD video to YouTube.
Here are the two ffmpeg (1.2.1) commands we use to achieve the above:
1. ffmpeg -i *video1.mp4* -i *video2.mp4* -filter_complex
"[1:v]pad=iw*2:ih[bg];[bg][0:v]overlay=W/2+((W/2-w)/2):(H-h)/2" -qscale:v 2
-strict -2 *video3.mp4*
2. ffmpeg -i *video3.mp4* -acodec libmp3lame -ab 64k -ar 22050 -r 25
-vcodec libx264 -level 41 -crf 20 -bufsize 20000k -maxrate 25000k -g 250 -s
1280x720 -coder 1 -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40 *
final.mp4*
My question: How can I optimize the command #2 above? I have sample stdout
below.
Thanks again.
----------------------------
/usr/bin/ffmpeg -i video.mp4 -acodec libmp3lame -ab 64k -ar 22050 -r 25
-vcodec libx264 -level 41 -crf 20 -bufsize 20000k -maxrate 25000k -g 250 -s
1280x720 -coder 1 -subq 7 -me_range 16 -keyint_min 25 -sc_threshold 40
result.mp4
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat
4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect
--enable-gpl --enable-version3 --enable-postproc --enable-avfilter
--enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth
--enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm
--enable-libmp3lame --enable-libnut --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
--enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx
--enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.63.104
Duration: 00:08:01.02, start: 0.000000, bitrate: 234 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1024x768 [SAR 1:1 DAR 4:3], 28 kb/s, 100 fps, 100 tbr, 12800 tbn, 200 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp2 (mp4a / 0x6134706D), 44100 Hz, stereo,
s16p, 191 kb/s
Metadata:
handler_name : SoundHandler
[libx264 @ 0x1ef40c0] using SAR=3/4
[libx264 @ 0x1ef40c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x1ef40c0] profile High, level 4.1
[libx264 @ 0x1ef40c0] 264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft
2003-2013 - 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=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 vbv_maxrate=25000 vbv_bufsize=20000 crf_max=0.0
nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'result.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.63.104
Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1280x720 [SAR 3:4 DAR 4:3], q=-1--1, 12800 tbn, 25 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (i[0][0][0] / 0x0069), 22050 Hz, stereo,
s16p, 64 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (mp2 -> libmp3lame)
Press [q] to stop, [?] for help
frame= 321 fps= 36 q=32766.0 Lsize= 126kB time=00:00:12.76 bitrate=
81.2kbits/s dup=0 drop=951
video:14kB audio:100kB subtitle:0 global headers:0kB muxing overhead
11.387343%
[libx264 @ 0x1ef40c0] frame I:2 Avg QP: 4.50 size: 216
[libx264 @ 0x1ef40c0] frame P:81 Avg QP: 6.14 size: 46
[libx264 @ 0x1ef40c0] frame B:238 Avg QP: 9.67 size: 38
[libx264 @ 0x1ef40c0] consecutive B-frames: 0.9% 0.6% 0.0% 98.4%
[libx264 @ 0x1ef40c0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x1ef40c0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0%
0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x1ef40c0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0%
0.0% direct: 0.0% skip:100.0%
[libx264 @ 0x1ef40c0] 8x8 transform intra:0.0%
[libx264 @ 0x1ef40c0] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0%
0.0% 0.0%
[libx264 @ 0x1ef40c0] i16 v,h,dc,p: 98% 0% 2% 0%
[libx264 @ 0x1ef40c0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x1ef40c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x1ef40c0] kb/s:8.17
More information about the ffmpeg-user
mailing list