简体   繁体   English

使用FFmpeg的不同分辨率的Concat视频文件

[英]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. 我正在使用FFmpeg在我的android应用程序中连接视频。我已经按照一些步骤合并了不同格式的视频。 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. 对于mp4视频,我必须将所有输入文件转换为MPEG-2 TS文件,然后合并所有.ts文件以获得输出mp4文件。

  • 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). 如果它们具有不同的分辨率(例如一个是640 * 480而另一个是1280 * 720),我在合并视频时遇到问题。输出视频没有正确合并(有时它会在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. 要合并视频,您需要使用相同的分辨率,您应该缩放640x480视频或压缩1280x720,这取决于您。 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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