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
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 have several videos (FullHD resolution) which I want to convert to mkv format and play on my Samsung BluRay Player (model BD-J5900).
Based on User Manual (http://media.datatail.com/docs/manual/252846_en.pdf , page 6) it supports mkv playing if codecs are:
Video : H.264 BP/MP/HP
Audio : MP3
Thus, based on https://ffmpeg.org/ffmpeg.html the command to convert it into proper format is:
ffmpeg -i input.avi -f matroska -vcodec libx264 -acodec mp3 output.mkv
It converts, but file is not playable on player. It say "Video format is not supported".
After checking info here: https://trac.ffmpeg.org/wiki/Encode/H.264 - I thought it may require some compatibility and change the command to :
ffmpeg -i input.avi -f matroska -vcodec libx264 -profile:v baseline -level 3.0 -acodec mp3 output.mkv
But it also didn't help - player demonstrates the same error.
How to fix that?
Thanks!
Updated:
Also tested following options
ffmpeg -i input.file -f matroska -vcodec libx264 -preset veryslow -x264-params bluray_compat=1 -acodec mp3 output.mkv
ffmpeg -i input.file -f matroska -vcodec libx264 -preset veryslow -profile:v high -level 4.2 -x264-params bluray_compat=1 -acodec mp3 output.mkv
ffmpeg -i input.file -f matroska -vcodec libx264 -preset veryslow -profile:v baseline -level 3.0 -x264-params bluray_compat=1 -acodec mp3 output.mkv
ffmpeg -i input.file -vcodec libx264 -vf format=yuv420p -preset veryslow -acodec mp3 output.mkv
Also not supported.
Updated:
Console output for command without profile flag:
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.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-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
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000019abc2aa4c0] sample aspect ratio already set to 1:1, ignoring 'pasp' atom (65536:65536)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Yehor\Desktop\video_conversion\input\VID_20180620_165336103.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2018-06-20T22:55:12.000000Z
com.android.version: 7.0
Duration: 00:01:34.19, start: 0.000000, bitrate: 17178 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 17016 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : SoundHandle
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 # 0000019abc348e00] using SAR=1/1time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
[libx264 # 0000019abc348e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000019abc348e00] profile High, level 4.0
[libx264 # 0000019abc348e00] 264 - core 155 r2901 7d0ff22 - 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=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, matroska, to 'C:\Users\Yehor\Desktop\video_conversion\output\VID_20180620_165336103.mkv':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 7.0
encoder : Lavf58.12.100
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuvj420p(pc), 1080x1920 [SAR 1:1 DAR 9:16], q=-1--1, 30 fps, 1k tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.18.100 libx264
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : VideoHandle
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
displaymatrix: rotation of -0.00 degrees
Stream #0:1(eng): Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp (default)
Metadata:
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : SoundHandle
encoder : Lavc58.18.100 libmp3lame
frame= 2823 fps= 15 q=-1.0 Lsize= 80210kB time=00:01:34.10 bitrate=6982.7kbits/s speed=0.492x
video:78692kB audio:1469kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.061441%
[libx264 # 0000019abc348e00] frame I:14 Avg QP:21.43 size:187644
[libx264 # 0000019abc348e00] frame P:728 Avg QP:23.93 size: 68336
[libx264 # 0000019abc348e00] frame B:2081 Avg QP:27.79 size: 13553
[libx264 # 0000019abc348e00] consecutive B-frames: 1.3% 0.6% 2.0% 96.1%
[libx264 # 0000019abc348e00] mb I I16..4: 5.7% 71.5% 22.7%
[libx264 # 0000019abc348e00] mb P I16..4: 2.0% 8.8% 0.9% P16..4: 46.2% 20.0% 12.2% 0.0% 0.0% skip:10.1%
[libx264 # 0000019abc348e00] mb B I16..4: 0.2% 0.9% 0.1% B16..8: 45.3% 4.9% 1.0% direct: 2.8% skip:44.9% L0:45.7% L1:47.3% BI: 7.0%
[libx264 # 0000019abc348e00] 8x8 transform intra:75.1% inter:69.7%
[libx264 # 0000019abc348e00] coded y,uvDC,uvAC intra: 56.8% 70.0% 15.9% inter: 18.3% 19.2% 2.4%
[libx264 # 0000019abc348e00] i16 v,h,dc,p: 18% 33% 15% 34%
[libx264 # 0000019abc348e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 20% 24% 5% 8% 8% 8% 5% 5%
[libx264 # 0000019abc348e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 19% 13% 6% 9% 9% 9% 7% 5%
[libx264 # 0000019abc348e00] i8c dc,h,v,p: 53% 23% 17% 7%
[libx264 # 0000019abc348e00] Weighted P-Frames: Y:15.7% UV:2.6%
[libx264 # 0000019abc348e00] ref P L0: 49.7% 11.2% 25.9% 11.3% 1.9%
[libx264 # 0000019abc348e00] ref B L0: 88.2% 9.2% 2.6%
[libx264 # 0000019abc348e00] ref B L1: 96.2% 3.8%
[libx264 # 0000019abc348e00] kb/s:6843.33
Console output for command with profile flag:
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.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-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
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000018124b5b080] sample aspect ratio already set to 1:1, ignoring 'pasp' atom (65536:65536)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Yehor\Desktop\video_conversion\input\VID_20180620_165336103.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2018-06-20T22:55:12.000000Z
com.android.version: 7.0
Duration: 00:01:34.19, start: 0.000000, bitrate: 17178 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 17016 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : SoundHandle
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 # 0000018124bf9100] using SAR=1/1time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
[libx264 # 0000018124bf9100] frame MB size (68x120) > level limit (1620)
[libx264 # 0000018124bf9100] DPB size (1 frames, 8160 mbs) > level limit (0 frames, 8100 mbs)
[libx264 # 0000018124bf9100] MB rate (244800) > level limit (40500)
[libx264 # 0000018124bf9100] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0000018124bf9100] profile Constrained Baseline, level 3.0
[libx264 # 0000018124bf9100] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=10 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=24 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 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, matroska, to 'C:\Users\Yehor\Desktop\video_conversion\output\VID_20180620_165336103.mkv':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 7.0
encoder : Lavf58.12.100
Stream #0:0(eng): Video: h264 (libx264) (H264 / 0x34363248), yuvj420p(pc), 1080x1920 [SAR 1:1 DAR 9:16], q=-1--1, 30 fps, 1k tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.18.100 libx264
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : VideoHandle
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
displaymatrix: rotation of -0.00 degrees
Stream #0:1(eng): Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp (default)
Metadata:
creation_time : 2018-06-20T22:55:12.000000Z
handler_name : SoundHandle
encoder : Lavc58.18.100 libmp3lame
frame= 2823 fps= 11 q=-1.0 Lsize= 106243kB time=00:01:34.16 bitrate=9242.5kbits/s speed=0.358x
video:104723kB audio:1469kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.047877%
[libx264 # 0000018124bf9100] frame I:14 Avg QP:24.31 size:181656
[libx264 # 0000018124bf9100] frame P:2809 Avg QP:27.29 size: 37271
[libx264 # 0000018124bf9100] mb I I16..4: 24.0% 0.0% 76.0%
[libx264 # 0000018124bf9100] mb P I16..4: 2.7% 0.0% 2.0% P16..4: 45.5% 15.6% 4.7% 0.4% 0.1% skip:28.9%
[libx264 # 0000018124bf9100] coded y,uvDC,uvAC intra: 40.3% 61.3% 13.8% inter: 21.0% 20.2% 3.7%
[libx264 # 0000018124bf9100] i16 v,h,dc,p: 22% 30% 23% 26%
[libx264 # 0000018124bf9100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 15% 12% 9% 12% 12% 12% 9% 7%
[libx264 # 0000018124bf9100] i8c dc,h,v,p: 52% 22% 18% 8%
[libx264 # 0000018124bf9100] kb/s:9107.11
Problem solved with this code:
ffmpeg -f matroska -i input_file.*** -c:v libx264 -preset veryslow -crf 23 -profile:v high -level:v 4.1 -pix_fmt yuv420p -flags global_header -c:a aac output_file.mkv
Tested with ffmpeg 4.0.2 on Windows 10 [x64]
Probably, there is a room to play with CRF to decrease the size of final file.
Here is my png.txt file:
file '01.png'
duration 92
file '02.png'
duration 46
file '03.png'
duration 67
file '04.png'
duration 62
file '05.png'
duration 57
file '06.png'
duration 3
file '06.png'
mp3 duration = 00:05:28 (total of above)
And here is the line:
ffmpeg -f concat -i png.txt -vsync vfr -i 20170817.mp3 -c:a aac -s 1280x720 -c:v libx264 -pix_fmt yuv420p -shortest 20170817.mp4
And here is the output:
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.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. 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, concat, from 'png.txt':
Duration: 00:05:27.00, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: png, rgba(pc), 1280x720 [SAR 2835:2835 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #1, mp3, from '20170817.mp3':
Metadata:
encoder : Lavf57.71.100
Duration: 00:05:28.10, start: 0.069063, bitrate: 24 kb/s
Stream #1:0: Audio: mp3, 16000 Hz, mono, s16p, 24 kb/s
File '20170817.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (mp3 (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x7fbe83003000] using SAR=1/1
[libx264 # 0x7fbe83003000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x7fbe83003000] profile High, level 3.1
[libx264 # 0x7fbe83003000] 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=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 '20170817.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 16000 Hz, mono, fltp, 69 kb/s
Metadata:
encoder : Lavc57.89.100 aac
frame= 7 fps=4.2 q=-1.0 Lsize= 3349kB time=00:05:27.04 bitrate= 83.9kbits/s speed= 196x
video:465kB audio:2863kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.644585%
[libx264 # 0x7fbe83003000] frame I:1 Avg QP: 7.93 size:159157
[libx264 # 0x7fbe83003000] frame P:2 Avg QP:17.16 size: 61998
[libx264 # 0x7fbe83003000] frame B:4 Avg QP:18.34 size: 48049
[libx264 # 0x7fbe83003000] consecutive B-frames: 14.3% 28.6% 0.0% 57.1%
[libx264 # 0x7fbe83003000] mb I I16..4: 48.6% 21.6% 29.8%
[libx264 # 0x7fbe83003000] mb P I16..4: 4.4% 9.8% 19.7% P16..4: 11.6% 3.0% 2.6% 0.0% 0.0% skip:48.9%
[libx264 # 0x7fbe83003000] mb B I16..4: 0.4% 0.5% 13.2% B16..8: 14.9% 3.9% 2.6% direct: 1.1% skip:63.4% L0:45.0% L1:52.1% BI: 3.0%
[libx264 # 0x7fbe83003000] 8x8 transform intra:19.2% inter:38.3%
[libx264 # 0x7fbe83003000] coded y,uvDC,uvAC intra: 52.3% 63.3% 62.4% inter: 8.6% 7.7% 6.9%
[libx264 # 0x7fbe83003000] i16 v,h,dc,p: 88% 9% 3% 0%
[libx264 # 0x7fbe83003000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 12% 45% 2% 2% 3% 2% 3% 4%
[libx264 # 0x7fbe83003000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 26% 18% 5% 5% 5% 5% 6% 6%
[libx264 # 0x7fbe83003000] i8c dc,h,v,p: 55% 18% 20% 8%
[libx264 # 0x7fbe83003000] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 # 0x7fbe83003000] ref P L0: 93.3% 0.3% 3.7% 2.8%
[libx264 # 0x7fbe83003000] ref B L0: 85.2% 14.8%
[libx264 # 0x7fbe83003000] ref B L1: 87.8% 12.2%
[libx264 # 0x7fbe83003000] kb/s:11.52
[aac # 0x7fbe83004800] Qavg: 1971.172
The problem is that the mp4 has 00:06:45 duration, and the music finished at 00:05:28
How do I chop the last silent bit off?
I tried the following:
ffmpeg -ss 0 -i 20170817.mp4 -to 00:05:28 -c copy cut.mp4
Which is worse. Adds blank silent video at front, and chop the video at middle which yet to finish.
Please note the first 5 images are correct at right music positions, only last image duration error
After running into the same extra silence at the end, it seems that explicitly limiting the video length using an output option (-to or -t) does the job. (You can use ss, -to, and -t as input or output options).
I had a similar setup to your question, albeit I took a 10-second slice of an audio file and used the concat filter to overlay it with 4 images.
# files.ffconcat
file 'image1.png'
duration 1
file 'image2.png'
duration 4
file 'image3.png'
duration 3
file 'image4.png'
duration 2
ffmpeg \
-t 10 \
-i song.mp3 \
-i files.ffconcat \
-pix_fmt yuv420p \
video.mp4
Though 1 + 4 + 3 + 2 = 10 seconds, the final video had a length of 10.84s with silence at the end, as you have observed:
frame= 274 fps= 17 q=-1.0 Lsize= 1013kB time=00:00:10.84 bitrate= 765.2kbits/s dup=343 drop=0 speed=0.683x
However, adding -t 10 as an output option
ffmpeg \
-t 10 \
-i song.mp3 \
-i files.ffconcat \
-pix_fmt yuv420p \
-t 10 \
video.mp4
results in a video which is exactly 10 seconds:
frame= 250 fps= 31 q=-1.0 Lsize= 1002kB time=00:00:10.00 bitrate= 820.0kbits/s dup=343 drop=0 speed=1.25x
Strange Aside
Interestingly enough, if the time durations for each image are 2.5 seconds, the final video does not need this workaround to be exactly 10 seconds:
# files.ffconcat
file 'image1.png'
duration 2.5
file 'image2.png'
duration 2.5
file 'image3.png'
duration 2.5
file 'image4.png'
duration 2.5
ffmpeg \
-t 10 \
-i song.mp3 \
-i files.ffconcat \
-pix_fmt yuv420p \
-t 10 \
video.mp4
frame= 250 fps= 30 q=-1.0 Lsize= 1000kB time=00:00:10.00 bitrate= 818.4kbits/s dup=307 drop=0 speed= 1.2x
This is something I was not able to figure out. But for anyone curious, here's the ffmpeg -version:
ffmpeg version 4.0.1-tessus Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
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.
I'd like to convert my h.264 avi container to a mp4 container with ffmpeg. I've found this works:
./ffmpeg -i myfile.avi -vcodec copy myfile.mp4
ffmpeg version N-51169-gcedf276 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 21 2013 05:12:00 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32 --extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static' --extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 22.100 / 52. 22.100
libavcodec 55. 1.100 / 55. 1.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 48.100 / 3. 48.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[avi # 0x9fff660] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'myfile.avi':
Metadata:
encoder : Lavf52.64.2
Duration: 00:00:10.40, start: 0.000000, bitrate: 409 kb/s
Stream #0:0: Video: h264 (Baseline) (H264 / 0x34363248), yuvj420p, 640x480, 10 fps, 10 tbr, 10 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
Output #0, mp4, to 'myfile.mp4':
Metadata:
encoder : Lavf55.0.100
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuvj420p, 640x480, q=2-31, 10 fps, 10240 tbn, 10 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 8000 Hz, mono, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (pcm_s16le -> libvo_aacenc)
Press [q] to stop, [?] for help
[mp4 # 0xa006ea0] pts has no value
Last message repeated 100 times
frame= 101 fps=0.0 q=-1.0 Lsize= 350kB time=00:00:11.06 bitrate= 259.3kbits/s
video:332kB audio:15kB subtitle:0 global headers:0kB muxing overhead 0.926809%
This generates a file that I can play with the HTML5 video player but for legacy browsers I'd like to use a flash player (Flowplayer). The file doesn't play with Flowplayer, in fact it causes it to crash.
However if I use:
./ffmpeg -i myfile.avi myfile2.mp4
ffmpeg version N-51169-gcedf276 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 21 2013 05:12:00 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/32bit --arch=x86_32 --extra-cflags='-m32 -I/root/ffmpeg-static/32bit/include -static' --extra-ldflags='-m32 -L/root/ffmpeg-static/32bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 22.100 / 52. 22.100
libavcodec 55. 1.100 / 55. 1.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 48.100 / 3. 48.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[avi # 0x9b02660] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'myfile.avi':
Metadata:
encoder : Lavf52.64.2
Duration: 00:00:10.40, start: 0.000000, bitrate: 409 kb/s
Stream #0:0: Video: h264 (Baseline) (H264 / 0x34363248), yuvj420p, 640x480, 10 fps, 10 tbr, 10 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
No pixel format specified, yuvj420p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 # 0x9b065a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 # 0x9b065a0] profile High, level 2.2
[libx264 # 0x9b065a0] 264 - core 129 r2230 1cffe9f - 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=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'myfile2.mp4':
Metadata:
encoder : Lavf55.0.100
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuvj420p, 640x480, q=-1--1, 10240 tbn, 10 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 8000 Hz, mono, s16, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (pcm_s16le -> libvo_aacenc)
Press [q] to stop, [?] for help
frame= 47 fps=0.0 q=25.0 size= 21kB time=00:00:04.40 bitrate= 39.9kbits/s dup=3 dropframe= 59 fps= 56 q=25.0 size= 56kB time=00:00:05.68 bitrate= 80.2kbits/s dup=3 dropframe= 71 fps= 45 q=25.0 size= 89kB time=00:00:06.84 bitrate= 106.9kbits/s dup=3 dropframe= 83 fps= 40 q=25.0 size= 124kB time=00:00:08.12 bitrate= 124.9kbits/s dup=3 dropframe= 94 fps= 36 q=25.0 size= 157kB time=00:00:09.14 bitrate= 140.4kbits/s dup=4 dropframe= 105 fps= 23 q=25.0 Lsize= 309kB time=00:00:11.06 bitrate= 228.8kbits/s dup=4 drop=0
video:291kB audio:15kB subtitle:0 global headers:0kB muxing overhead 1.108651%
[libx264 # 0x9b065a0] frame I:1 Avg QP:17.65 size: 12772
[libx264 # 0x9b065a0] frame P:94 Avg QP:19.46 size: 2868
[libx264 # 0x9b065a0] frame B:10 Avg QP:21.58 size: 1464
[libx264 # 0x9b065a0] consecutive B-frames: 82.9% 13.3% 0.0% 3.8%
[libx264 # 0x9b065a0] mb I I16..4: 16.6% 66.3% 17.1%
[libx264 # 0x9b065a0] mb P I16..4: 4.2% 6.3% 0.5% P16..4: 27.0% 9.5% 5.1% 0.0% 0.0% skip:47.4%
[libx264 # 0x9b065a0] mb B I16..4: 0.8% 1.0% 0.0% B16..8: 39.1% 4.6% 0.5% direct: 2.4% skip:51.7% L0:39.8% L1:56.4% BI: 3.9%
[libx264 # 0x9b065a0] 8x8 transform intra:58.0% inter:74.7%
[libx264 # 0x9b065a0] coded y,uvDC,uvAC intra: 47.3% 0.0% 0.0% inter: 16.6% 0.0% 0.0%
[libx264 # 0x9b065a0] i16 v,h,dc,p: 29% 19% 10% 42%
[libx264 # 0x9b065a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 21% 29% 2% 3% 4% 4% 3% 3%
[libx264 # 0x9b065a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 28% 18% 2% 3% 3% 3% 2% 2%
[libx264 # 0x9b065a0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 # 0x9b065a0] Weighted P-Frames: Y:5.3% UV:0.0%
[libx264 # 0x9b065a0] ref P L0: 67.9% 12.0% 12.6% 6.8% 0.6%
[libx264 # 0x9b065a0] ref B L0: 76.9% 23.1%
[libx264 # 0x9b065a0] ref B L1: 99.7% 0.3%
[libx264 # 0x9b065a0] kb/s:226.31
This works great. But the timing is quite different not to mention CPU cycles. The first command is measured in milli-secs while the second can take quite some time (~5-40secs).
Is there another way I can convert the avi to a mp4 container quickly? Ideally by re-muxing as opposed to re-encoding.
EDIT
I'm using this right now which I find to be the fastest for re-encoding. But again I'd rather not do this. I just want to re-mux the code.
ffmpeg -loglevel quiet -i myfile.avi -vcodec libx264 -profile:v baseline -preset ultrafast myfile.mp4
I wouldn't have done it differently than you already did. I tried to remux the file with ffmpeg-1.2 on OS X 10.7:
ffmpeg --info
ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Apr 8 2013 02:39:03 with Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
I tried your commands and explicitly
ffmpeg -i myfile.avi -vcodec copy -acodec copy out.mp4
But I always got the following errors:
ffmpeg -i myfile.avi -vcodec copy -acodec copy out.mp4
ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Apr 8 2013 02:39:03 with Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
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
[avi # 0x7f9ef981ae00] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'myfile.avi':
Metadata:
encoder : Lavf52.64.2
Duration: 00:00:10.40, start: 0.000000, bitrate: 409 kb/s
Stream #0:0: Video: h264 (Baseline) (H264 / 0x34363248), yuvj420p, 640x480, 10 fps, 10 tbr, 10 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
[mp4 # 0x7f9ef991ac00] Tag [1][0][0][0]/0x00000001 incompatible with output codec id '65536' ([0][0][0][0])
Output #0, mp4, to 'out.mp4':
Metadata:
encoder : Lavf52.64.2
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuvj420p, 640x480, q=2-31, 10 fps, 90k tbn, 10 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
So I did a quick research for the error number and found out pcm_s16le isn't compatible with mp4. See this bug report on the ffmpeg tracker.
This would possibly explain the different results with both of your commands - although it's strange that it did not yield an error in your case (old ffmpeg snapshot?).
So I guess the solution could/would be to provide a different audio codec from the beginning or to convert the audio track to a different codec. As a quick test I tried:
ffmpeg -i myfile.avi -vcodec copy -acodec mp2 out.mp4
The output file was written immediately to disk - no errors were yielded. Unfortunately I don't have the possibility to verify the result with a flash player.