1
I have a portrait video (9:16 ratio) taken on a phone, and would like to convert it to a lanscape one (16:9), either with black padding on the side or, ideally, with blurred padding (but not overly important).
There are many questions on SE about this, as well as tutorials on other websites, but I have not been able to make any of these work. They tend to either not run at all, or give an error "no such filter", and then list the command input, eg
ffmpeg -i MC_orig.mp4 -filter_complex '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' outputfile.mp4
gives the error
[AVFilterGraph @ 000001bc89ea28c0] No such filter: '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' Error initializing complex filters. Invalid argument
All the tutorials/SE questions I have found suggest a similar input to the one above, and all give basically the same error.
My full console output (Windows 10, using Command Prompt or Cmder), including details of the FFmpeg version that I'm using, is the following.
D:\Users\Sam\Videos\FFMPEG\bin>ffmpeg -i MC_orig.mp4 -filter_complex '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' outputfile.mp4 ffmpeg version N-91930-g0caa33c60b Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20180813 configuration: --enable-gpl --enable-version3 --enable-sdl2 --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. 19.101 / 56. 19.101 libavcodec 58. 30.100 / 58. 30.100 libavformat 58. 18.100 / 58. 18.100 libavdevice 58. 4.103 / 58. 4.103 libavfilter 7. 29.100 / 7. 29.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MC_orig.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2018-09-09T18:07:24.000000Z com.android.version: 7.0 Duration: 00:07:12.03, start: 0.000000, bitrate: 12081 kb/s Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 11950 kb/s, 24.94 fps, 24.92 tbr, 90k tbn, 300 tbc (default) Metadata: rotate : 90 creation_time : 2018-09-09T18:07:24.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, 127 kb/s (default) Metadata: creation_time : 2018-09-09T18:07:24.000000Z handler_name : SoundHandle [AVFilterGraph @ 000001bc89ea28c0] No such filter: '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' Error initializing complex filters. Invalid argument
Thank you, it is now running. Is it old syntax to use single-quotes? Only all the tutorials I saw had single-quotes. (Actually, some had doubles but also failed, but for a different reason, which I forget now!) Anyway, it's running, and I'll update when it's done! – Sam T – 2018-09-14T11:41:35.937
The use of enclosing quotes is related to the shell, not ffmpeg. On linux/OSX, single quotes is fine. – Gyan – 2018-09-14T11:55:52.693
So it has now finished, and it gives the desired output. However, I then want to change it from an
mp4
to anavi
. I had done this with a previous file using the codeffmpeg -i MC_orig.mp4 -vcodec copy out.avi
and it worked fine. However, if I do this inputting the video I just created with your help, then ffmpeg runs, but the video doesn't work (audio does, but no video) – Sam T – 2018-09-14T12:18:11.790(I realise that normally one would ask this as a separate question, but the reason that I'm adding it here is that I have been able to do it previously, but with this video I have an issue.) – Sam T – 2018-09-14T12:19:06.183
Share the output of
ffmpeg -i outputfile.mp4
– Gyan – 2018-09-14T12:24:11.083Since it's quite long, I've added it to the original post. Thanks for your assistance – Sam T – 2018-09-14T12:50:42.037
Your output resolution is higher than can be accommodated by the H264 decoder of most players. VLC should still play the video, but you'll need to downscale to 1920 width or lower for broad compatibility. Also, storing H264 with B-frames in AVI is hacky and not really recommended. Add
-bf 0
to disable them. – Gyan – 2018-09-14T13:03:39.520I must confess, I don't know what a B-frame is. The only reason I'm trying to convert is that I have a video that I want to concaternate it with, taken from another camera, and that is in AVI (it's the first part of a speech on one camera and the second half on the phone video) -- the AVI video is a better quality video (from a proper video camera), so I thought it best to convert the phone camera video to AVI and then concaternate. \ Does this sound like the right thing to do to you, and (if so) are you able to advise me as to what code I should use to convert from MP4 to AVI? Thanks so much – Sam T – 2018-09-14T13:46:18.500
This has now veered into a separate question. Make one with logs of both files. – Gyan – 2018-09-14T14:47:55.943
I have actually fixed my issue by using handbrake in addition to ffmpeg, and so have rolled back the question to include only the original issue. Thank you for your help! – Sam T – 2018-09-14T18:24:47.907