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
Related
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 have been using FFMPEG to overlay coloured rectangles on a video. I updated FFMPEG and it no longer works. No error is issued, it just doesn't do the job - the resulting video is the same as the input video. Here's the script:
FFMpeg -y -i Input.mp4 -filter_complex \
"nullsrc=size=1920x1080, \
drawbox=x=200:y=100:w=300:h=150:t=20:c=yellow, fade=in:st=10:d=1:alpha=1, fade=out:st=20:d=2:alpha=1 [tmp1]; \
nullsrc=size=1920x1080, \
drawbox=x=240:y=140:w=300:h=150:t=20:c=red, fade=in:st=15:d=1:alpha=1, fade=out:st=25:d=2:alpha=1 [tmp2]; \
[tmp1][tmp2] overlay=0:0:shortest=1[tmp3]; \
[0:v][tmp3] overlay=0:0:shortest=1" \
Output.mp4
The output video should be the input video with a yellow rectangle added from T=10 to T=20 and a red rectangle from T=15 to T=25, fading them in and out.
The version that was working (3.4) was one that came with an ImageMagick installation. The version I updated it to was 4.2.3. I tried it on various other builds I had lying around and it only works with 3.4.
It seems unlikely that this is a regression so I haven't submitted a bug report. I figure it's more likely that I'm not doing something correctly and 3.4 is more lenient on its interpretation of my command.
Whatever, I prefer to be working with a current build, so I invite comments on what the reasons might be.
Console dump of 3.4 run
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
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
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:01:48.67, start: 0.000000, bitrate: 1693 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1562 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 126 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 000001f0d4a0e6a0] using SAR=1/1
[libx264 # 000001f0d4a0e6a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001f0d4a0e6a0] profile High, level 4.0
[libx264 # 000001f0d4a0e6a0] 264 - core 152 r2851 ba24899 - 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=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 'Output-34.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.107.100 aac
frame= 3260 fps= 25 q=-1.0 Lsize= 21461kB time=00:01:48.56 bitrate=1619.3kbits/s speed=0.828x
video:19713kB audio:1634kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.534457%
[libx264 # 000001f0d4a0e6a0] frame I:14 Avg QP:17.68 size:208205
[libx264 # 000001f0d4a0e6a0] frame P:844 Avg QP:21.55 size: 16867
[libx264 # 000001f0d4a0e6a0] frame B:2402 Avg QP:28.40 size: 1263
[libx264 # 000001f0d4a0e6a0] consecutive B-frames: 0.7% 2.9% 0.4% 96.0%
[libx264 # 000001f0d4a0e6a0] mb I I16..4: 14.0% 39.6% 46.4%
[libx264 # 000001f0d4a0e6a0] mb P I16..4: 0.4% 0.7% 0.2% P16..4: 20.2% 9.1% 4.6% 0.0% 0.0% skip:64.8%
[libx264 # 000001f0d4a0e6a0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 12.4% 0.4% 0.1% direct: 0.1% skip:87.1% L0:42.9% L1:55.2% BI: 1.9%
[libx264 # 000001f0d4a0e6a0] 8x8 transform intra:45.2% inter:68.3%
[libx264 # 000001f0d4a0e6a0] coded y,uvDC,uvAC intra: 64.4% 81.6% 45.1% inter: 2.9% 4.2% 0.1%
[libx264 # 000001f0d4a0e6a0] i16 v,h,dc,p: 32% 26% 6% 37%
[libx264 # 000001f0d4a0e6a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 20% 15% 5% 6% 7% 7% 7% 8%
[libx264 # 000001f0d4a0e6a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 28% 8% 4% 6% 6% 6% 5% 5%
[libx264 # 000001f0d4a0e6a0] i8c dc,h,v,p: 37% 25% 28% 10%
[libx264 # 000001f0d4a0e6a0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 000001f0d4a0e6a0] ref P L0: 70.4% 15.3% 10.8% 3.5%
[libx264 # 000001f0d4a0e6a0] ref B L0: 93.1% 6.0% 0.9%
[libx264 # 000001f0d4a0e6a0] ref B L1: 97.8% 2.2%
[libx264 # 000001f0d4a0e6a0] kb/s:1486.03
[aac # 000001f0d4a10a20] Qavg: 1586.609
And 4.2.3
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200523
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:01:48.67, start: 0.000000, bitrate: 1693 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1562 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 126 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> overlay:main (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 000001e7b4531d40] using SAR=1/1
[libx264 # 000001e7b4531d40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 000001e7b4531d40] profile High, level 4.0, 4:2:0, 8-bit
[libx264 # 000001e7b4531d40] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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 'Output-423.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.54.100 aac
frame= 3260 fps= 28 q=-1.0 Lsize= 21425kB time=00:01:48.56 bitrate=1616.7kbits/s speed=0.917x
video:19686kB audio:1625kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.535352%
[libx264 # 000001e7b4531d40] frame I:14 Avg QP:17.68 size:208355
[libx264 # 000001e7b4531d40] frame P:844 Avg QP:21.54 size: 16838
[libx264 # 000001e7b4531d40] frame B:2402 Avg QP:28.43 size: 1261
[libx264 # 000001e7b4531d40] consecutive B-frames: 0.7% 2.9% 0.4% 96.0%
[libx264 # 000001e7b4531d40] mb I I16..4: 13.9% 39.7% 46.4%
[libx264 # 000001e7b4531d40] mb P I16..4: 0.4% 0.7% 0.2% P16..4: 20.2% 9.1% 4.6% 0.0% 0.0% skip:64.8%
[libx264 # 000001e7b4531d40] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 12.4% 0.4% 0.1% direct: 0.1% skip:87.1% L0:42.9% L1:55.2% BI: 1.9%
[libx264 # 000001e7b4531d40] 8x8 transform intra:45.3% inter:68.3%
[libx264 # 000001e7b4531d40] coded y,uvDC,uvAC intra: 65.2% 82.4% 45.8% inter: 2.9% 4.2% 0.1%
[libx264 # 000001e7b4531d40] i16 v,h,dc,p: 32% 24% 6% 38%
[libx264 # 000001e7b4531d40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 19% 14% 5% 6% 7% 7% 7% 8%
[libx264 # 000001e7b4531d40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 28% 8% 4% 6% 6% 6% 5% 5%
[libx264 # 000001e7b4531d40] i8c dc,h,v,p: 37% 24% 28% 11%
[libx264 # 000001e7b4531d40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 000001e7b4531d40] ref P L0: 70.4% 15.3% 10.8% 3.5%
[libx264 # 000001e7b4531d40] ref B L0: 93.1% 6.0% 0.9%
[libx264 # 000001e7b4531d40] ref B L1: 97.8% 2.2%
[libx264 # 000001e7b4531d40] kb/s:1483.98
[aac # 000001e7b47fa800] Qavg: 1462.566
There was a bug in the drawbox filter whereby the source alpha pixels would be replaced with the drawbox color's alpha (usually opaque) instead of preserving or blending it. Your command relies on that remaining the case, but I changed that after 3.4 series, so you now have to tell drawbox to replace the alpha for the box pixels.
So,
drawbox=x=200:y=100:w=300:h=150:t=20:c=yellow:replace=1
and
drawbox=x=240:y=140:w=300:h=150:t=20:c=red:replace=1
My source for inputs into FFmpeg is either one AVI file or a concat of many of them. Either way my resulting timelapse file has a long tail of frames that are a repeat of a single frame. It's like a very long freeze frame is resulting on the end of my output file.
I'm on an older Mac Pro so I can't update my FFmpeg. I have a laptop that has a newer version and I get the same there as well. I'm not sure if it's because my source files are AVI or not.
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags=-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/ --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[avi # 0x7fa82080c800] sample size (1) != block align (2)
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'concat:16460001.AVI|16460002.AVI|16460003.AVI|16460004.AVI|16460005.AVI|16460006.AVI|16460007.AVI|16460008.AVI|16460009.AVI|16460010.AVI|16460011.AVI|16460012.AVI|16460013.AVI|16460014.AVI|16460015.AVI|16460016.AVI|16460017.AVI|16460018.AVI|16460019.AVI|16460020.AVI|16460021.AVI':
Duration: 00:10:02.00, start: 0.000000, bitrate: 365923 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 32000 Hz, mono, s16, 512 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x7fa82082cc00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 # 0x7fa82082cc00] profile High, level 3.1
[libx264 # 0x7fa82082cc00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=16 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 'out.mp4':
Metadata:
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1280x720, q=-1--1, 16 fps, 16384 tbn, 16 tbc
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 69 kb/s
Metadata:
encoder : Lavc58.35.100 aac
frame= 1962 fps=1.2 q=-1.0 Lsize= 136725kB time=03:24:07.00 bitrate= 91.5kbits/s dup=0 drop=365448 speed=7.41x
video:31548kB audio:103624kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.149437%
[libx264 # 0x7fa82082cc00] frame I:10 Avg QP:18.74 size: 62176
[libx264 # 0x7fa82082cc00] frame P:514 Avg QP:21.24 size: 30528
[libx264 # 0x7fa82082cc00] frame B:1438 Avg QP:22.74 size: 11121
[libx264 # 0x7fa82082cc00] consecutive B-frames: 1.4% 2.0% 2.0% 94.6%
[libx264 # 0x7fa82082cc00] mb I I16..4: 2.1% 97.2% 0.7%
[libx264 # 0x7fa82082cc00] mb P I16..4: 2.0% 33.3% 0.1% P16..4: 37.7% 12.0% 10.4% 0.0% 0.0% skip: 4.5%
[libx264 # 0x7fa82082cc00] mb B I16..4: 0.7% 11.5% 0.0% B16..8: 29.1% 4.8% 1.3% direct:12.0% skip:40.6% L0:47.5% L1:42.9% BI: 9.6%
[libx264 # 0x7fa82082cc00] 8x8 transform intra:94.3% inter:83.0%
[libx264 # 0x7fa82082cc00] coded y,uvDC,uvAC intra: 73.4% 66.7% 8.5% inter: 25.9% 46.8% 2.2%
[libx264 # 0x7fa82082cc00] i16 v,h,dc,p: 17% 33% 26% 24%
[libx264 # 0x7fa82082cc00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 23% 51% 1% 2% 1% 4% 1% 2%
[libx264 # 0x7fa82082cc00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 21% 19% 5% 8% 7% 13% 5% 5%
[libx264 # 0x7fa82082cc00] i8c dc,h,v,p: 46% 29% 23% 2%
[libx264 # 0x7fa82082cc00] Weighted P-Frames: Y:47.5% UV:19.3%
[libx264 # 0x7fa82082cc00] ref P L0: 45.0% 13.8% 20.6% 15.7% 5.0%
[libx264 # 0x7fa82082cc00] ref B L0: 61.1% 30.4% 8.5%
[libx264 # 0x7fa82082cc00] ref B L1: 85.8% 14.2%
[libx264 # 0x7fa82082cc00] kb/s:2107.54
[aac # 0x7fa82081ea00] Qavg: 130.084
I've read this thread and tried to follow it:
Create time lapse video from other video
Here are some trials I've attempted before, all with the same output:
# ffmpeg -y -i $mov -vf framestep=10,setpts=N/FRAME_RATE/TB,fps=2 -r 30 $out
# ffmpeg -y -i $mov -vf framestep=10,setpts=.01*PTS -r 30 $out
# ffmpeg -y -i $mov -vf framestep=10,setpts=.1*PTS -r 30 $out
# ffmpeg -y -i "concat:16460001.AVI|16460002.AVI|16460003.AVI|16460004.AVI|16460005.AVI|16460006.AVI|16460007.AVI|16460008.AVI|16460009.AVI|16460010.AVI|16460011.AVI|16460012.AVI|16460013.AVI|16460014.AVI|16460015.AVI|16460016.AVI|16460017.AVI|16460018.AVI|16460019.AVI|16460020.AVI|16460021.AVI" -vf framestep=10,setpts=.05*PTS -r 30 $out
ffmpeg -y -i "concat:16460001.AVI|16460002.AVI|16460003.AVI|16460004.AVI|16460005.AVI|16460006.AVI|16460007.AVI|16460008.AVI|16460009.AVI|16460010.AVI|16460011.AVI|16460012.AVI|16460013.AVI|16460014.AVI|16460015.AVI|16460016.AVI|16460017.AVI|16460018.AVI|16460019.AVI|16460020.AVI|16460021.AVI" -r 16 -filter:v "setpts=0.01*PTS" out.mp4
Am I overlooking something? I'm trying to speed up the inputs into a single file to quickly review incoming security footage. How can I do this without the super long useless tail at the end?
Use
ffmpeg -i 16460021.AVI -vf framestep=15,setpts=N/30/TB -r 30 -an out.mp4
I get an output 1/15th the length of the original. When using framestep=X, setpts should be of the form N/X/TB if you wish to avoid frame duplication. Don't use fps when compressing video duration as it uses old stream duration from before compression (a bug). Skip audio, since that will result in original length.
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).
This question already has an answer here:
FFmpeg converting image sequence to video results in blank video [closed]
(1 answer)
Closed 5 years ago.
My current project involves creating a .flv using AIR (using https://github.com/zeropointnine/leelib/tree/master/src/leelib/util/flvEncoder) - which then has to be converted into an .mp4, for which we are using ffmpeg.
The .mp4 output is the correct dimensions and duration, but blank (no images). Audio is not an issue as the original output has no audio.
ffmpeg version N-55020-g768e40b Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 28 2013 18:05:44 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --e
nable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable
-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enab
le-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheo
ra --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --en
able-libxavs --enable-libxvid --enable-zlib
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 19.100 / 55. 19.100
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.103 / 3. 81.103
libswscale 2. 4.100 / 2. 4.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, flv, from 'testWithAudio.flv':
Metadata:
canSeekToEnd : true
metadatacreator : FlvEncoder v0.9 Lee Felarca
Duration: 00:00:44.77, start: 0.000000, bitrate: 56730 kb/s
Stream #0:0: Video: flashsv, bgr24, 400x400, 30 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 00000000002e1da0] using cpu capabilities: MMX2 SSE2Fast SSEMisalign LZCNT
[libx264 # 00000000002e1da0] profile High 4:4:4 Predictive, level 2.1, 4:4:4 8-bit
[libx264 # 00000000002e1da0] 264 - core 135 r2345 f0c1c53 - 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=4 threads=1 lookahead_threads=1 sl
iced_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 dire
ct=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 'testWithAudio.mp4':
Metadata:
canSeekToEnd : true
metadatacreator : FlvEncoder v0.9 Lee Felarca
encoder : Lavf55.12.102
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 400x400, q=-1--1, 15360 tbn, 30 tbc
Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (flashsv -> libx264)
Stream #0:1 -> #0:1 (pcm_s16le -> libvo_aacenc)
Press [q] to stop, [?] for help
frame= 1343 fps= 25 q=29.0 Lsize= 2680kB time=00:00:44.70 bitrate= 491.2kbits/s
video:1943kB audio:691kB subtitle:0 global headers:0kB muxing overhead 1.756713%
[libx264 # 00000000002e1da0] frame I:25 Avg QP:20.44 size: 14523
[libx264 # 00000000002e1da0] frame P:614 Avg QP:23.20 size: 2319
[libx264 # 00000000002e1da0] frame B:704 Avg QP:24.59 size: 287
[libx264 # 00000000002e1da0] consecutive B-frames: 25.6% 11.0% 7.4% 56.0%
[libx264 # 00000000002e1da0] mb I I16..4: 17.6% 67.0% 15.3%
[libx264 # 00000000002e1da0] mb P I16..4: 7.6% 9.9% 0.8% P16..4: 28.0% 8.3% 4.0% 0.0% 0.0% skip:41.4%
[libx264 # 00000000002e1da0] mb B I16..4: 0.4% 0.5% 0.0% B16..8: 16.3% 1.1% 0.1% direct: 0.2% skip:81.4% L0:39.7% L
1:57.4% BI: 2.8%
[libx264 # 00000000002e1da0] 8x8 transform intra:56.3% inter:85.5%
[libx264 # 00000000002e1da0] coded y,u,v intra: 35.7% 17.0% 19.1% inter: 7.7% 3.8% 3.4%
[libx264 # 00000000002e1da0] i16 v,h,dc,p: 26% 28% 17% 30%
[libx264 # 00000000002e1da0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 33% 4% 4% 5% 4% 4% 4%
[libx264 # 00000000002e1da0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 21% 16% 5% 6% 9% 6% 6% 6%
[libx264 # 00000000002e1da0] Weighted P-Frames: Y:6.5% UV:3.3%
[libx264 # 00000000002e1da0] ref P L0: 56.8% 16.5% 18.2% 8.0% 0.6%
[libx264 # 00000000002e1da0] ref B L0: 82.3% 14.1% 3.7%
[libx264 # 00000000002e1da0] ref B L1: 93.7% 6.3%
[libx264 # 00000000002e1da0] kb/s:355.47
Any ideas?
See the informational message:
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
So, add -pix_fmt yuv420p and you should be fine.