VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. this is the code i once use in the past to batch add a secondary audio to a tv show, however i can not remember or find the videohelp post i used to help me do it and also the script was a little messy because i needed to rename all episode to sequential order 1,2,3 etc, also mkvs needed to be on folder A and audios needed to be on folder B and end result on folder "output", my question is it possible to do this on a more efficient way?

    * 1) do i have to rename episodes and audios files to sequential order or can it be done so it scan the folder for mkv, audios files, etc or idk?
    * 2) can it be automated so that it replaces or delete original mkv files?

    thank you in advance.

    code here:
    Code:
    @echo off
    setlocal enabledelayedexpansion 
    cd /D %~dp0
    cd A
    attrib -h *.*
    set i=0
    for %%a in (*.*) do set /A i+=1 & set alpha[!i!]=%%a & set gamma[!i!]=%%~na
    cd ..
    cd B
    attrib -h *.*
    set i=0
    for %%b in (*.*) do set /A i+=1 & set beta[!i!]=%%b
    cd ..
    set n=%i%
    
    for /L %%i in (1,1,%n%) do "D:\Users\aniel\Documents\portable programs\mkvtoolnix\mkvtoolnix\mkvmerge.exe" -o "output\!gamma[%%i]!.mkv" "A\!alpha[%%i]!" --no-video "B\!beta[%%i]!"
    pause
    Quote Quote  
  2. Can't you search the threads you've created, or posted in ? Or was that with another account ?
    As it is, it's difficult to figure out exactly what you intend to do and what the problem exactly is...
    Quote Quote  
  3. Originally Posted by abolibibelot View Post
    Can't you search the threads you've created, or posted in ? Or was that with another account ?
    As it is, it's difficult to figure out exactly what you intend to do and what the problem exactly is...
    am trying to batch add a secondary audio to a given tv show using mkvtoolnix or similar the most efficient way, if you can help me i would appreciate it, thanks.
    Quote Quote  
  4. * 1) do i have to rename episodes and audios files to sequential order or can it be done so it scan the folder for mkv, audios files, etc or idk?
    Well, it's still a bit sketchy... What format are those files currently in ? And how do you know which file's audio must be merged with which file's video ? What are their default names, prior to any renaming operation ?
    Since you used the --no-video switch for the second input I assume that it's a second video file. So perhaps it would be more convenient to first extract the audio with a name matching that of the first video input.
    With ffmpeg (if the "beta" files are in MP4 with AAC audio) :
    Code:
    for %%I in (*.mp4) do ffmpeg -i "%%I" -vn -c:a copy "%%~nI.m4a"
    With mp4box :
    Code:
    for %%I in (*.mp4) do mp4box -add "%%I#audio" -new "%%~nI.m4a"
    It might be possible to adapt the command to change the name of the output as required, or to use a dedicated tool like Bulk Rename Utility to rename the audio files with a specific template, so as to streamline the remuxing script.

    * 2) can it be automated so that it replaces or delete original mkv files?
    Well, that would not be recommended, if there's any SNAFU you're SOL and JWF...
    Quote Quote  
  5. original mkvs look like this: https://forum.videohelp.com/images/imgfiles/6Jk49Jp.png, https://forum.videohelp.com/images/imgfiles/7kAoA4L.png
    and audios look like this: https://forum.videohelp.com/images/imgfiles/tcYp7DL.png
    do u get the idea? as for not deleting original am fine with it, i can always delete it it manually once i confirm everything was done successfully.
    Quote Quote  
  6. Well, yes, but it's going to be tricky to give further advice without explicitly mentioning what is shown on those screenshots, which may be at odds with some rules over here !...
    As I said, with Bulk Rename Utility it would be easy to rename those .eac3 files so that their names (without the extension) matches that of the corresponding .mkv files, or the other way around (which should be even easier since the part after the episode number appears to be different between folders — with BRU you can for instance remove everything beyond a given position, and replace the extra dot with a space). Then with all the files in the same folder a simple command like this should work :
    Code:
    for %%I in (*.mkv) do mkvmerge -o "%%~nI [remux].mkv" "%%I" "%%~nI.eac3"
    By the way, it's convenient to have CLI utilities in Windows' "Path", as described here. To avoid doing it for each utility, I created a "CLI" directory on the system partition, and put there all the .exe files I use regularly, more specifically hard links created with Link Shell Extension, which allows to have the same file in several directories on the same partition with no added clutter.
    In the command above, I used an upper-case letter for the variable, which is better to avoid confusion with the lower-case modifiers (~n, ~x, ~z...).
    The command as it is works as a .bat script, if executing it from the command prompt, only one percent sign must be used, "%I" instead of "%%I".
    You can replace "[remux]" by anything you want, for instance the language of the added audio track.
    You could refine the muxing scheme by specifying the order of each audio track, and which one should be played by default. The most convenient way to do that is to set it as intended for one file through MKVToolNix GUI, then copy the command line, then adapt the script accordingly with the complimentary switches and parameters.

    I'll have to re-watch the whole thing some day... it's been 10 years already, so hard to believe... é_è I'm afraid I could find most of it quite trite in retrospect, with the full knowledge of how it all transpires ultimetaly, even though I have very fond memories of many moments, and of the general mood associated with it, the intense speculation it elicited... (Recently I made a 5 hours trip by car pooling, I had slept about 3 hours that night, the driver talked a lot, said it made the trip seem much shorter, I tried to interact as much as possible, despite being utterly tired and despite my general tendency to STFU, and so at some point we talked about series we had watched and appreciated, I mentioned this one, he said that he had stopped watching it some time during the second season, when it indeed got really boring for at least 10 straight episodes and I remember being on the verge of "letting it go" myself, but then he asked me to tell him how it all ended and what that smoke thing really was... and so, half awake, resisting the urge to take a nap, with a flimsy grasp on reality and what distinguishes it from mystic magnetic island fantasies, I tried my best to provide an account of the most significant events beyond that point {that does not include the dude who gets killed repeatedly and inexplicably resuscitated, or the polar bears, or the tatoos, or the spiders... but I did mention the seemingly very important new female character who got "artzed" before she did anything meaningful...}, which would somewhat make sense for someone who stopped at the "push the button every 108 minutes or else..." storyline, without sounding too crazy... I must have achieved that feat somehow since he didn't kick me out of the car and call the closest psychiatric ward, then I reached my destination with all my belongings and with no nosebleeding, even though I had lost my Constant a few months before...)

    See ya in anotha' thread, brotha'!
    Last edited by abolibibelot; 25th Jan 2020 at 23:57.
    Quote Quote  
  7. nice road trip story. i watched the whole season and i liked it, however my mom is dying to watch it but she does not speak English that i why i need to add the Spanish audio to it, while there are Spanish websites where i can download content already with the work done for me, there couple reason why i want to do this myself.
    1) i already downloaded and have a given content.
    2) Spanish audios are made available from those said websites for this very same reason
    3) usually those website take a little longer to made content available than doing it myself (keep in mind am referring to new movies and tv show rather than old content).
    4) i like to control and have the best quality available and those website i would say dont have the best quality possible all the time. i will be watching some youtube videos on learning hot batch script mkvtoolnix and hope for the best, if you can send me some guide or info where i can learn about batch scripting i will appreciate it, thank you for taking the time to reply.
    Quote Quote  



Similar Threads

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