Search code examples
videoffmpegaspect-ratiovideo-editing

FFMPEG concatenate 2 random and different videos


I am trying to make an app in which users can send a video and it will be concatenated with other videos automatically. So the videos are in random formats, but I am converting them before concatenation using this command :

ffmpeg -y -i {orginalVideo.itsExtention} -vcodec wmv2 4.wmv

For the concatenation I have the following command:

ffmpeg -y -i concat.wmv -i 4.wmv -filter_complex "[0:0][0:1][1:0][1:1] concat=n=2:v=1:a=1" output.wmv

but I get the following error

Input link in1:v0 parameters (size 640x480, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1080x1920, SAR 1:1)

Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0

Thank you for your answer


Solution

  • The videos have to be the same size (pixel dimensions, that is). The output stream can't change sizes midway through. So resize one (or both) to the desired size.

    e.g.:

    ffmpeg -y -i {orginalVideo.itsExtention} -vf scale=640:480 -vcodec wmv2 4.wmv
    

    And see https://trac.ffmpeg.org/wiki/Scaling for more.