Skip to content

deepak-rathi/merge-video-audio-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Merge multiple audio files and video files into single MP4 file

Make sure all audio and video files are in same folder, Open Command Prompt in that folder and follow below steps.

  1. Create text file with all audio files names into 'myAudioList.txt', make sure to open the text file and check if all files are in currect order
(for %i in (*.aac) do @echo file '%i') > myAudioList.txt
  1. Create text file with all video files names into 'myVideoList.txt', make sure to open the text file and check if all files are in currect order
(for %i in (*.ts) do @echo file '%i') > myVideoList.txt
  1. If all files are having same codec you would see no problem in merging or else you may face issues and these step will not work for you.

  2. Download ffmpeg open source executable from official website

https://ffmpeg.org/download.html
  1. Extract zip file and copy executable 'ffmpeg.exe' to the same folder having all your audio, video files.

  2. Merge all audio files into single audio file

ffmpeg -f concat -safe 0 -i myAudioList.txt -c copy output.aac
  1. Merge all video files into single video file
ffmpeg -f concat -safe 0 -i myVideoList.txt -c copy output.ts
  1. Merge video file and audio file into single mp4 file
ffmpeg -i output.ts -i output.aac -map 0:V:0 -map 1:a:0 -c copy -f mp4 -movflags +faststart output.mp4

Helpful Web Links:

https://trac.ffmpeg.org/wiki/Concatenate

https://trac.ffmpeg.org/wiki