0

I have two videos which I want to merge. Both have same resolution. The second video does not have any audio

ffmpeg -i test.mp4 -i picture.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=1:v=2:a=1 [v] [a]" -map "[vv]" -map "[aa]" mergedVideo.mp4

this is the command that I am using but I am getting the following error Stream specifier ':a' in filtergraph description [0:v] [0:a] [1:v] [1:a] concat=n=2:v=2:a=1 [v] [a] matches no streams.

I am not very familiar with ffmpeg commands but I guess I am giving some wrong -filter complex values

2 Answers2

0

You are trying "concat video filter" method of ffmpeg. I would suggest trying "concat demuxer". Create a file named inputlist.txt (or anything you like) with the following content:

file 'test.mp4'
file 'picture.mp4'

and then run ffmpeg as follows:

ffmpeg -f concat -safe 0 -i inputlist.txt -c copy mergedVideo.mp4
tikeman
  • 39
  • 10
  • I did try this method but I want to use this command in my android application and I will have to write the path of the two video every time to the txt file. I want a command where I can concatenate them with just their paths – Usama Shakeel Aug 12 '21 at 10:55
  • 1
    As mentined in the documentation: [link](https://ffmpeg.org/ffmpeg-filters.html#concat) "All segments must have the same number of streams of each type, and that will also be the number of streams at output." Your first video has both video and audio streams but second video only video stream. So, stream numbers are not same. This is the reason of error you are getting. concat video filter may not be appropriate for your case – tikeman Aug 12 '21 at 11:13
  • Is there a way to merge the image file with the video instead of two videos? – Usama Shakeel Aug 12 '21 at 11:39
0

Missing audio

  • picture.mp4 does not have audio.
  • You cannot concatenate an input with audio with an input that does not have audio.
  • Solution is to add silent/dummy/filler audio with the anullsrc filter. Or add an audio file.

Example

ffmpeg -i test.mp4 -i picture.mp4 -t 0.1 -f lavfi -i anullsrc -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" mergedVideo.mp4

Other problems

  • In your first command you were telling the concat filter that you have 1 set of segments (n=1) instead of 2 (n=2). See the concat filter documentation.
  • You were telling the concat filter that you have 2 video outputs (v=2) instead of 1 (v=1). See the concat filter documentation.
  • Your -map labels were referring to non-existent labels. See FFmpeg Wiki: Map.
  • There may be additional issues to resolve, but you did not include the complete log.
llogan
  • 121,796
  • 28
  • 232
  • 243