ffmpeg命令将不同类型和分辨率的视频连接为1个视频,并且可以在android中播放 [英] ffmpeg commands to concatenate different type and resolution videos into 1 video and can be played in android

查看:232
本文介绍了ffmpeg命令将不同类型和分辨率的视频连接为1个视频,并且可以在android中播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将4种不同分辨率的4种不同视频混为一谈,并键入1个可以在android中播放的视频.我正在使用 https://github.com/guardianproject/android-ffmpeg 在android上移植的ffmpeg

I want to concatinate 4 different videos of 4 different resolution and type into 1 video which can be played in android. I am using ffmpeg ported on android using https://github.com/guardianproject/android-ffmpeg

所以我有这4种不同类型的视频1)

So I have these 4 different types of videos 1)

./ffmpeg -i 1.mp4 
Video: h264 (High), yuv420p, 1920x1080, 16959 kb/s, 29.85 fps, 90k tbr, 90k tbn, 180k tbc
Audio: aac, 48000 Hz, stereo, s16, 106 kb/s

2)

ffmpeg -i 2.mp4
Video: h264 (Constrained Baseline), yuv420p, 640x480, 3102 kb/s, 29.99 fps, 90k tbr, 90k tbn, 180k tbc
Audio: aac, 48000 Hz, stereo, s16, 93 kb/s

3)

ffmpeg -i 3.3gp
Video: h263, yuv420p, 1408x1152 [PAR 12:11 DAR 4:3], 2920 kb/s, 15 fps, 15 tbr, 15360 tbn, 29.97 tbc
Audio: amrnb, 8000 Hz, 1 channels, flt, 12 kb/s

4)

ffmpeg -i 4.3gp
Video: h264 (High), yuv420p, 352x288 [PAR 12:11 DAR 4:3], 216 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc

音频:aac,44100 Hz,立体声,s16、92 kb/s

Audio: aac, 44100 Hz, stereo, s16, 92 kb/s

所以我正在使用以下命令将它们转换为mpegts

So I am converting them to mpegts using following commands

./ffmpeg -i 1.mp4 -c:v libx264 -vf scale=1920:1080 -r 60 -c:a aac -ar 48000 -b:a 160k -strict experimental -f mpegts 1.ts
./ffmpeg -i 2.mp4 -c:v libx264 -vf scale=1920:1080 -r 60 -c:a aac -ar 48000 -b:a 160k -strict experimental -f mpegts 2.ts
./ffmpeg -i 3.3gp -c:v libx264 -vf scale=1920:1080 -r 60 -c:a aac -ar 48000 -b:a 160k -strict experimental -f mpegts 3.ts
./ffmpeg -i 4.3gp -c:v libx264 -vf scale=1920:1080 -r 60 -c:a aac -ar 48000 -b:a 160k -strict experimental -f mpegts 4.ts

然后将.ts文件连接为f.ts,然后使用

then concatenating the .ts files into f.ts and then creating a final .mp4 file from it using

cat 1.ts 2.ts 3.ts 4.ts > f.ts
./ffmpeg -i f.ts -c copy -bsf:a aac_adtstoasc output.mp4

但是我的f.ts似乎也无法在Linux上的VLC中正确播放,它只能播放前2个mp4的视频+音频,而只能播放最后一个.3gp的音频.弄清楚我想念什么?

But my f.ts also doesnt seem to play correctly in VLC on linux, it plays first 2 mp4's video + audio and it plays last .3gp's audio only.(Same for output.mp4 too) Could you please help me in figuring out what am I missing ?

预先感谢

推荐答案

您可以使用 concat 在将所有视频转换为单一格式后,将它们一个接一个地添加.

You can use concat to append all the videos one by one after converting them to a single format.

您还可以使用以下命令将格式不同的视频转换为一种格式:

You can also use the below command to convert differently formatted video to one format:

./ffmpeg -i 1.mp4 -acodec libvo_aacenc -vcodec libx264 -s 1920x1080 -r 60 -strict experimental 1.mp4

将所有内容转换为 mp4 ,然后按照上面的链接中的说明进行操作.这样一来,您就可以将所有视频合并到一个文件中.

Convert everything to mp4 and then follow the instructions given in the link above. This will enable you to join all the videos in a single file.

这篇关于ffmpeg命令将不同类型和分辨率的视频连接为1个视频,并且可以在android中播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆