Multiple Resolution Concatenated Files Using FFmpeg

I am using FFmpeg for concat video in an android application. I followed some steps to combine videos of different formats. For mp4 video, I need to convert all input files to MPEG-2 TS files and then combine all .ts files to get mp4 output file.

  • I have a problem with combining videos if they are different from each other (say 640 * 480, and the other is 1280 * 720). The video output does not merge properly (sometimes this causes an error in Streams). Is there a way to handle this without losing video quality?

  • Suppose I combine two videos, one with audio and the other without audio. When I try to combine these two, I get errors in Audio Streams. Is there a way to handle this (videos should be combined with or without audio)?

I ran into problems in the two above things and spent more time without success. Any idea is welcome.

+4
source share
1 answer

To merge the video you need to work with the same resolution, you have to scale the video to 640x480 or compress 1280x720, it is up to you. I would recommend you compress more than faster.

In addition, to merge the video you need a media file with audio and video part. You can create a silence sound with the same length of your video even after you can add it to your video. Videos must be combined with audio.

ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -i /dev/zero -ab 128K -f mp2 -acodec mp2 -y silence.mp2 ffmpeg -i video_without_audio.mpg -i silence.mp2 video_to_merge.mpg 
0
source

Source: https://habr.com/ru/post/1490905/


All Articles