Ubuntu用 MP4Box -cat file1.mp4 -cat file2.mp4 output.mp4 这个命令连接两个相同的mp4正常,
但是连接两个不同的mp4文件,虽然分辨率相同,就是输出的output.mp4根本不正常,
请问应该如何连接两个mp4文件, 可以用参数输出指定的分辨率和音频编码?
离线
https://askubuntu.com/questions/161226/how-to-join-video-files-from-terminal
If you want to combine two videos safely, you need to change the video codec and audio codec of input files into the same codecs.
For example, using xvid (video codec) and mp3lame (audio codec):
sudo apt-get install mencoder libxvidcore4 libmp3lame0
you can encode the input videos by the below commands:mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=1000 first.avi -o video1.avi
mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=1000 second.avi -o video2.avi
To be matched your videos, you can change the options "bitrate" etc. (and also the codecs).If the encoded video names are "video1.avi" and "video2.avi", and the output video name is "joined-video.avi",
mencoder -ovc copy -oac mp3lame video1.avi video2.avi -o joined-video.avi
Using this command, you can make the joined video file.
按这上面说的,
先把两个视频文件转成相同的码率,相同的分辨率, 相同的音视频编码格式,
然后再连接试一试。
离线
https://superuser.com/questions/521113/join-mp4-files-in-linux
ffmpeg -i input0.mp4 -map 0 -c copy -f mpegts -bsf h264_mp4toannexb -y temp0
ffmpeg -i input1.mp4 -map 0 -c copy -f mpegts -bsf h264_mp4toannexb -y temp1
ffmpeg -f mpegts -i "concat:temp0|temp1" -c copy -absf aac_adtstoasc output.mp4
这两个也是一样的原理!
先把mp4解到两个临时文件ts码流
然后cat起来并转成mp4
离线