1

I have 50 parts of mp3 audio files and 50 parts of mp4 video files (without audio) files, which I want to unite into one video. I tried uniting the audio files into one file, then uniting the videos into one file, and eventually unting it all to one video with the following command. I used this How to merge audio and video file in ffmpeg.

ffmpeg.exe -f concat -safe 0 -i video_list.txt -c:v video.mp4

ffmpeg.exe -f concat -safe 0 -i audio_list.txt -c:a audio.mp3

ffmpeg.exe -i video.mp4 -i audio.mp3 -c:v copy -c:a aac final.mkv

All tryings led to the video being played before the audio in final.mkv (audio delayed).

Am I doing it wrong?

3
  • 1
    Make sure all inputs have the same attributes for proper concatentation.
    – llogan
    Dec 31, 2020 at 23:31
  • How should I check it? And if they don't have the same attributes, how should I still concat them? I do think I found that the audio is a bit longer, thus I tried to trim each audio part to the exact length of each video part using: ffmpeg -i 0.mp3 -ss 0 -t 10.011 -c new_0.mp3 That didn't help. It makes me think that maybe the merge between the final audio and the final video is made in a wrong way.
    – Omer G
    Jan 1, 2021 at 9:14
  • 1) You can compare with ffmpeg -i 0.mp3 -i 1.mp3 -i 2.mp3, etc & ffmpeg -i 0.mp4 -i 1.mp4 -i 2.mp4, etc. It will print the details on each input. 2) If they don't match then use various filters to make them match. Many, many concat example on this site and Stack Overflow doing that.
    – llogan
    Jan 1, 2021 at 19:32

1 Answer 1

0

Eventually I succeeded by uniting each video with the suitable audio with the -shortest ffmpeg option. That's made ffmpeg stop encoding once one file ends. Then I united all the videos that were created together. Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.