简体   繁体   中英

Concat video files of different resolutions using FFmpeg

I am using FFmpeg to concat videos in my android application.I have followed some of the steps to merge videos of different formats. For mp4 videos, i have to convert all input files to MPEG-2 TS files and then merge all the .ts files to get an output mp4 file.

  • I have a problem in merging the videos if they are of different resolutions(say one is 640*480 and the other is 1280*720).The output video does not merge properly(sometimes it throws an error in Streams). Is there any way to handle this without losing the quality of videos?

  • Lets say i am merging two videos one with audio and the other without audio.When i try to merge these two i am getting errors in Audio Streams.Is there any way to handle this also(videos should be merged with or without audio)?

I am facing problems in above two things and spent more time without success. Any idea is greatly appreciated.

For merging videos you need to work with the same resolution, you should scale the 640x480 video or compress the 1280x720, it is up to you. I would recommend you compress the bigger one it is faster.

Moreover, for merging videos you need a media file with audio and video part. You can create a silence audio with the same duration of your video and after you can add it to your video. Videos should be merged 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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM