../ffmpeg/ffmpeg -err_detect ignore_err -nostdin -threads 0 -y -strict experimental -thread_queue_size 10M -max_delay 20M -rtbufsize 20M -fflags +discardcorrupt \
-i "${cam1}" -i "${cam2}" -i "${cam3}" -i "${cam4}" \
-filter_complex " \
nullsrc=size=3840x2160:rate=30 [main1]; \
anullsrc=channel_layout=stereo:sample_rate=44100 [a]; \
[0:v] scale=1920:1080 [overlay1]; \
[1:v] scale=1920:1080 [overlay2]; \
[2:v] scale=1920:1080 [overlay3]; \
[3:v] scale=1920:1080 [overlay4]; \
[main1][overlay1] overlay=0:0 [main2]; \
[main2][overlay2] overlay=1920:0 [main3]; \
[main3][overlay3] overlay=0:1080 [main4]; \
[main4][overlay4] overlay=1920:1080 [v] " \
-t 10 -r 30 -g 60 -map "[v]" -map "[a]" \
-shortest -video_size 3840x2160 -pix_fmt yuv420p -vcodec libx264 -preset ultrafast -tune zerolatency -minrate 2M -maxrate 2M -bufsize 20M -c:a aac -b:a 96k -ac 2 -ar 48000 -copytb 1 \
-f flv -y -fflags +genpts rtmp://b.rtmp.youtube.com/live2/${key}?backup=1
ffmpeg version N-109650-g9d5e66942c Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/home/bloodman/ffmpeg --pkg-config-flags=--static --extra-cflags='-I/home/bloodman/ffmpeg/include -march=native' --extra-ldflags=-L/home/bloodman/ffmpeg/lib --extra-libs='-lpthread -lm' --bindir=/home/bloodman/ffmpeg --enable-gpl --enable-nonfree --enable-libx264 --enable-libfdk-aac --enable-libmp3lame --enable-libfreetype --enable-hardcoded-tables
libavutil 57. 44.100 / 57. 44.100
libavcodec 59. 56.100 / 59. 56.100
libavformat 59. 35.100 / 59. 35.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 54.100 / 8. 54.100
libswscale 6. 8.112 / 6. 8.112
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100
[hls # 0x56019db77780] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019db77780] Opening 'cams/stream1_113.ts' for reading
Input #0, hls, from 'cams/stream1.m3u8':
Duration: N/A, start: 1122.341667, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (Baseline) ([27][0][0][0] / 0x001B), yuv420p, 2048x1536, 15 fps, 15 tbr, 90k tbn
Metadata:
variant_bitrate : 0
[hls # 0x56019db9e980] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019db9e980] Opening 'cams/stream2_105.ts' for reading
Input #1, hls, from 'cams/stream2.m3u8':
Duration: N/A, start: 1042.633000, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #1:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 100 tbr, 90k tbn
Metadata:
variant_bitrate : 0
[hls # 0x56019dccdbc0] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019dccdbc0] Opening 'cams/stream3_14.ts' for reading
Input #2, hls, from 'cams/stream3.m3u8':
Duration: N/A, start: 132.469000, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #2:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 2688x1520, 25 fps, 100 tbr, 90k tbn
Metadata:
variant_bitrate : 0
[hls # 0x56019f0ec980] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019f0ec980] Opening 'cams/stream4_26.ts' for reading
Input #3, hls, from 'cams/stream4.m3u8':
Duration: N/A, start: 253.389000, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #3:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709), 1920x1080, 90k tbr, 90k tbn
Metadata:
variant_bitrate : 0
Stream mapping:
Stream #0:0 (h264) -> scale:default
Stream #1:0 (h264) -> scale:default
Stream #2:0 (h264) -> scale:default
Stream #3:0 (h264) -> scale:default
overlay:default -> Stream #0:0 (libx264)
anullsrc:default -> Stream #0:1 (aac)
[hls # 0x56019db77780] Opening 'cams/stream1_114.ts' for reading
[hls # 0x56019db77780] Opening 'cams/stream1_115.ts' for reading
[swscaler # 0x5601a2c78e40] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x5601a332c940] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x5601a2c78e40] deprecated pixel format used, make sure you did set range correctly
Last message repeated 2 times
[swscaler # 0x5601a332c940] deprecated pixel format used, make sure you did set range correctly
[swscaler # 0x5601a361fc00] deprecated pixel format used, make sure you did set range correctly
Last message repeated 1 times
[libx264 # 0x56019e5212c0] using SAR=1/1
[libx264 # 0x56019e5212c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 # 0x56019e5212c0] profile Constrained Baseline, level 5.1, 4:2:0, 8-bit
[libx264 # 0x56019e5212c0] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=8 lookahead_threads=8 sliced_threads=1 slices=8 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=60 keyint_min=6 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=2000 vbv_bufsize=20000 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=0
Output #0, flv, to 'rtmp://b.rtmp.youtube.com/live2/XXXX-XXXX-XXXX-XXXX-XXXX?backup=1':
Metadata:
encoder : Lavf59.35.100
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 1k tbn
Metadata:
encoder : Lavc59.56.100 libx264
Side data:
cpb: bitrate max/min/avg: 2000000/0/0 buffer size: 20000000 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, stereo, fltp, 96 kb/s
Metadata:
encoder : Lavc59.56.100 aac
[hls # 0x56019db77780] Skip ('#EXT-X-VERSION:3')00:00:03.22 bitrate=7519.6kbits/s speed=0.359x
[hls # 0x56019db77780] Opening 'cams/stream1_116.ts' for reading
[hls # 0x56019db77780] Skip ('#EXT-X-VERSION:3')00:00:07.23 bitrate=4470.2kbits/s speed=0.383x
[hls # 0x56019db77780] Opening 'cams/stream1_117.ts' for reading
[hls # 0x56019f0ec980] Skip ('#EXT-X-VERSION:3')00:00:09.04 bitrate=3978.1kbits/s speed=0.384x
[hls # 0x56019f0ec980] Opening 'cams/stream4_27.ts' for reading
[hls # 0x56019dccdbc0] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019dccdbc0] Opening 'cams/stream3_15.ts' for reading
[hls # 0x56019db9e980] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019db9e980] Opening 'cams/stream2_106.ts' for reading
[flv # 0x56019e639a00] Failed to update header with correct duration.811.6kbits/s speed=0.385x
[flv # 0x56019e639a00] Failed to update header with correct filesize.
frame= 299 fps= 12 q=34.0 Lsize= 4622kB time=00:00:09.98 bitrate=3792.7kbits/s speed=0.386x
video:4603kB audio:3kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.349536%
[libx264 # 0x56019e5212c0] frame I:5 Avg QP:45.60 size:275880
[libx264 # 0x56019e5212c0] frame P:294 Avg QP:38.77 size: 11340
[libx264 # 0x56019e5212c0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 # 0x56019e5212c0] mb P I16..4: 1.4% 0.0% 0.0% P16..4: 4.7% 0.0% 0.0% 0.0% 0.0% skip:93.9%
[libx264 # 0x56019e5212c0] coded y,uvDC,uvAC intra: 16.2% 8.9% 1.2% inter: 1.8% 0.6% 0.0%
[libx264 # 0x56019e5212c0] i16 v,h,dc,p: 64% 17% 15% 5%
[libx264 # 0x56019e5212c0] i8c dc,h,v,p: 90% 6% 3% 1%
[libx264 # 0x56019e5212c0] kb/s:3783.23
[aac # 0x56019e63a700] Qavg: 65511.207
[hls # 0x56019db77780] Skip ('#EXT-X-VERSION:3')
[hls # 0x56019db77780] Opening 'cams/stream1_118.ts' for reading
NOTES: sources are cams streamed first to hls/m3u8. -t 10 only for testing purposes.
The problem is variable output fps= 12 (sometimes 2, 5, 10, maybe 13) where I expect 30. Machine is 10 times greater (encode uses up to 5% cpu).
Im trying adding -re, -r 30, -r 15 to sources, convert sources via stream_filter (,fps=30), vsync (old versions of ffmpeg), wallclock time, etc. and reading stackoverflow of course. And... nothing.
Where is the problem?
Related
This question already has answers here:
FFmpeg filter_complex concat gives only first input on crop
(1 answer)
Problems building Image slideshow with sliding transition using ffmpeg
(1 answer)
ffmpeg: chain of multiple filter_complex, re-using intermediate output stream
(1 answer)
Closed 3 years ago.
I'm attempting to scale and blur (sections of) a video with ffmpeg complex filters. This has actually been working in production for years.
I'm now running a newer build of ffmpeg on Ubuntu 18.04 and getting an error relating to the filters where the same command works fine on Ubuntu 16.04's ffmpeg against the same video.
Specifically, I'm seeing the following error:
mov,mp4,m4a,3gp,3g2,mj2 # 0x56055a5902c0] Invalid stream specifier: vs0.
Last message repeated 1 times
Stream specifier 'vs0' in filtergraph description ... matches no streams.
Has something about the complex filter API changed that would make this same input invalid in a newer version of ffmpeg?
The command in question is just running the following in a Bash terminal.
ffmpeg -ss 60 -i ~/test.mp4 -y -filter_complex "[0:v]scale=-2:'min(320,ih)'[vs0];[vs0]crop=in_w/9:in_h/2:0:0,boxblur=5:1:cr=3:ar=3[b0];[vs0]crop=in_w/9:in_h/2:in_w-out_w:0,boxblur=5:1:cr=3:ar=3[b1];[vs0]crop=(in_w-2*in_w/9):in_h/20:in_w/9:0,boxblur=5:1:cr=3:ar=3[b2];[vs0][b0]overlay=0:0[ovr0];[ovr0][b1]overlay=main_w-overlay_w:0[ovr1];[ovr1][b2]overlay=main_w/9:0[vs1]" -map [vs1] -an -ac 2 -b:a 128k -acodec aac -b:v 1024k -r 30 -vcodec libx264 -t 300 -y -preset slow -movflags faststart -pix_fmt yuv420p -f mp4 ~/out.mp4
If we break up the complex filter statement, it looks like:
[0:v]scale=-2:'min(320,ih)'[vs0];
[vs0]crop=in_w/9:in_h/2:0:0,boxblur=5:1:cr=3:ar=3[b0];
[vs0]crop=in_w/9:in_h/2:in_w-out_w:0,boxblur=5:1:cr=3:ar=3[b1];
[vs0]crop=(in_w-2*in_w/9):in_h/20:in_w/9:0,boxblur=5:1:cr=3:ar=3[b2];
[vs0][b0]overlay=0:0[ovr0];[ovr0][b1]overlay=main_w-overlay_w:0[ovr1];
[ovr1][b2]overlay=main_w/9:0[vs1]
On ffmpeg version N-86980-g62b7553 (Ubuntu 16.04), everything works great as it has done for years.
$ ffmpeg -ss 60 -i ~/test.mp4 -y -filter_complex "[0:v]scale=-2:'min(320,ih)'[vs0];[vs0]crop=in_w/9:in_h/2:0:0,boxblur=5:1:cr=3:ar=3[b0];[vs0]crop=in_w/9:in_h/2:in_w-out_w:0,boxblur=5:1:cr=3:ar=3[b1];[vs0]crop=(in_w-2*in_w/9):in_h/20:in_w/9:0,boxblur=5:1:cr=3:ar=3[b2];[vs0][b0]overlay=0:0[ovr0];[ovr0][b1]overlay=main_w-overlay_w:0[ovr1];[ovr1][b2]overlay=main_w/9:0[vs1]" -map [vs1] -an -ac 2 -b:a 128k -acodec aac -b:v 1024k -r 30 -vcodec libx264 -t 300 -y -preset slow -movflags faststart -pix_fmt yuv420p -f mp4 ~/out.mp4
ffmpeg version N-86980-g62b7553 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-openssl --enable-nonfree
libavutil 55. 73.100 / 55. 73.100
libavcodec 57.102.100 / 57.102.100
libavformat 57. 76.100 / 57. 76.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 98.100 / 6. 98.100
libswscale 4. 7.102 / 4. 7.102
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/cmaier/test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.76.100
Duration: 00:10:00.00, start: 0.000000, bitrate: 1036 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 768x480, 1033 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 (h264) -> scale
Stream #0:0 (h264) -> crop
Stream #0:0 (h264) -> crop
Stream #0:0 (h264) -> overlay:main
overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 # 0x27b2ca0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x27b2ca0] profile High, level 3.1
[libx264 # 0x27b2ca0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=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=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=abr mbtree=1 bitrate=1024 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/home/cmaier/out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.76.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 768x480, q=-1--1, 1024 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc57.102.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/1024000 buffer size: 0 vbv_delay: -1
[mp4 # 0x27b5a60] Starting second pass: moving the moov atom to the beginning of the file3.9x
frame= 9000 fps=117 q=-1.0 Lsize= 37827kB time=00:04:59.90 bitrate=1033.3kbits/s speed= 3.9x
video:37721kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.282333%
[libx264 # 0x27b2ca0] frame I:36 Avg QP:15.21 size: 50944
[libx264 # 0x27b2ca0] frame P:2723 Avg QP:20.12 size: 9593
[libx264 # 0x27b2ca0] frame B:6241 Avg QP:24.23 size: 1710
[libx264 # 0x27b2ca0] consecutive B-frames: 3.6% 6.9% 14.5% 75.0%
[libx264 # 0x27b2ca0] mb I I16..4: 17.3% 58.5% 24.2%
[libx264 # 0x27b2ca0] mb P I16..4: 0.5% 4.4% 0.9% P16..4: 31.1% 20.7% 12.1% 0.0% 0.0% skip:30.3%
[libx264 # 0x27b2ca0] mb B I16..4: 0.0% 0.3% 0.1% B16..8: 28.9% 5.5% 1.1% direct: 1.1% skip:63.1% L0:37.5% L1:52.6% BI: 9.9%
[libx264 # 0x27b2ca0] final ratefactor: 19.69
[libx264 # 0x27b2ca0] 8x8 transform intra:72.8% inter:68.3%
[libx264 # 0x27b2ca0] direct mvs spatial:99.9% temporal:0.1%
[libx264 # 0x27b2ca0] coded y,uvDC,uvAC intra: 74.5% 73.0% 30.4% inter: 13.0% 10.7% 0.2%
[libx264 # 0x27b2ca0] i16 v,h,dc,p: 49% 30% 3% 17%
[libx264 # 0x27b2ca0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 7% 14% 11% 7% 11% 8% 19% 8% 15%
[libx264 # 0x27b2ca0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 13% 5% 8% 14% 10% 17% 9% 16%
[libx264 # 0x27b2ca0] i8c dc,h,v,p: 42% 29% 15% 15%
[libx264 # 0x27b2ca0] Weighted P-Frames: Y:7.4% UV:2.9%
[libx264 # 0x27b2ca0] ref P L0: 59.2% 20.2% 11.5% 3.7% 4.3% 1.0% 0.1%
[libx264 # 0x27b2ca0] ref B L0: 87.5% 8.8% 2.7% 1.0%
[libx264 # 0x27b2ca0] ref B L1: 96.5% 3.5%
[libx264 # 0x27b2ca0] kb/s:1030.01
On ffmpeg version N-93862-gf49cec2 (Ubuntu 18.04), the command fails immediately.
# ffmpeg -ss 60 -i ~/test.mp4 -y -filter_complex "[0:v]scale=-2:'min(320,ih)'[vs0];[vs0]crop=in_w/9:in_h/2:0:0,boxblur=5:1:cr=3:ar=3[b0];[vs0]crop=in_w/9:in_h/2:in_w-out_w:0,boxblur=5:1:cr=3:ar=3[b1];[vs0]crop=(in_w-2*in_w/9):in_h/20:in_w/9:0,boxblur=5:1:cr=3:ar=3[b2];[vs0][b0]overlay=0:0[ovr0];[ovr0][b1]overlay=main_w-overlay_w:0[ovr1];[ovr1][b2]overlay=main_w/9:0[vs1]" -map [vs1] -an -ac 2 -b:a 128k -acodec aac -b:v 1024k -r 30 -vcodec libx264 -t 300 -y -preset slow -movflags faststart -pix_fmt yuv420p -f mp4 ~/out.mp4
ffmpeg version N-93862-gf49cec2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04)
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-openssl --enable-nonfree
libavutil 56. 27.100 / 56. 27.100
libavcodec 58. 52.101 / 58. 52.101
libavformat 58. 27.103 / 58. 27.103
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 53.100 / 7. 53.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/root/test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.76.100
Duration: 00:10:00.00, start: 0.000000, bitrate: 1036 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 768x480, 1033 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
[mov,mp4,m4a,3gp,3g2,mj2 # 0x56055a5902c0] Invalid stream specifier: vs0.
Last message repeated 1 times
Stream specifier 'vs0' in filtergraph description [0:v]scale=-2:'min(320,ih)'[vs0];[vs0]crop=in_w/9:in_h/2:0:0,boxblur=5:1:cr=3:ar=3[b0];[vs0]crop=in_w/9:in_h/2:in_w-out_w:0,boxblur=5:1:cr=3:ar=3[b1];[vs0]crop=(in_w-2*in_w/9):in_h/20:in_w/9:0,boxblur=5:1:cr=3:ar=3[b2];[vs0][b0]overlay=0:0[ovr0];[ovr0][b1]overlay=main_w-overlay_w:0[ovr1];[ovr1][b2]overlay=main_w/9:0[vs1] matches no streams.
I developed a video conferencing app that records the video streams separately, and I am now looking for a way to merge them. At the moment I am experimenting with -itsoffset and hstack to stack 2 videos side by side using this command:
ffmpeg \
-itsoffset 17 -i smaller.mp4 \
-itsoffset 0 -i bigger.mp4 \
-filter_complex hstack=inputs=2 \
-c:v libx264 -crf 23 out.mp4
The result is a side by side video where both streams remain frozen for 17 seconds then start playing, even the bigger.mp4 video that should start at time 0.
Any help would be really appreciated!
ffmpeg verbose:
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10+deb8u1)
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libx264 --enable-libspeex --enab le-shared --enable-pthreads --enable-libopenjpeg --enable-nonfree --enable-libopus --enable-libvorbis --enable-libvpx
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 'smaller.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:05.16, start: 0.000000, bitrate: 444 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 330 kb/s, 32 fps, 32 tbr, 16384 tbn, 64 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 103 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'bigger.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.36.100
Duration: 00:00:22.03, start: 0.000000, bitrate: 290 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 177 kb/s, 32 fps, 32 tbr, 16384 tbn, 64 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 103 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'out.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 (h264) -> hstack:input0 (graph 0)
Stream #1:0 (h264) -> hstack:input1 (graph 0)
hstack (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x206ed00] using SAR=1/1
[libx264 # 0x206ed00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x206ed00] profile High, level 3.1
[libx264 # 0x206ed00] 264 - core 146 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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_thre ads=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 scene cut=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:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 960x360 [SAR 1:1 DAR 8:3], q=-1--1, 32 fps, 16384 tbn, 32 tbc (default)
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(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.35.100 aac
frame= 709 fps=130 q=-1.0 Lsize= 573kB time=00:00:22.12 bitrate= 212.2kbits/s dup=544 drop=0 speed=4.05x
video:478kB audio:81kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.445685%
[libx264 # 0x206ed00] frame I:3 Avg QP:16.86 size: 38355
[libx264 # 0x206ed00] frame P:190 Avg QP:18.22 size: 1633
[libx264 # 0x206ed00] frame B:516 Avg QP:16.23 size: 123
[libx264 # 0x206ed00] consecutive B-frames: 1.3% 2.8% 6.8% 89.1%
[libx264 # 0x206ed00] mb I I16..4: 6.6% 54.8% 38.6%
[libx264 # 0x206ed00] mb P I16..4: 0.4% 1.5% 0.2% P16..4: 8.7% 4.0% 1.9% 0.0% 0.0% skip:83.3%
[libx264 # 0x206ed00] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 4.2% 0.3% 0.0% direct: 0.0% skip:95.4% L0:37.2% L1:58.9% BI: 4.0%
[libx264 # 0x206ed00] 8x8 transform intra:66.2% inter:63.4%
[libx264 # 0x206ed00] coded y,uvDC,uvAC intra: 66.1% 65.6% 21.6% inter: 1.7% 1.1% 0.0%
[libx264 # 0x206ed00] i16 v,h,dc,p: 21% 26% 11% 42%
[libx264 # 0x206ed00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 23% 13% 5% 7% 8% 7% 7% 6%
[libx264 # 0x206ed00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 24% 9% 6% 7% 7% 6% 7% 7%
[libx264 # 0x206ed00] i8c dc,h,v,p: 46% 25% 20% 9%
[libx264 # 0x206ed00] Weighted P-Frames: Y:1.1% UV:0.0%
[libx264 # 0x206ed00] ref P L0: 66.0% 19.4% 12.0% 2.6% 0.0%
[libx264 # 0x206ed00] ref B L0: 87.2% 11.8% 1.0%
[libx264 # 0x206ed00] ref B L1: 95.2% 4.8%
[libx264 # 0x206ed00] kb/s:176.52
[aac # 0x204aa00] Qavg: 247.398
hstack doesn't sync by timestamps. You'll need to pad the delayed video.
ffmpeg \
-i smaller.mp4 \
-i bigger.mp4 \
-filter_complex \
"[0]tpad=start_duration=17[left];\
[left][1]hstack=inputs=2;\
[0]adelay=17s|17s[lefta];[lefta][1]amix=2" \
-c:v libx264 -crf 23 out.mp4
I have been experiencing difficulty in finding many answers with FFMPEG documentation, forums and here.
What I am trying to do is a compress a screen capture video but with just RGB data.
The steps I am currently taking are;
ffmpeg -f avfoundation -pix_fmt 0rgb -r "30" -i "1" -vcodec libx264rgb -pix_fmt rgb24 -crf 0 -t 25 -q 0 -y ~/Desktop/RGB.mkv
south-58-45:~ danielcarter$ ffmpeg -f avfoundation -pix_fmt 0rgb -r "30" -i "1" -vcodec libx264rgb -pix_fmt rgb24 -crf 0 -t 170 -q 0 -y -v info ~/Desktop/output.mkv
ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.41)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3 --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. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
[avfoundation # 0x7fc39d004c00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, avfoundation, from '1':
Duration: N/A, start: 175270.249500, bitrate: N/A
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1440x900, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264rgb))
Press [q] to stop, [?] for help
[libx264rgb # 0x7fc39d13ea00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264rgb # 0x7fc39d13ea00] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264rgb # 0x7fc39d13ea00] 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=0x1:0x111 me=hex subme=7 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 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=cqp mbtree=0 qp=0
Output #0, matroska, to '/Users/danielcarter/Desktop/output.mkv':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264rgb) (H264 / 0x34363248), rgb24, 1440x900, q=-1--1, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libx264rgb
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 5100 fps= 30 q=-1.0 Lsize= 12167kB time=00:02:49.96 bitrate= 586.4kbits/s speed=0.999x
video:12134kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.267659%
[libx264rgb # 0x7fc39d13ea00] frame I:21 Avg QP: 0.00 size:430796
[libx264rgb # 0x7fc39d13ea00] frame P:5079 Avg QP: 0.00 size: 665
[libx264rgb # 0x7fc39d13ea00] mb I I16..4: 61.3% 0.0% 38.7%
[libx264rgb # 0x7fc39d13ea00] mb P I16..4: 0.1% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:99.9%
[libx264rgb # 0x7fc39d13ea00] 8x8 transform intra:0.0% inter:11.2%
[libx264rgb # 0x7fc39d13ea00] coded y,u,v intra: 48.0% 31.6% 29.0% inter: 0.0% 0.0% 0.0%
[libx264rgb # 0x7fc39d13ea00] i16 v,h,dc,p: 76% 22% 2% 0%
[libx264rgb # 0x7fc39d13ea00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 46% 35% 7% 2% 2% 1% 1% 1% 3%
[libx264rgb # 0x7fc39d13ea00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264rgb # 0x7fc39d13ea00] ref P L0: 83.1% 6.4% 5.3% 5.2%
[libx264rgb # 0x7fc39d13ea00] kb/s:584.71
This captures the screen on my mac. To the best of my knowledge, this creates a lossless file and I have compared screen shots that confirm this.
The next step is where I think I have an issue.
Because I want to run the compression on raw RGB data I need to convert the MKV to an RGB file;
ffmpeg -i ~/Desktop/RGB.mkv -c:v rawvideo -pix_fmt rgb24 -crf 0 -ss 00:00:03 -to 00:02:01 -q 0 -y ~/Desktop/out.rgb
south-58-45:~ danielcarter$ ffmpeg -i ~/Desktop/output.mkv -c:v rawvideo -pix_fmt rgb24 -crf 0 -ss 00:00:03 -to 00:02:01 -q 0 -y ~/Desktop/out.rgb
ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.41)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3 --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. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, matroska,webm, from '/Users/danielcarter/Desktop/output.mkv':
Metadata:
ENCODER : Lavf57.71.100
Duration: 00:02:50.00, start: 0.000000, bitrate: 586 kb/s
Stream #0:0: Video: h264 (High 4:4:4 Predictive), gbrp(tv, gbr/unknown/unknown, progressive), 1440x900, 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
Metadata:
ENCODER : Lavc57.89.100 libx264rgb
DURATION : 00:02:50.000000000
Codec AVOption crf (Select the quality for constant quality mode) specified for output file #0 (/Users/danielcarter/Desktop/out.rgb) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to '/Users/danielcarter/Desktop/out.rgb':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1440x900, q=2-31, 933120 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
DURATION : 00:02:50.000000000
encoder : Lavc57.89.100 rawvideo
frame= 3540 fps=111 q=-0.0 Lsize=13440938kB time=00:01:58.00 bitrate=933120.0kbits/s speed=3.68x
video:13440938kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Once I have this I can then compress and decompress successfully. I then get a working file to play back using;
ffmpeg -f rawvideo -vcodec rawvideo -s 1440x900 -r 30 -pix_fmt rgb24 -i ~/Desktop/out.rgb -c:v libx264rgb -pix_fmt rgb24 -x264opts keyint=300:min-keyint=300:no-scenecut -y -crf 0 ~/Desktop/rgbplay.mkv
south-58-45:~ danielcarter$ ffmpeg -f rawvideo -vcodec rawvideo -s 1440x900 -r 30 -pix_fmt rgb24 -i ~/Desktop/out.rgb -c:v libx264rgb -pix_fmt rgb24 -x264opts keyint=300:min-keyint=300:no-scenecut -y -crf 0 ~/Desktop/rgbplay.mkv
ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.41)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3 --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. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
[rawvideo # 0x7fb1f9002600] Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from '/Users/danielcarter/Desktop/out.rgb':
Duration: 00:01:58.00, start: 0.000000, bitrate: 933120 kb/s
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1440x900, 933120 kb/s, 30 tbr, 30 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264rgb))
Press [q] to stop, [?] for help
[libx264rgb # 0x7fb1f9010c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264rgb # 0x7fb1f9010c00] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264rgb # 0x7fb1f9010c00] 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=0x1:0x111 me=hex subme=7 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=300 keyint_min=151 scenecut=0 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, matroska, to '/Users/danielcarter/Desktop/rgbplay.mkv':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264rgb) (H264 / 0x34363248), rgb24, 1440x900, q=-1--1, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libx264rgb
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 3540 fps= 64 q=-1.0 Lsize= 8319kB time=00:01:57.96 bitrate= 577.7kbits/s speed=2.13x
video:8297kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.273154%
[libx264rgb # 0x7fb1f9010c00] frame I:12 Avg QP: 0.00 size:437670
[libx264rgb # 0x7fb1f9010c00] frame P:3528 Avg QP: 0.00 size: 919
[libx264rgb # 0x7fb1f9010c00] mb I I16..4: 61.9% 0.0% 38.1%
[libx264rgb # 0x7fb1f9010c00] mb P I16..4: 0.1% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:99.8%
[libx264rgb # 0x7fb1f9010c00] 8x8 transform intra:0.0% inter:15.1%
[libx264rgb # 0x7fb1f9010c00] coded y,u,v intra: 49.7% 36.5% 33.7% inter: 0.0% 0.0% 0.0%
[libx264rgb # 0x7fb1f9010c00] i16 v,h,dc,p: 73% 25% 1% 0%
[libx264rgb # 0x7fb1f9010c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 45% 36% 7% 2% 2% 2% 2% 1% 3%
[libx264rgb # 0x7fb1f9010c00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264rgb # 0x7fb1f9010c00] ref P L0: 81.3% 7.7% 6.7% 4.3%
[libx264rgb # 0x7fb1f9010c00] kb/s:575.96
But here I have pixel variance. My guess is there is a RGB-YUV-RGB conversion happening somewhere but I am not smart enough to work out where.
If any of you can help I would forever grateful.
Here is a picture of the two stills side by side that shows the differences;
pixel difference
If you need anything more I can post it also.
Cheers,
DC
I managed to get this to work by removing a step.
The conversion from mkv->rgb was producing the problem, it was using gbrp as the pixel format and this created slight differences in colour across the whole screen. Thank you to Mulvya for pointing out the range markers too, without that I would not have known where to look.
To get this to work I use the following code to screen capture direct to RGB;
ffmpeg -f avfoundation -pix_fmt 0rgb -color_range 2 -r "30" -i "1" -vcodec rawvideo -pix_fmt rgb24 -color_range 2 -t 210 -q 0 -y -v info ~/Desktop/output.rgb
Then can convert that to an MKV file for playback using;
ffmpeg -report -f rawvideo -vcodec rawvideo -s 1440x900 -r 30 -pix_fmt rgb24 -color_range 2 -i ~/Desktop/output.rgb -c:v libx264rgb -pix_fmt rgb24 -ss 00:00:04 -to 00:02:02 -color_range 2 -x264opts crf=0 -y ~/Desktop/rgbplay.mkv
Thank you for everything, I can sleep again haha
I want to concat two video files using the concat filter. The first file has to be included fully, whereas the second video must be included from the 10th second. Do I need to first create an intermediate file starting from the 10th second, or can I do it in one step?
The command I am using is
/usr/local/bin/ffmpeg -i intro.mp4 -i input.mp4 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
I tried specifying -ss after -i input.mp4, but it is applied on the final output file.
iMac:files joyce$ /usr/local/bin/ffmpeg -i intro.mp4 -i input.mp4 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 22 2014 16:19:43 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libfdk-aac
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Duration: 00:00:03.05, start: 0.046440, bitrate: 1304 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 1167 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 132 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
episode_sort : 1
season_number : 1
media_type : 9
hd_video : 0
Duration: 00:00:45.43, start: 0.042667, bitrate: 906 kb/s
Stream #1:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x576 [SAR 1:1 DAR 5:4], 774 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'output.mp4' already exists. Overwrite ? [y/N] y
[libx264 # 0x7fa9a8828e00] using SAR=1/1
[libx264 # 0x7fa9a8828e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 # 0x7fa9a8828e00] profile High, level 3.1
[libx264 # 0x7fa9a8828e00] 264 - core 125 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=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.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 1:1 DAR 5:4], q=-1--1, 30k tbn, 29.97 tbc (default)
Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
Stream mapping:
Stream #0:0 (h264) -> scale
Stream #0:1 (aac) -> concat:in0:a0
Stream #1:0 (h264) -> scale
Stream #1:1 (aac) -> concat:in1:a0
concat -> Stream #0:0 (libx264)
concat -> Stream #0:1 (libfaac)
Press [q] to stop, [?] for help
frame= 1453 fps= 42 q=-1.0 Lsize= 4536kB time=00:00:48.50 bitrate= 766.1kbits/s dup=227 drop=0
video:3796kB audio:691kB subtitle:0 global headers:0kB muxing overhead 1.102067%
[libx264 # 0x7fa9a8828e00] frame I:31 Avg QP:17.02 size: 14953
[libx264 # 0x7fa9a8828e00] frame P:764 Avg QP:24.14 size: 3677
[libx264 # 0x7fa9a8828e00] frame B:658 Avg QP:28.17 size: 933
[libx264 # 0x7fa9a8828e00] consecutive B-frames: 36.4% 6.2% 10.3% 47.1%
[libx264 # 0x7fa9a8828e00] mb I I16..4: 40.4% 32.3% 27.3%
[libx264 # 0x7fa9a8828e00] mb P I16..4: 6.6% 4.0% 1.1% P16..4: 25.2% 5.7% 2.3% 0.0% 0.0% skip:55.0%
[libx264 # 0x7fa9a8828e00] mb B I16..4: 0.8% 0.4% 0.2% B16..8: 24.5% 1.7% 0.2% direct: 0.5% skip:71.6% L0:50.7% L1:45.5% BI: 3.9%
[libx264 # 0x7fa9a8828e00] 8x8 transform intra:33.3% inter:59.0%
[libx264 # 0x7fa9a8828e00] coded y,uvDC,uvAC intra: 26.4% 41.2% 8.0% inter: 5.6% 7.9% 0.2%
[libx264 # 0x7fa9a8828e00] i16 v,h,dc,p: 46% 29% 8% 17%
[libx264 # 0x7fa9a8828e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 19% 28% 3% 3% 4% 3% 4% 3%
[libx264 # 0x7fa9a8828e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 22% 13% 4% 6% 7% 5% 5% 3%
[libx264 # 0x7fa9a8828e00] i8c dc,h,v,p: 57% 19% 20% 4%
[libx264 # 0x7fa9a8828e00] Weighted P-Frames: Y:1.8% UV:1.2%
[libx264 # 0x7fa9a8828e00] ref P L0: 73.2% 9.1% 11.7% 5.3% 0.7%
[libx264 # 0x7fa9a8828e00] ref B L0: 89.3% 8.9% 1.8%
[libx264 # 0x7fa9a8828e00] ref B L1: 95.3% 4.7%
[libx264 # 0x7fa9a8828e00] kb/s:641.26
I had placed the -ss argument after the -i option, which was why it was not applied correctly.
/usr/local/bin/ffmpeg -i intro.mp4 -i input.mp4 -ss 1.5 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
I tried placing it before -i option, and now it is working as expected.
/usr/local/bin/ffmpeg -i intro.mp4 -ss 1.5 -i input.mp4 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
According to documentation %{}:, should be escaped with slash. But when I escape % the text is not added. There's error message saying Stray % near ')'. But what does it mean and how I can fix it? Command and output:
$ /usr/bin/ffmpeg -y -i /home/www/255871.mov -af 'aresample=async=1:min_hard_comp=0.100000' -vf 'scale=480:trunc(ow/a/2)*2,transpose=1 [in];movie=watermarks/text-box440.mov,scale=320:55 [bg];[in][bg] overlay=x=20:y=main_h-80,drawtext=fontsize=20:fix_bounds=1:fontfile=Helvetica\\:Style=bold:fontcolor=0xe6b300:text=small kitten \%\):x=30:y=h-80+ascent/2:draw=gte(t\,0)\;lt(t\,5) [out]' -pix_fmt yuv420p -r 24.39 -map_metadata -1 -movflags +faststart -f mp4 -vcodec libx264 -b:v 800k -maxrate 1100k -bufsize 2M -bt 256k -profile:vbaseline -acodec libfdk_aac -ab 64k -ar 44100 -ac 1 /tmp/kitten.mp4
ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 15 2013 18:40:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --enable-gpl --enable-libmp3lame --enable-libvo-aacenc --enable-libx264 --enable-version3 --enable-pthreads --enable-libfaac --enable-nonfree --enable-libfdk_a
ac --enable-fontconfig --enable-libfreetype
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 '/home/www/255871.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2012-07-17 07:42:35
model : iPhone 3GS
model-rus : iPhone 3GS
encoder : 4.2.1
encoder-rus : 4.2.1
date : 2012-07-17T10:42:35+0300
date-rus : 2012-07-17T10:42:35+0300
make : Apple
make-rus : Apple
Duration: 00:00:09.38, start: 0.000000, bitrate: 790 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 480x360, 720 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc
Metadata:
rotate : 90
creation_time : 2012-07-17 07:42:35
handler_name : Core Media Data Handler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s
Metadata:
creation_time : 2012-07-17 07:42:35
handler_name : Core Media Data Handler
[Parsed_drawtext_5 # 0x2ae9b00] Using "/usr/share/fonts/default/Type1/n019003l.pfb"
[libx264 # 0x2ae7d40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0x2ae7d40] profile Constrained Baseline, level 2.1
[libx264 # 0x2ae7d40] 264 - core 130 r2274 c832fe9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 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=0 weightp=0 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=800 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1100 vbv_bufsize=2000 nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/tmp/kitten.mp4':
Metadata:
encoder : Lavf54.63.104
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 360x480, q=-1--1, 800 kb/s, 19512 tbn, 24.39 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> libfdk_aac)
Press [q] to stop, [?] for help
[Parsed_drawtext_5 # 0x2ae9b00] Stray % near ')'
Last message repeated 201 times
Stray % near ')'0.0 q=27.0 size= 480kB time=00:00:07.96 bitrate= 493.4kbits/s dup=0 drop=35
[Parsed_drawtext_5 # 0x2ae9b00] Stray % near ')'
Last message repeated 77 times
Starting second pass: moving header on top of the file
frame= 231 fps=0.0 q=-1.0 Lsize= 1002kB time=00:00:09.47 bitrate= 866.6kbits/s dup=0 drop=50
video:921kB audio:74kB subtitle:0 global headers:0kB muxing overhead 0.680957%
[libx264 # 0x2ae7d40] frame I:1 Avg QP:24.43 size: 13264
[libx264 # 0x2ae7d40] frame P:230 Avg QP:23.72 size: 4041
[libx264 # 0x2ae7d40] mb I I16..4: 24.8% 0.0% 75.2%
[libx264 # 0x2ae7d40] mb P I16..4: 2.3% 0.0% 4.8% P16..4: 34.4% 28.8% 9.4% 0.0% 0.0% skip:20.3%
[libx264 # 0x2ae7d40] coded y,uvDC,uvAC intra: 62.5% 54.2% 4.4% inter: 19.6% 20.3% 0.1%
[libx264 # 0x2ae7d40] i16 v,h,dc,p: 36% 29% 19% 16%
[libx264 # 0x2ae7d40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 21% 20% 6% 8% 7% 7% 6% 6%
[libx264 # 0x2ae7d40] i8c dc,h,v,p: 65% 15% 17% 3%
[libx264 # 0x2ae7d40] ref P L0: 93.4% 4.3% 2.3%
[libx264 # 0x2ae7d40] kb/s:796.32
Found the solution. The reason of this error is that ffmpeg tries to expand text with % to function as stated in documentation:
Sequence of the form %{...} are expanded. The text between the braces
is a function name, possibly followed by arguments separated by ’:’.
If the arguments contain special characters or delimiters (’:’ or
’}’), they should be escaped.
So simply adding expansion=none to filter configuration solves the issue.