I use https://github.com/Zulko/moviepy library for merge two videos with python. It merged successfully but sound of videos is not exists in merged.mp4.
The python code :
clip1 = VideoFileClip("2.mp4",audio=True)
clip2 = VideoFileClip("1.mp4",audio=True)
final_clip = concatenate_videoclips([clip1,clip2],method="compose")
final_clip.write_videofile("merged.mp4")
I also tried with ffmpeg
ffmpeg -i 'concat:1.mp4|2.mp4' -codec copy merged.mp4
ffmpeg couldn't merge videos. It create merged.mp4 which has only 1.mp4
How can I merge two videos with python or another way?
ffmpeg offcial
Instructions Create a file mylist.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored):
file 'path/to/file1.wav'
file 'path/to/file2.wav'
file 'path/to/file3.wav'
Note that these can be either relative or absolute paths. Then you can stream copy or re-encode your files:
ffmpeg -f concat -safe 0 -i mylist.txt -c copy mergedfile.mp4
The -safe 0 above is not required if the paths are relative.
It works for all kinds of video formats mp4, wav ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With