VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hi.
    I want to bach merge videos with audio.
    For one episode there are two qualities (HD and FHD) and one audio file.
    All files have .mp4 extension.
    The name pattern looks like this:

    001f_1920x1080 HD.mp4, 001_1280x720 HD.mp4, 001a_Spanish (es).mp4
    002f_1920x1080 HD.mp4, 002_1280x720 HD.mp4, 002a_Spanish (es).mp4
    003f_1920x1080 HD.mp4, 003_1280x720 HD.mp4, 003a_Spanish (es).mp4
    Is there a way to batch mux audio and video? I want to make sure that correct audio will be merged with video.
    Last edited by m0ck; 5th Jul 2019 at 07:10.
    Quote Quote  
  2. Try:

    Code:
    SETLOCAL ENABLEDELAYEDEXPANSION
    
    for %%a in ("*(es).mp4") do (
    	set number=%%a
    	ffmpeg -i "!number:~0,3!f_1920x1080 HD.mp4" -i "%%~a" -map 0:v -map 1:a -c copy "!number:~0,3!f_1920x1080 HD ES.mp4"
    	ffmpeg -i "!number:~0,3!_1280x720 HD.mp4" -i "%%~a" -map 0:v -map 1:a -c copy "!number:~0,3!_1280x720 HD ES.mp4"
    )
    Quote Quote  
  3. Thanks, it seems to be working.
    Is there an option to automatically delete video and audio files once merged successfully?
    Quote Quote  
  4. Should be possible by checking ffmpeg return code (IF NOT ERRORLEVEL 1 ...). Not sure how reliable that would be.
    Quote Quote  
  5. Can you provide a script if that's not a problem. I a noob with this stuff unfortunately.
    Quote Quote  
  6. Member
    Join Date
    May 2021
    Location
    croatia
    Search PM
    Can someone help me write the code for the similar problem? Forgive me. I am a nobbie in this. I am learning to use ffmpeg.
    I want to merge video 1 with audio 01, merge video 2 with audio 02.... Everything is in the mp4 form.
    I use this:
    ffmpeg -i 1.mp4 -i 01.mp4 -map 0 -map 1 -codec copy X01.mp4
    ffmpeg -i 2.mp4 -i 02.mp4 -map 0 -map 1 -codec copy X02.mp4
    ffmpeg -i 3.mp4 -i 03.mp4 -map 0 -map 1 -codec copy X03.mp4
    ...

    It is working but I have to wait until one video is ready to make another...
    How can I do this automatically?

    Thanks
    Quote Quote  
  7. Originally Posted by jospalato View Post
    Can someone help me write the code for the similar problem? Forgive me. I am a nobbie in this. I am learning to use ffmpeg.
    I want to merge video 1 with audio 01, merge video 2 with audio 02.... Everything is in the mp4 form.
    I use this:
    ffmpeg -i 1.mp4 -i 01.mp4 -map 0 -map 1 -codec copy X01.mp4
    ffmpeg -i 2.mp4 -i 02.mp4 -map 0 -map 1 -codec copy X02.mp4
    ffmpeg -i 3.mp4 -i 03.mp4 -map 0 -map 1 -codec copy X03.mp4
    ...

    It is working but I have to wait until one video is ready to make another...
    How can I do this automatically?

    Thanks
    On Windows, save as .bat and ensure your filepaths are correct.
    Quote Quote  



Similar Threads

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