VideoHelp Forum

Try DVDFab and copy Ultra HD Blu-rays and DVDs! Or rip iTunes movies and music! Download free trial !
+ Reply to Thread
Results 1 to 28 of 28
Thread
  1. Hello.
    I'm currently using ffmpeg to convert my mkv files with e-ac3 audio to ac3, with this command line:

    Code:
    ffmpeg  -hwaccel auto -y -i "input.mkv" -map 0 -c:s copy -c:v copy -c:a ac3 -b:a 640k "output.mkv"
    It works great, but it takes a long time when you have more than 1 file. So do you if there is a way to batch convert several files, instead of opening a different command line each time?

    Thank you.
    Quote Quote  
  2. for %a in (*.mkv) do ffmpeg -y -i "%a" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "output_%~na.mkv"

    ("%%" instead of "%" if in a batch file)
    Quote Quote  
  3. Sorry, can you explain in more details? I don't get what to do (I'm still a beginner). Thanks.
    Quote Quote  
  4. Originally Posted by Nico Darko View Post
    Sorry, can you explain in more details? I don't get what to do (I'm still a beginner). Thanks.
    Just create new script with provided example.
    btw '-hwaccel auto' will not increase any speed...

    Code:
    for %%a in (*.mkv) do ffmpeg -y -i "%%a" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "output_%%~na.mkv"
    Quote Quote  
  5. I'm sorry, I know nothing about coding, I was simply given the instructions to do that one conversion, and it worked. But where do I enter the files names in that code? I have 12 in the same folder.

    Sorry if I'm a pain.
    Quote Quote  
  6. You don't enter file names at all. The "for" command will automatically pick up and enter the file names for you in a loop.
    Quote Quote  
  7. Ok, that's what I thought, but I entered your command line, but it's not working, it says %%a was unexpected.
    Quote Quote  
  8. If you are entering in command line use single %
    In batch file %% (double)
    Quote Quote  
  9. OK! Now it's working! Thank you!!
    Quote Quote  
  10. Member
    Join Date
    Nov 2017
    Location
    Madrid, Spain
    Search PM
    You can use this tool in the future for batch converting and saving your ffmpeg long presets:
    FFmpeg Batch
    Quote Quote  
  11. Member pumpysworld's Avatar
    Join Date
    Feb 2006
    Location
    The Wasteland
    Search Comp PM
    I also used the freeware Xmedia Recode to convert the audio tracks of MKVs. I set it to copy (not convert) the video and converted the audio to AC3.
    Quote Quote  
  12. Just wanted to share this. I am running Ubuntu Linux and none of the above solutions worked for me. I combined stuff and now works like a charm. It just takes a few seconds to convert large files. Hope This Helps for others

    Code:
    #!/bin/bash
    for f in *.mkv; do ffmpeg -y -i "$f" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "${f%.*}-ac3.mkv"; done
    Quote Quote  
  13. Originally Posted by pandy View Post
    Just create new script with provided example.
    btw '-hwaccel auto' will not increase any speed...

    Code:
    for %%a in (*.mkv) do ffmpeg -y -i "%%a" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "output_%%~na.mkv"
    Hi,
    I'm still using this script and it works great. But now I need to do the same thing only I just need the output file to be the converted ac3 audio, not the whole mkv file. Is there a way to change the script to do that?
    Thanks.
    Quote Quote  
  14. Try ..

    Code:
    for %%a in (*.mkv) do ffmpeg -i "%%a"  -c:a ac3 -b:a 640k "output_%%~na.ac3"
    pause
    責任者
    Quote Quote  
  15. That's perfect, it works. Thank you!
    Quote Quote  
  16. I have another request (maybe I should open a new thread). Can I use the same command line to convert the audio to ac3 and convert it from 25 fps to 23.976 fps at the same time?
    If not, is there at least a script to convert the audio to a different frame rate?

    Thanks.
    Quote Quote  
  17. try

    Code:
    for %%a in (*.ac3) do ffmpeg -y -i "%%a" -map 0:0 -af "atempo=0.959040" -vn -c:a ac3 -b:a 640k -ar 48000 "%%~na.new.ac3"
    責任者
    Quote Quote  
  18. It works! thank you.
    Quote Quote  
  19. Actually it didn't work properly, I need to convert the audio to eliminate the PAL speed-up, it is originally NTSC, but your command line seems to have slowed down the files to 23.976 fps but kept the same pitch as it was at 25 fps, it sounds the same! What is the way to just restore the NTSC tempo and pitch?
    Quote Quote  
  20. Try something like:
    Code:
    -af asetrate=48000*(24000/(1001*25)),aresample=48000
    (48000 Hz being the sample rate of the input and output.)
    Last edited by sneaker; 12th Apr 2020 at 06:33. Reason: 48000 Hz not kHz
    Quote Quote  
  21. That one does the job, thank you!
    I might as well use this to batch convert the videos to 23.976 fps as well, do you know what the full command line for that would be?
    Last edited by Nico Darko; 12th Apr 2020 at 16:12.
    Quote Quote  
  22. Originally Posted by pandy View Post
    Just create new script with provided example.
    btw '-hwaccel auto' will not increase any speed...

    Code:
    for %%a in (*.mkv) do ffmpeg -y -i "%%a" -map 0 -c:v copy -c:a ac3 -b:a 640k -c:s copy "output_%%~na.mkv"
    Hi,
    Does someone know if I can add a command line to that one, within the same script, to remove one of the two audio tracks of the mkv (and only convert the second one to AC3)?

    Thank you.
    Quote Quote  
  23. Code:
    for %%a in (*.mkv) do ffmpeg -y -i "%%a" -map 0:v -map 0:a:1 -map 0:s? -c:v copy -c:a ac3 -b:a 640k -c:s copy "output_%%~na.mkv"
    (Map video from first input file. Map second audio from first input file. Map subtitles from first input file if they exist.)
    https://trac.ffmpeg.org/wiki/Map
    Quote Quote  
  24. Perfect, thank you!
    Quote Quote  
  25. Originally Posted by sneaker View Post
    Try something like:
    Code:
    -af asetrate=48000*(24000/(1001*25)),aresample=48000
    (48000 Hz being the sample rate of the input and output.)
    What would it be to go from 23.976 to 25fps? and with aac audio?

    Edit: I've just tried:

    for %%a in (*.aac) do ffmpeg -y -i "%%a" -map 0:0 -af asetrate=48000*(25000/(1001*24)),aresample=48000 "%%~na.new.aac"

    It seems to have worked, but it reduced the bitrate from 192kbs to 130kbs
    Last edited by Nico Darko; 7th May 2020 at 12:02.
    Quote Quote  
  26. Code:
    -af asetrate=48000*((25*1001)/24000)),aresample=48000
    Audio codec does not matter for this part. (Set -c:a aac if you want to encode output to AAC).

    But maybe for PAL-Speedup keeping pitch using -atempo as suggested by sekininsha is a better solution?
    Quote Quote  
  27. Originally Posted by sneaker View Post
    Code:
    -af asetrate=48000*((25*1001)/24000)),aresample=48000
    Audio codec does not matter for this part. (Set -c:a aac if you want to encode output to AAC).

    But maybe for PAL-Speedup keeping pitch using -atempo as suggested by sekininsha is a better solution?
    This one is actually to correct a PAL original show slowed down to NTSC, so I need to fix the pitch as well.

    I added "-c:a aac" but the bitrate is still reduced.
    Quote Quote  
  28. Ok, I added "-b:a 192k", that did the trick.

    Thank you.
    Quote Quote  



Similar Threads