When trying to convert a .webm video (two colored animation) to a .mp4 video using ffmpeg (3.4.2 on mac) the result is somewhat blurry. I did research this topic and tried different approaches to solve this. Here is the most promising command:
ffmpeg -i vidoe.webm -qscale 1 video.mp4
However, the quality change is still tremendous, see the difference below.
webm
mp4
The resolution of the two videos is the same, however the size dropped from 24,3MB (.webm) to 1,5MB (.mp4) after conversion.
Update
Here is the log of the conversion.
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, matroska,webm, from 'video.webm':
Metadata:
encoder : whammy
Duration: 00:00:05.02, start: 0.000000, bitrate: 38755 kb/s
Stream #0:0: Video: vp8, yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 60 fps, 60 tbr, 1k tbn, 1k tbc (default)
Please use -q:a or -q:v, -qscale is ambiguous
Stream mapping:
Stream #0:0 -> #0:0 (vp8 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x7f8625800c00] -qscale is ignored, -crf is recommended.
[libx264 # 0x7f8625800c00] using SAR=1/1
[libx264 # 0x7f8625800c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7f8625800c00] profile High, level 4.2
[libx264 # 0x7f8625800c00] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'video.mp4':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc (default)
Metadata:
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 301 fps= 45 q=-1.0 Lsize= 1417kB time=00:00:04.96 bitrate=2336.4kbits/s speed=0.735x
video:1412kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.309675%
[libx264 # 0x7f8625800c00] frame I:2 Avg QP:13.08 size: 8842
[libx264 # 0x7f8625800c00] frame P:75 Avg QP:24.29 size: 6785
[libx264 # 0x7f8625800c00] frame B:224 Avg QP:26.38 size: 4102
[libx264 # 0x7f8625800c00] consecutive B-frames: 0.7% 0.0% 1.0% 98.3%
[libx264 # 0x7f8625800c00] mb I I16..4: 68.1% 28.7% 3.2%
[libx264 # 0x7f8625800c00] mb P I16..4: 0.1% 2.2% 0.4% P16..4: 6.5% 4.0% 1.4% 0.0% 0.0% skip:85.4%
[libx264 # 0x7f8625800c00] mb B I16..4: 0.0% 0.2% 0.0% B16..8: 8.8% 3.0% 0.3% direct: 0.3% skip:87.3% L0:52.1% L1:47.5% BI: 0.4%
[libx264 # 0x7f8625800c00] 8x8 transform intra:57.7% inter:67.8%
[libx264 # 0x7f8625800c00] coded y,uvDC,uvAC intra: 25.7% 8.7% 0.9% inter: 3.9% 0.4% 0.0%
[libx264 # 0x7f8625800c00] i16 v,h,dc,p: 95% 2% 3% 0%
[libx264 # 0x7f8625800c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 5% 48% 5% 7% 6% 5% 4% 3%
[libx264 # 0x7f8625800c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 14% 31% 6% 7% 7% 6% 5% 4%
[libx264 # 0x7f8625800c00] i8c dc,h,v,p: 88% 6% 6% 0%
[libx264 # 0x7f8625800c00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7f8625800c00] ref P L0: 55.3% 5.5% 24.8% 14.5%
[libx264 # 0x7f8625800c00] ref B L0: 75.6% 16.7% 7.7%
[libx264 # 0x7f8625800c00] ref B L1: 93.9% 6.1%
[libx264 # 0x7f8625800c00] kb/s:2304.86
Any idea on how to overcome this quality loss?
Changing -qscale 1 to -crf 1 resolves the quality issue. The working command is:
ffmpeg -i video.webm -crf 1 -c:v libx264 video.mp4
As outlined in the H.264 Video Encoding Guide -crf takes in values from 0 (lossless) to 51 (worst quality).
Related
I'm using ffmpeg as:
ffmpeg -i "video.webm" -c:v libx264 -vf "crop=in_w:in_h:in_w/2:in_h" -ss 00:02:56.000 -to 00:03:02.750 cut.mp4 -y
to get left side of screen to crop out right one, but in result I'm getting uncropped video (both sides present), when I change command to get right side (to crop out left one):
ffmpeg -i "video.webm" -c:v libx264 -vf "crop=in_w/2:in_h:in_w:in_h" -ss 00:2:56.000 -to 00:03:02.750 cut.mp4 -y
everything works as it should (only right side of original video presents in "cut.mp4").
What am I doing wrong?
P.S.
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11.2.1 (Gentoo 11.2.1_p20220115 p4) 20220115
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.4.1-r5/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --strip=x86_64-pc-linux-gnu-strip --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-march=native -O2 -pipe' --extra-libs= --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=alsa --disable-indev=oss --disable-indev=jack --disable-indev=sndio --disable-outdev=alsa --disable-outdev=oss --disable-outdev=sndio --enable-version3 --enable-bzlib --enable-runtime-cpudetect --disable-debug --disable-gcrypt --enable-gnutls --enable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libxml2 --enable-lzma --enable-network --disable-opencl --enable-openssl --enable-postproc --disable-libsmbclient --disable-ffplay --disable-sdl2 --disable-vaapi --disable-vdpau --disable-vulkan --disable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --disable-opengl --disable-libv4l2 --disable-libpulse --disable-libdrm --disable-libjack --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --disable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --disable-libsrt --enable-librsvg --disable-ffnvcodec --disable-libvorbis --disable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libvmaf --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --disable-libtesseract --disable-lv2 --enable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-amf --disable-libvo-amrwbenc --disable-libkvazaar --disable-libaom --disable-libmp3lame --disable-libopenh264 --disable-librav1e --disable-libsnappy --disable-libsvtav1 --disable-libtheora --disable-libtwolame --enable-libwebp --enable-libx264 --disable-libx265 --disable-libxvid --disable-gnutls --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-fma3 --disable-fma4 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, matroska,webm, from 'video.webm':
Metadata:
ENCODER : Lavf58.76.100
Duration: 00:36:29.58, start: -0.007000, bitrate: 1066 kb/s
Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
Metadata:
DURATION : 00:36:29.560000000
Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
DURATION : 00:36:29.581000000
Stream mapping:
Stream #0:0 -> #0:0 (vp9 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (opus (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x564b4eda52c0] using SAR=1/1
[libx264 # 0x564b4eda52c0] using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX
[libx264 # 0x564b4eda52c0] profile Progressive High, level 4.0, 4:2:0, 8-bit
[libx264 # 0x564b4eda52c0] 264 - core 157 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - 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=15 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=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.40 aq=1:1.00
Output #0, mp4, to 'cut.mp4':
Metadata:
encoder : Lavf58.76.100
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 12800 tbn (default)
Metadata:
DURATION : 00:36:29.560000000
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
DURATION : 00:36:29.581000000
encoder : Lavc58.134.100 aac
frame= 169 fps= 28 q=-1.0 Lsize= 851kB time=00:00:06.74 bitrate=1033.9kbits/s speed=1.12x
video:738kB audio:106kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.764865%
[libx264 # 0x564b4eda52c0] frame I:1 Avg QP:14.29 size: 31413
[libx264 # 0x564b4eda52c0] frame P:43 Avg QP:16.65 size: 9476
[libx264 # 0x564b4eda52c0] frame B:125 Avg QP:22.36 size: 2529
[libx264 # 0x564b4eda52c0] consecutive B-frames: 1.2% 0.0% 1.8% 97.0%
[libx264 # 0x564b4eda52c0] mb I I16..4: 31.6% 63.8% 4.6%
[libx264 # 0x564b4eda52c0] mb P I16..4: 1.4% 5.4% 0.3% P16..4: 13.8% 3.2% 1.0% 0.0% 0.0% skip:75.0%
[libx264 # 0x564b4eda52c0] mb B I16..4: 0.1% 0.2% 0.0% B16..8: 11.4% 0.7% 0.1% direct: 0.4% skip:87.0% L0:48.2% L1:48.1% BI: 3.7%
[libx264 # 0x564b4eda52c0] 8x8 transform intra:73.0% inter:90.2%
[libx264 # 0x564b4eda52c0] coded y,uvDC,uvAC intra: 38.9% 41.7% 6.4% inter: 2.2% 2.7% 0.0%
[libx264 # 0x564b4eda52c0] i16 v,h,dc,p: 45% 18% 5% 31%
[libx264 # 0x564b4eda52c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 20% 22% 5% 6% 7% 5% 7% 5%
[libx264 # 0x564b4eda52c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 22% 14% 6% 10% 8% 7% 5% 3%
[libx264 # 0x564b4eda52c0] i8c dc,h,v,p: 55% 19% 19% 6%
[libx264 # 0x564b4eda52c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x564b4eda52c0] ref P L0: 67.6% 9.2% 16.0% 7.3%
[libx264 # 0x564b4eda52c0] ref B L0: 88.6% 9.5% 1.9%
[libx264 # 0x564b4eda52c0] ref B L1: 97.3% 2.7%
[libx264 # 0x564b4eda52c0] kb/s:893.47
[aac # 0x564b4edde600] Qavg: 208.505
I think you are quite confused about the crop filter options. Here are the descriptions of the first 4 options:
w, out_w
The width of the output video. It defaults to iw. This expression is evaluated only once during the filter configuration, or when the ‘w’ or ‘out_w’ command is sent.
h, out_h
The height of the output video. It defaults to ih. This expression is evaluated only once during the filter configuration, or when the ‘h’ or ‘out_h’ command is sent.
x
The horizontal position, in the input video, of the left edge of the output video. It defaults to (in_w-out_w)/2. This expression is evaluated per-frame.
y
The vertical position, in the input video, of the top edge of the output video. It defaults to (in_h-out_h)/2. This expression is evaluated per-frame.
If you want to halve the width, then the first option must be in_w/2 regardless of which side to crop from.
Height is unchanged, so always use in_h
To crop from left, x offset must match the width, so in_w/2. To crop from right, no pixels are removed on the left edge, so must be 0.
Because no rows are removed, usey = 0.
So to summarize:
Crop the left edge: crop=in_w/2:in_h:in_w/2:0
Crop the right edge: crop=in_w/2:in_h:0:0
I'm tying to split mov file to .ts segments with m3u8 playlist.
All is ok except of audio. Audio doesn't work and it seems that ffmpeg ignores audio stream.
This is my command:
ffmpeg -i stepteen2.mov
-c:a aac
-c:v libx264
-an
-map 0
-muxdelay 0
-muxpreload 0
-output_ts_offset 0
-segment_time 2
-segment_wrap 1000
-segment_list_size 0
-segment_list temp.m3u8
-segment_list_flags +cache
-segment_list_type m3u8
-f segment
temp-%03d.ts
After this command I receive 5 ts segments and m3u8 playlist with segment paths list.
If I open properties of segment files there are no any information in Audio and Video tabs (although video works)
This is output:
ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-avisynth --enable-cuda --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'stepteen2.mov':
Metadata:
creation_time : 1998-11-12T18:28:20.000000Z
Duration: 00:00:28.60, start: 0.000000, bitrate: 111 kb/s
Stream #0:0(eng): Video: svq1 (SVQ1 / 0x31515653), yuv410p, 160x120, 90 kb/s, 7.52 fps, 7.50 tbr, 600 tbn, 600 tbc (default)
Metadata:
creation_time : 1998-11-12T18:28:20.000000Z
handler_name : Apple Video Media Handler
encoder : Sorenson Video
Stream #0:1(eng): Audio: qdmc (QDMC / 0x434D4451), 44100 Hz, mono, s16, 20 kb/s (default)
Metadata:
creation_time : 1998-11-12T18:28:20.000000Z
handler_name : Apple Sound Media Handler
Stream mapping:
Stream #0:0 -> #0:0 (svq1 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x55a5a80b8dc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x55a5a80b8dc0] profile High, level 1.0
[libx264 # 0x55a5a80b8dc0] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=4 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=7 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.40 aq=1:1.00
[segment # 0x55a5a7fd2e00] Opening 'temp-000.ts' for writing
Output #0, segment, to 'temp-%03d.ts':
Metadata:
encoder : Lavf58.20.100
Stream #0:0(eng): Video: h264 (libx264), yuv420p, 160x120, q=-1--1, 7.50 fps, 90k tbn, 7.50 tbc (default)
Metadata:
creation_time : 1998-11-12T18:28:20.000000Z
handler_name : Apple Video Media Handler
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[segment # 0x55a5a7fd2e00] Opening 'temp.m3u8.tmp' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp-001.ts' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp.m3u8.tmp' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp-002.ts' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp.m3u8.tmp' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp-003.ts' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp.m3u8.tmp' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp-004.ts' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp.m3u8.tmp' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp-005.ts' for writing
[segment # 0x55a5a7fd2e00] Opening 'temp.m3u8.tmp' for writing
frame= 215 fps=0.0 q=-1.0 Lsize=N/A time=00:00:28.26 bitrate=N/A speed= 162x
video:217kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 # 0x55a5a80b8dc0] frame I:8 Avg QP:14.15 size: 2625
[libx264 # 0x55a5a80b8dc0] frame P:93 Avg QP:21.28 size: 1295
[libx264 # 0x55a5a80b8dc0] frame B:114 Avg QP:24.62 size: 703
[libx264 # 0x55a5a80b8dc0] consecutive B-frames: 27.0% 2.8% 12.6% 57.7%
[libx264 # 0x55a5a80b8dc0] mb I I16..4: 28.3% 23.0% 48.8%
[libx264 # 0x55a5a80b8dc0] mb P I16..4: 1.5% 6.2% 7.0% P16..4: 21.3% 17.8% 15.1% 0.0% 0.0% skip:31.1%
[libx264 # 0x55a5a80b8dc0] mb B I16..4: 1.2% 1.8% 1.5% B16..8: 28.1% 16.0% 10.0% direct:11.0% skip:30.4% L0:43.4% L1:31.9% BI:24.8%
[libx264 # 0x55a5a80b8dc0] 8x8 transform intra:35.9% inter:39.5%
[libx264 # 0x55a5a80b8dc0] coded y,uvDC,uvAC intra: 73.6% 71.0% 48.2% inter: 34.9% 32.7% 4.3%
[libx264 # 0x55a5a80b8dc0] i16 v,h,dc,p: 61% 12% 26% 2%
[libx264 # 0x55a5a80b8dc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 14% 23% 5% 4% 5% 4% 7% 6%
[libx264 # 0x55a5a80b8dc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 16% 15% 6% 5% 8% 6% 7% 7%
[libx264 # 0x55a5a80b8dc0] i8c dc,h,v,p: 53% 17% 21% 9%
[libx264 # 0x55a5a80b8dc0] Weighted P-Frames: Y:14.0% UV:9.7%
[libx264 # 0x55a5a80b8dc0] ref P L0: 65.2% 16.8% 12.2% 5.4% 0.4%
[libx264 # 0x55a5a80b8dc0] ref B L0: 92.3% 6.2% 1.4%
[libx264 # 0x55a5a80b8dc0] ref B L1: 97.3% 2.7%
[libx264 # 0x55a5a80b8dc0] kb/s:61.84
I see that Output #0, segment, to 'temp-%03d.ts' contains only video stream:
Stream #0:0(eng): Video: h264 (libx264), yuv420p, 160x120, q=-1--1, 7.50 fps, 90k tbn, 7.50 tbc (default)
...
video:217kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Remove -an. This option means "no audio".
I'm trying to insert 13 seconds of black video at the start of a video that has sound using ffmpeg like so:
ffmpeg -f lavfi -i "color=c=black:s=720x406:r=25:sar=1/1" -i input.mp4 -filter_complex \
"[0:v] trim=end=13,setpts=PTS-STARTPTS [blackstart]; \
[blackstart] [1:v] concat=n=2:v=1:a=0[out]" \
-map "[out]" -c:a copy output.mp4
However the sound is not being maintained. What am I doing incorrectly? -c:a copy does not seem to work should I be using a [1:a] somewhere?
garrett-retina:~ garrett-macbookretina$ ffmpeg -f lavfi -i "color=c=red:s=720x406:r=25:sar=1/1" -i input.mp4 -filter_complex \
> "[0:v] trim=end=13,setpts=PTS-STARTPTS [blackstart]; \
> [blackstart] [1:v] concat=n=2:v=1:a=0[out]" \
> -map "[out]" -c:a copy output.mp4
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, lavfi, from 'color=c=red:s=720x406:r=25:sar=1/1':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x406 [SAR 1:1 DAR 360:203], 25 tbr, 25 tbn, 25 tbc
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.56.100
Duration: 33:59:47.32, start: 0.000000, bitrate: 179 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x406 [SAR 1:1 DAR 360:203], 62 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 16000 Hz, stereo, fltp, 114 kb/s (default)
Metadata:
handler_name : SoundHandler
[libx264 # 0x7fa344048400] using SAR=1/1
[libx264 # 0x7fa344048400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x7fa344048400] profile High, level 3.0
[libx264 # 0x7fa344048400] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=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=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.40 aq=1:1.00
Output #0, mp4, to '/Users/garrett-macbookretina/Desktop/Best of Luck With the Wall/exports/test.mp4':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x406 [SAR 1:1 DAR 360:203], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
encoder : Lavc57.64.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 (rawvideo) -> trim
Stream #1:0 (h264) -> concat:in1:v0
concat -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
frame=3060008 fps=432 q=-1.0 Lsize= 957795kB time=34:00:00.20 bitrate= 64.1kbits/s speed=17.3x
video:921972kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.885564%
[libx264 # 0x7fa344048400] frame I:16585 Avg QP:13.67 size: 49743
[libx264 # 0x7fa344048400] frame P:770518 Avg QP:16.48 size: 91
[libx264 # 0x7fa344048400] frame B:2272905 Avg QP:25.11 size: 22
[libx264 # 0x7fa344048400] consecutive B-frames: 0.9% 0.1% 0.4% 98.6%
[libx264 # 0x7fa344048400] mb I I16..4: 10.2% 39.7% 50.1%
[libx264 # 0x7fa344048400] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.7% 0.0% 0.0% 0.0% 0.0% skip:99.1%
[libx264 # 0x7fa344048400] 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:46.9% L1:53.1% BI: 0.1%
[libx264 # 0x7fa344048400] 8x8 transform intra:39.9% inter:52.0%
[libx264 # 0x7fa344048400] coded y,uvDC,uvAC intra: 86.1% 77.1% 60.4% inter: 0.0% 0.1% 0.0%
[libx264 # 0x7fa344048400] i16 v,h,dc,p: 66% 10% 13% 11%
[libx264 # 0x7fa344048400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 20% 14% 6% 7% 7% 7% 7% 11%
[libx264 # 0x7fa344048400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 19% 11% 7% 9% 8% 8% 7% 9%
[libx264 # 0x7fa344048400] i8c dc,h,v,p: 59% 19% 17% 5%
[libx264 # 0x7fa344048400] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7fa344048400] ref P L0: 53.9% 4.0% 16.6% 25.5% 0.0%
[libx264 # 0x7fa344048400] ref B L0: 27.9% 71.6% 0.5%
[libx264 # 0x7fa344048400] ref B L1: 97.6% 2.4%
[libx264 # 0x7fa344048400] kb/s:61.71
garrett-retina:~ garrett-macbookretina$
You need to add silent audio as well. One method using anullsrc:
ffmpeg \
-f lavfi -i "color=c=black:s=720x406:r=25:sar=1/1:d=13" \
-f lavfi -t 1 -i anullsrc=cl=stereo:r=16000 \
-i input.mp4 \
-filter_complex \
"[2:v]setpts=PTS-STARTPTS[video]; \
[0:v][1:a][video][2:a]concat=n=2:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4
The silent audio duration only needs to be shorter than the black video duration; the concat filter will pad the rest automatically.
I'm unable to test this example at the moment, but if it is broken let me know and I can fix it later.
I am stuck at a very weird and complex problem, hoping if anyone know the solution:
I am converting user uploaded video using ffmpeg command on server and it was working fine as well. Today I found that if a video is recorded by a webcam from windows, is playing well in linux as well as on windows where as if user is creating a video by webcam from linux, is playing only on linux (any browser). On window it's screen either show loading icon or black screen while audio is working fine.
I am using following codec:
['-strict', '-2', '-preset slow', '-maxrate 500k', '-bufsize 1000k', vfOption, '-threads 0', '-ab 64k', '-movflags faststart','-vf scale=-1:480', '-metadata:s:v:0 rotate=0', '-vcodec libx264']
I work on linux and using html5 player on my website. I am converting video in mp4 format.
Input:
ffmpeg -i /<server path>/stream_FE2AF05B-E630-1F7B-390B-37325B31B362.flv -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags faststart -metadata:s:v:0 rotate=0 /<server path>/testing.mp4
Output:
ffmpeg version 2.2.5 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 1 2014 09:24:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libtheora --enable-libx264 --enable-libvpx --enable-libmp3lame
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, flv, from '/<server path>/stream_FE2AF05B-E630-1F7B-390B-37325B31B362.flv':
Metadata:
canSeekToEnd : true
Duration: 00:00:04.04, start: 0.000000, bitrate: 636 kb/s
Stream #0:0: Video: flv1, yuv420p, 640x480, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 44100 Hz, mono, flt
[libx264 # 0x23c5340] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x23c5340] profile High, level 5.2
[libx264 # 0x23c5340] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 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=24 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=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/<server path>/testing.mp4':
Metadata:
canSeekToEnd : true
encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 500 kb/s, 16k tbn, 1k tbc
Metadata:
rotate : 0
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (flv -> libx264)
Stream #0:1 -> #0:1 (nellymoser -> aac)
Press [q] to stop, [?] for help
[mp4 # 0x23c0200] Starting second pass: moving the moov atom to the beginning of the file2 drop=0
frame= 4020 fps=706 q=-1.0 Lsize= 355kB time=00:00:04.08 bitrate= 712.0kbits/s dup=3931 drop=0
video:271kB audio:32kB subtitle:0 data:0 global headers:0kB muxing overhead 16.957901%
[libx264 # 0x23c5340] frame I:17 Avg QP:27.55 size: 7119
[libx264 # 0x23c5340] frame P:1013 Avg QP:25.37 size: 88
[libx264 # 0x23c5340] frame B:2990 Avg QP:27.32 size: 22
[libx264 # 0x23c5340] consecutive B-frames: 0.8% 0.0% 0.1% 99.1%
[libx264 # 0x23c5340] mb I I16..4: 42.0% 55.1% 2.9%
[libx264 # 0x23c5340] mb P I16..4: 0.3% 0.4% 0.0% P16..4: 0.6% 0.1% 0.0% 0.0% 0.0% skip:98.6%
[libx264 # 0x23c5340] 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:35.7% L1:64.3% BI: 0.0%
[libx264 # 0x23c5340] 8x8 transform intra:55.0% inter:84.5%
[libx264 # 0x23c5340] direct mvs spatial:87.6% temporal:12.4%
[libx264 # 0x23c5340] coded y,uvDC,uvAC intra: 33.4% 51.9% 0.7% inter: 0.0% 0.1% 0.0%
[libx264 # 0x23c5340] i16 v,h,dc,p: 26% 54% 15% 5%
[libx264 # 0x23c5340] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 16% 53% 3% 1% 2% 2% 3% 3%
[libx264 # 0x23c5340] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 20% 13% 14% 5% 7% 7% 11% 8%
[libx264 # 0x23c5340] i8c dc,h,v,p: 43% 31% 23% 3%
[libx264 # 0x23c5340] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x23c5340] ref P L0: 80.9% 9.0% 6.9% 2.6% 0.7%
[libx264 # 0x23c5340] ref B L0: 89.4% 8.6% 1.8% 0.2%
[libx264 # 0x23c5340] ref B L1: 91.0% 9.0%
[libx264 # 0x23c5340] kb/s:551.72
Outout from file recorded on window:
Input:
ffmpeg -i /<server path>/stream_window.flv -strict -2 -vcodec libx264 -preset slow -vb 500k -maxrate 500k -bufsize 1000k -vf 'scale=-1:480 ' -threads 0 -ab 64k -s 640x480 -movflags faststart -metadata:s:v:0 rotate=0 /<server path>/testing_1.mp4
Output:
ffmpeg version 2.2.5 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 1 2014 09:24:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libtheora --enable-libx264 --enable-libvpx --enable-libmp3lame
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, flv, from '/<server path>/stream_window.flv':
Metadata:
canSeekToEnd : true
Duration: 00:00:09.22, start: 0.000000, bitrate: 420 kb/s
Stream #0:0: Video: flv1, yuv420p, 640x480, 1k tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: nellymoser, 44100 Hz, mono, flt
[libx264 # 0x1e09fc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x1e09fc0] profile High, level 5.2
[libx264 # 0x1e09fc0] 264 - core 142 r2453 ea0ca51 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 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=24 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=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/<server path>/testing_1.mp4':
Metadata:
canSeekToEnd : true
encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 500 kb/s, 16k tbn, 1k tbc
Metadata:
rotate : 0
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (flv -> libx264)
Stream #0:1 -> #0:1 (nellymoser -> aac)
Press [q] to stop, [?] for help
[mp4 # 0x1e06220] Starting second pass: moving the moov atom to the beginning of the file7 drop=0
frame= 8936 fps=703 q=-1.0 Lsize= 771kB time=00:00:09.26 bitrate= 681.5kbits/s dup=8907 drop=0
video:585kB audio:73kB subtitle:0 data:0 global headers:0kB muxing overhead 17.106213%
[libx264 # 0x1e09fc0] frame I:40 Avg QP:29.54 size: 7449
[libx264 # 0x1e09fc0] frame P:2248 Avg QP:30.88 size: 69
[libx264 # 0x1e09fc0] frame B:6648 Avg QP:39.17 size: 22
[libx264 # 0x1e09fc0] consecutive B-frames: 0.8% 0.0% 0.1% 99.1%
[libx264 # 0x1e09fc0] mb I I16..4: 36.8% 60.7% 2.5%
[libx264 # 0x1e09fc0] mb P I16..4: 0.2% 0.3% 0.0% P16..4: 0.4% 0.0% 0.0% 0.0% 0.0% skip:98.9%
[libx264 # 0x1e09fc0] 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:34.2% L1:65.8% BI: 0.0%
[libx264 # 0x1e09fc0] 8x8 transform intra:60.6% inter:87.6%
[libx264 # 0x1e09fc0] direct mvs spatial:72.8% temporal:27.2%
[libx264 # 0x1e09fc0] coded y,uvDC,uvAC intra: 36.3% 62.8% 4.7% inter: 0.0% 0.0% 0.0%
[libx264 # 0x1e09fc0] i16 v,h,dc,p: 33% 46% 15% 7%
[libx264 # 0x1e09fc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 19% 46% 3% 1% 1% 1% 2% 4%
[libx264 # 0x1e09fc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 17% 14% 9% 4% 4% 5% 5% 7%
[libx264 # 0x1e09fc0] i8c dc,h,v,p: 42% 31% 23% 4%
[libx264 # 0x1e09fc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x1e09fc0] ref P L0: 82.6% 9.9% 5.2% 1.7% 0.5%
[libx264 # 0x1e09fc0] ref B L0: 87.1% 11.0% 1.4% 0.4%
[libx264 # 0x1e09fc0] ref B L1: 90.3% 9.7%
[libx264 # 0x1e09fc0] kb/s:536.03
Can anyone figure what could be the problem?
#LordNeckbeard: Please find the command and its output above. Thanks
I am trying to create a video out of one image and copy audio on top. Following this (last section), I tried:
$ ffmpeg -loop 1 -i img.jpg -i audio.mp3 -c:v libx264 -c:a copy -shortest h264.mp4
ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Feb 23 2015 10:29:52 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, image2, from 'img.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 123986 kb/s
Stream #0:0: Video: mjpeg, yuvj440p(pc, bt470bg/unknown/unknown), 1440x900 [SAR 72:72 DAR 8:5], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 # 0x7f94d2034600] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'audio.mp3':
Metadata:
genre : Other
Duration: 00:00:03.25, start: 0.000000, bitrate: 130 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, mono, s16p, 128 kb/s
[swscaler # 0x7f94d2800000] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0x7f94d281b200] using SAR=1/1
[libx264 # 0x7f94d281b200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 # 0x7f94d281b200] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 # 0x7f94d281b200] 264 - core 142 r2455 021c0dc - 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=4 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=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'h264.mp4':
Metadata:
encoder : Lavf56.15.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj444p(pc), 1440x900 [SAR 1:1 DAR 8:5], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc56.13.100 libx264
Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, mono, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 64 fps= 30 q=28.0 size= 332kB time=00:00:00.48 bitrate=5670.9kbits/frame= 80 fps= 30 q=28.0 size= 344kB time=00:00:01.12 bitrate=2514.2kbits/frame= 96 fps= 30 q=28.0 size= 356kB time=00:00:01.76 bitrate=1655.1kbits/frame= 112 fps= 30 q=28.0 size= 367kB time=00:00:02.40 bitrate=1252.1kbits/frame= 129 fps= 31 q=28.0 size= 378kB time=00:00:03.08 bitrate=1006.5kbits/frame= 134 fps= 26 q=-1.0 Lsize= 386kB time=00:00:03.28 bitrate= 963.5kbits/s
video:331kB audio:51kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.120110%
[libx264 # 0x7f94d281b200] frame I:1 Avg QP:19.84 size:329471
[libx264 # 0x7f94d281b200] frame P:34 Avg QP:16.64 size: 189
[libx264 # 0x7f94d281b200] frame B:99 Avg QP:25.33 size: 48
[libx264 # 0x7f94d281b200] consecutive B-frames: 1.5% 0.0% 0.0% 98.5%
[libx264 # 0x7f94d281b200] mb I I16..4: 2.8% 70.0% 27.3%
[libx264 # 0x7f94d281b200] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 1.2% 0.0% 0.0% 0.0% 0.0% skip:98.8%
[libx264 # 0x7f94d281b200] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0: 1.6% L1:98.4% BI: 0.0%
[libx264 # 0x7f94d281b200] 8x8 transform intra:70.0% inter:95.0%
[libx264 # 0x7f94d281b200] coded y,u,v intra: 96.4% 73.8% 72.9% inter: 0.0% 0.0% 0.0%
[libx264 # 0x7f94d281b200] i16 v,h,dc,p: 37% 4% 1% 58%
[libx264 # 0x7f94d281b200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 27% 8% 3% 5% 5% 8% 4% 9%
[libx264 # 0x7f94d281b200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 18% 5% 3% 7% 7% 10% 5% 7%
[libx264 # 0x7f94d281b200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7f94d281b200] ref P L0: 20.0% 0.4% 42.4% 37.2%
[libx264 # 0x7f94d281b200] ref B L0: 0.0% 100.0%
[libx264 # 0x7f94d281b200] ref B L1: 90.9% 9.1%
[libx264 # 0x7f94d281b200] kb/s:508.50
But I get a video with no audio in QuickTime. I think its a problem of the output container (mp4) not supporting mp3. What output container might be best? Due to quality loss, I am reluctant to convert the mp3 to another format. If my audio is mp3, what might I change about this ffmpeg command?
The final destination is YouTube.
Because YouTube is the final location you can ignore the other players:
Most non-FFmpeg based players can't decode yuvj444p. If you want the video in these other players to work, then add -pix_fmt yuv420p as an output option as mentioned in the console output.
Some players have trouble decoding MP3 in MP4 such as QuickTime and WMP with certain audio rates. If you need it to work in these players you'll need to re-encode to AAC audio by changing -c:a copy to -c:a aac.
Since the input is a single image you can reduce your frame rate for a much faster encoding by adding -framerate 1 as an input option. Again, some players may not be able to decode this frame rate.
YouTube can handle these potential issues, so feel free to upload it. See FFmpeg Wiki: YouTube for more info.