VideoHelp Forum
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. I have a bunch of video files in a folder that I need to mass mux to mp4.

    Each video has a aac audio file and a h264 video file.

    mp4box does a good job, but it will only allow me to select one file at a time and there's a 10 second pause after it selects the audio track, before I can add it to the queue. This would take ages just to get the queue ready.

    I am looking for a batch muxer or something that will enable me to queue up the audio and video file quickly.

    Thanks in advance.

    P.S. I am not interested in re-encoding the videos.
    Quote Quote  
  2. Man of Steel freebird73717's Avatar
    Join Date
    Dec 2003
    Location
    Smallville, USA
    Search PM
    Use mp4box from the command line. As long as all videos have the same framerate it's easy. In this example the framerate for all the videos is 25.00. If your videos are 23.976 or 29.97 just change that part of the bat script. So copy and paste the text below into notepad, change the path to mp4box.exe, output folder name, and fps if necessarry, then save that as "mp4mux.bat". Put mp4mux.bat into the folder containing all your video and audio files and double click it. It will batch mux all your video and audio files without any user interaction necessary.

    Code:
    for %%a in (*.h264) do "C:\Path\to\Your\Copy\Of\MP4Box.exe" -add "%%a:fps=25.00" -add "%%~na.aac" "C:\Your\Output\Folder\%%~na.mp4"
    Donadagohvi (Cherokee for "Until we meet again")
    Quote Quote  
  3. Originally Posted by freebird73717 View Post
    Use mp4box from the command line. As long as all videos have the same framerate it's easy. In this example the framerate for all the videos is 25.00. If your videos are 23.976 or 29.97 just change that part of the bat script. So copy and paste the text below into notepad, change the path to mp4box.exe, output folder name, and fps if necessarry, then save that as "mp4mux.bat". Put mp4mux.bat into the folder containing all your video and audio files and double click it. It will batch mux all your video and audio files without any user interaction necessary.

    Code:
    for %%a in (*.h264) do "C:\Path\to\Your\Copy\Of\MP4Box.exe" -add "%%a:fps=25.00" -add "%%~na.aac" "C:\Your\Output\Folder\%%~na.mp4"
    Thanks a lot man, works well on a couple of testers I did. Only curious thing was that it would import the h264 file fine, but did not like the name of the aac file and would fail when importing it. The video files were named video name_track1.h264 and audio was video name_track2.aac. I guessed the script was saying "import the h264 file and then add any aac file with exact same name. Anyway I changed the audio to have same name as video and it muxed fine.

    A couple more questions. Is there any programe that will allow me to see the framerate of all files in a folder, so I can easily create seperate batch files andn folders for differing fps? Also, is it possible to add an srt to that script you gave? Thanks a bunch, really appreciate you fixing the above issue for me. I hate scripts, but that one was easy.
    Last edited by dukestravels07; 11th Jul 2010 at 03:12.
    Quote Quote  
  4. Man of Steel freebird73717's Avatar
    Join Date
    Dec 2003
    Location
    Smallville, USA
    Search PM
    Originally Posted by dukestravels07 View Post
    I guessed the script was saying "import the h264 file and then add any aac file with exact same name. Anyway I changed the audio to have same name as video and it muxed fine.
    Yep sorry I should have been more explanatory that all files (video, audio, subs) should be named the same (with the exception of their extensions of course).

    A couple more questions. Is there any programe that will allow me to see the framerate of all files in a folder, so I can easily create seperate batch files andn folders for differing fps?
    You can use mediainfo. It has a feature to scan an entire directory.

    Also, is it possible to add an srt to that script you gave? Thanks a bunch, really appreciate you fixing the above issue for me. I hate scripts, but that one was easy.
    Yep. Just add the following to your script -add "%%~na.srt"
    So your new bat script would be like this
    Code:
    for %%a in (*.h264) do "C:\Path\to\Your\Copy\Of\MP4Box.exe" -add "%%a:fps=25.00" -add "%%~na.aac" -add "%%~na.srt" "C:\Your\Output\Folder\%%~na.mp4"
    And yes remember that your video, audio, and subs all need to have the same name.
    Donadagohvi (Cherokee for "Until we meet again")
    Quote Quote  
  5. Originally Posted by freebird73717 View Post
    Originally Posted by dukestravels07 View Post
    I guessed the script was saying "import the h264 file and then add any aac file with exact same name. Anyway I changed the audio to have same name as video and it muxed fine.
    Yep sorry I should have been more explanatory that all files (video, audio, subs) should be named the same (with the exception of their extensions of course).

    A couple more questions. Is there any programe that will allow me to see the framerate of all files in a folder, so I can easily create seperate batch files andn folders for differing fps?
    You can use mediainfo. It has a feature to scan an entire directory.

    Also, is it possible to add an srt to that script you gave? Thanks a bunch, really appreciate you fixing the above issue for me. I hate scripts, but that one was easy.
    Yep. Just add the following to your script -add "%%~na.srt"
    So your new bat script would be like this
    Code:
    for %%a in (*.h264) do "C:\Path\to\Your\Copy\Of\MP4Box.exe" -add "%%a:fps=25.00" -add "%%~na.aac" -add "%%~na.srt" "C:\Your\Output\Folder\%%~na.mp4"
    And yes remember that your video, audio, and subs all need to have the same name.
    Thanks for additional info.

    One last thing. Do you have a code for a batch file that I can throw into a folder with mkv files in it?. Something that will extract the aac and h264 files for me. Something that would use mkvextract or the like? I like the idea of running a batch file and leaving it to do its job. Thanks again!
    Quote Quote  
  6. Man of Steel freebird73717's Avatar
    Join Date
    Dec 2003
    Location
    Smallville, USA
    Search PM
    Assuming that there is only one video and audio in each mkv file.
    Code:
    @for %%a in (*.mkv) do "C:\Path\to\mkvextract.exe" tracks "%%a" 1:"%%~na.h264" 2:"%%~na.aac"
    or if you have a srt subtitle you can do it like this
    Code:
    @for %%a in (*.mkv) do "C:\Path\to\mkvextract.exe" tracks "%%a" 1:"%%~na.h264"  2:"%%~na.aac" 3:"%%~na.srt"
    This will give you an h264 file and an aac file with the same name as the mkv.

    You could even combine the extract and mux files into one batch file

    Do it like this with no subs
    Code:
    @for %%a in (*.mkv) do "C:\Path\to\mkvextract.exe" tracks "%%a"  1:"%%~na.h264" 2:"%%~na.aac"
    @for %%a in (*.h264) do "C:\Path\to\Your\Copy\Of\MP4Box.exe" -add "%%a:fps=25.00" -add "%%~na.aac" "C:\Your\Output\Folder\%%~na.mp4"
    or like this with subs
    Code:
    @for %%a in (*.mkv) do "C:\Path\to\mkvextract.exe" tracks "%%a"   1:"%%~na.h264" 2:"%%~na.aac"
    @for %%a in (*.h264) do "C:\Path\to\Your\Copy\Of\MP4Box.exe" -add "%%a:fps=25.00" -add "%%~na.aac" -add "%%~na.srt"  "C:\Your\Output\Folder\%%~na.mp4"
    Donadagohvi (Cherokee for "Until we meet again")
    Quote Quote  
  7. Member
    Join Date
    Jun 2012
    Location
    lamiara
    Search PM
    thanks for the tip freebird :P
    Quote Quote  
  8. You could do the same with ffmpeg without having to explicitly extract streams and then mux them.

    Code:
    for %%a in (*.mkv) do "c:\path\to\ffmpeg.exe" -i "%%a" -acodec copy -vcodec copy "%%~na.mp4"
    Quote Quote  
  9. Jagabo's ffmpeg command line works well.

    for %%a in (*.mkv) do "c:\path\to\ffmpeg.exe" -i "%%a" -acodec copy -vcodec copy "%%~na.mp4"

    However, when I examine the resulting mp4 files with mediainfo, the chapter markers are written twice,
    once for the video stream, and again for the audio stream. Doing some Google searches, I found the
    following command line switch:

    "-movflags disable_chpl"

    This switch seems to do the trick of only writing the chapter info once, although the resulting mp4 when examined with
    mediainfo show the chapters as a separate stream.

    Does ffmpeg have another, better command line switch to copy over chapter info from an mkv to an mp4?

    Thanks.
    Last edited by pm1315; 29th Mar 2015 at 03:08. Reason: correction
    Quote Quote  
  10. Aren't chapter markers always separate streams?
    Quote Quote  
  11. Yes, you are correct Jagabo. Thanks.

    Original MKV

    Menu
    00:00:00.000 : en:Chapter 1
    00:05:00.000 : en:Chapter 2
    00:10:00.000 : en:Chapter 3
    00:15:00.000 : en:Chapter 4
    00:20:00.000 : en:Chapter 5
    00:25:00.000 : en:Chapter 6
    00:30:00.000 : en:Chapter 7
    00:35:00.000 : en:Chapter 8
    00:40:00.000 : en:Chapter 9
    00:45:00.000 : en:Chapter 10


    Remuxed to MP4 with ffmpeg using the "-movflags disable_chpl" switch

    Menu
    ID : 3
    Codec ID : text
    Duration : 1h 38mn
    Language : English
    Duration_LastFrame : -82624
    00:00:00.000 : Chapter 1
    00:05:00.000 : Chapter 2
    00:10:00.000 : Chapter 3
    00:15:00.000 : Chapter 4
    00:20:00.000 : Chapter 5
    00:25:00.000 : Chapter 6
    00:30:00.000 : Chapter 7
    00:35:00.000 : Chapter 8
    00:40:00.000 : Chapter 9
    00:45:00.000 : Chapter 10
    Bit rate mode : VBR
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!