VideoHelp Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. I have a list of .m4v files. I have a list of .mp3 files (which happen to be the same file name as the corresponding .m4v files).

    The .m4v files contain lower quality audio. The .mp3 files contain a better quality audio.

    I would like to replace the audio in the .m4v files, with the corresponding audio in the .mp3 files.

    I would not like to do this individually for 10000+ files, in either mkvmerge or ffmpeg.

    I have tried a batch script with something like this but to no avail:

    Code:
    FOR %%a IN ("*.m4v") DO ffmpeg -i "${%%a}" -i "${%%a//.m4v/.mp3}" -vcodec copy -acodec copy "${%%a//.m4v/.mp4}"
    
    pause
    As well as (as I wanted the output in a different directory):

    Code:
    FOR %%a IN ("*.m4v") DO ffmpeg -i "%%a" -i "%%a" -vcodec copy -acodec copy "outputDirFoo123\%%~na.mp4"
    
    pause
    These so far have been unsuccessful (have only encountered errors). I am not sure how to fix this.

    Could someone please indicate how I can batch process what I want above? Is there a better way to do it than I am here?

    Many thanks.
    Quote Quote  
  2. Code:
    FOR %%a IN (*.m4v) DO ffmpeg -i "%%a" -i "%%~na.mp3" -map 0:v -map 1:a -c copy "outputDirFoo123\%%~na.mp4"
    
    pause
    Will copy video from file #0 and audio from file #1. Any metadata or subtitles you are worried about?
    Quote Quote  
  3. Originally Posted by sneaker View Post
    Code:
    FOR %%a IN (*.m4v) DO ffmpeg -i "%%a" -i "%%~na.mp3" -map 0:v -map 1:a -c copy "outputDirFoo123\%%~na.mp4"
    
    pause
    Will copy video from file #0 and audio from file #1. Any metadata or subtitles you are worried about?
    Thanks! And yes, is it possible to retain the metadata from the .mp3 (i.e. such as author/presenter/speaker/etc/date) and incorporate that into the remuxed .mp4?
    Quote Quote  
  4. Try to add -map_metadata 1 or -map_metadata:s:a 1:s:a. I'm not sure it will work though as you expect or at all. Metadata from different formats cannot always be copied.
    Quote Quote  
  5. Originally Posted by sneaker View Post
    Try to add -map_metadata 1 or -map_metadata:a 1:a. I'm not sure it will work though as you expect or at all. Metadata from different formats cannot always be copied.
    The former worked quite well - many thanks for raising that point - I did not realise it could be done. Appreciate it!
    Quote Quote  



Similar Threads

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