8
5
I have two videos I would like to concatenate.
- First Video Dimensions = 480x640
- Second Video Dimensions = 640x480
I tried concatenating them and received an error. I've included the full error below.
ffmpeg -i 682_segment_0.mp4 -i 682_segment_1.mp4 -filter_complex \
"[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]" \
-map "[v]" -map "[a]" -ar 44100 -vcodec libx264 \
-strict -2 -acodec aac 682.mp4
ffmpeg version 2.8.8-0ubuntu0.16.04.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.2) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '682_segment_0.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:19.30, start: 0.000000, bitrate: 335 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x640 [SAR 1:1 DAR 3:4], 219 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 120 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '682_segment_1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:09.97, start: 0.000000, bitrate: 568 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 460 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 3.0, fltp, 104 kb/s (default)
Metadata:
handler_name : SoundHandler
[Parsed_concat_0 @ 0x202dea0] Input link in1:v0 parameters (size 640x480, SAR 1:1) do not match the corresponding output link in0:v0 parameters (480x640, SAR 1:1)
[Parsed_concat_0 @ 0x202dea0] Failed to configure output pad on Parsed_concat_0
Error configuring complex filters.
Invalid argument
I did a bit of checking, and it appears I need to resize one of the videos to be the same size as the other video before I could concatenate it. I'm not sure if that is correct, but I resized it using ffmpeg.
ffmpeg -i 682_segment_0.mp4 -vf scale=640:480 -strict -2 682_segment_0b.mp4
After resizing the 480x640 video to 640x480 I tried the concat command again. And got another error. (I've included the final error here, but not the whole output.)
Input #0 Video Stream: 640x480 [SAR 9:16 DAR 3:4]
Input #1 Video Stream: 640x480 [SAR 1:1 DAR 4:3]
[Parsed_concat_0 @ 0x22cefe0] Input link in1:v0 parameters (size 640x480, SAR 1:1) do not match the corresponding output link in0:v0 parameters (640x480, SAR 9:16)
[Parsed_concat_0 @ 0x22cefe0] Failed to configure output pad on Parsed_concat_0
I found that resizing the DAR allowed me to concat the two videos, but the resized portion of the completed video now has the wrong aspect ratio. I was hoping to basically have "black" on the sides with my resize without cropping the video.
I attached an example here:
Resize DAR command that worked but made aspect ratios wrong:
ffmpeg -i 682_segment_0.mp4 -ar 44100 -vcodec libx264 \
-strict -2 -acodec aac -s 360x480 682_segment_0e.mp4
I am wondering if I should try doing the concat and rescale at the same time, but I am not sure how to do so.
Thanks for the suggestion about updating ffmpeg. I was unaware that I was on an old version. I had used apt-get on Ubuntu to do the newest version. I went ahead and built from source. Also thanks for the link to the Resizing videos. The letterbox example was exactly what I was after. I am not clear what you mean by "conform each input". Do you have a reference to what you meant by that? And thanks again for the documentation link on concat. I read a lot of documentation, but its hard to know exactly what I'm looking for. – Daryl – 2016-10-20T21:57:52.100
@Daryl Yeah, there is a lot to read. By "conform each input" I meant that you should explicitly set each "common" parameter mentioned in the concat doc quote in the answer. Because if your inputs for one command compared to the next command vary in sample rate, channel layout, pixel format, etc, then concat will choose a different "common" set of parameters for each output per command. – llogan – 2016-10-20T22:31:07.507