FFMPEG – Merge Multiple Audio Files To A Single Video


  • Place all of your audio files and and image in the same folder as the script,
    run the script to get properly encoded, stream’able video file.
  • You may edit the script to accept any type of media-file,
    and any name for the image other than cover.jpg.
@echo off

echo # MP3 LIST(%DATE% %TIME%) >list.txt
for %%e in (*.mp3 *.m4a *.oga *.flac) do (
  echo file '%%e' >>list.txt
)

call ffmpeg.exe -y -hide_banner -loglevel "info" -stats     ^
-threads 16                                                 ^
-flags     "+loop+global_header+naq+low_delay"              ^
-fflags    "+genpts+discardcorrupt+fastseek"                ^
-flags2    "+fast+ignorecrop+showall+export_mvs"            ^
-avoid_negative_ts make_zero                                ^
 ^
-safe "0"  -f concat  -i "list.txt"                         ^
-r 1       -loop 1    -i "cover.jpg"                        ^
-movflags  "+rtphint+dash+disable_chpl+faststart"           ^
 ^
-ss        "00:00:00.001"                                   ^
-to        "00:00:10.000"                                   ^
 ^
-s "1280x720"                                               ^
-ignore_chapters   1                                        ^
-profile:v "high" -level "5.0"                              ^
-pix_fmt   "yuv420p"                                        ^
-tune      "stillimage"                                     ^
-preset    "veryslow" -crf "23" -subq "9" -qcomp "0.60"     ^
 ^
-af        "asetpts=PTS-STARTPTS,aresample=async=1:min_hard_comp=0.100000"  ^
-vf        "setpts=PTS-STARTPTS" -vsync "1"                                 ^
 ^
-c:a  aac      -b:a 128k -ar 44100                          ^
-c:v  libx264  -b:v 1k -minrate 1k -maxrate 1k              ^
 ^
output.mkv


del /f /q list.txt >nul

::http://icompile.eladkarako.com/ffmpeg-merge-multiple-audio-files-to-a-single-video/#more-7102
pause

The proportions of the video are YouTube’s 720p, and the audio quality is 128KBPS,
Which you also may modify for your needs.

You may want to remove the following lines from the script:

-ss        "00:00:00.001"                                   ^
-to        "00:00:10.000"                                   ^

the -to is to output a quick demo (testing quality),
the -ss is to force re-build the index without using some of ffmpeg’s bug’gy speed tweaks.


In a similar way, this will just generate an audio file,

@echo off

echo # MP3 LIST(%DATE% %TIME%) >list.txt
for %%e in (*.mp3 *.m4a *.oga *.flac) do (
  echo file '%%e' >>list.txt
)

call ffmpeg.exe -y -hide_banner -loglevel "info" -stats     ^
-threads 16                                                 ^
-flags     "+loop+global_header+naq+low_delay"              ^
-fflags    "+genpts+discardcorrupt+fastseek"                ^
-flags2    "+fast+ignorecrop+showall+export_mvs"            ^
-avoid_negative_ts make_zero                                ^
 ^
-safe "0"  -f concat  -i "list.txt"                         ^
-vn -sn                                                     ^
-movflags  "+rtphint+dash+disable_chpl+faststart"           ^
 ^
-ss        "00:00:00.001"                                   ^
-to        "00:00:10.000"                                   ^
 ^
-af        "asetpts=PTS-STARTPTS,aresample=async=1:min_hard_comp=0.100000"  ^
 ^
-c:a  aac      -b:a 128k -ar 44100                          ^
 ^
output.aac


del /f /q list.txt >nul

::http://icompile.eladkarako.com/ffmpeg-merge-multiple-audio-files-to-a-single-video/#more-7102
pause

Want a mp3 file?
use -c:a libmp3lame -b:a 128k -ar 44100 ^ instead.


I use mp3tag to add useful meta-data (aka. IDv3) to the result video or audio file.

Leave a Reply