VideoHelp Forum
+ Reply to Thread
Results 1 to 25 of 25
Thread
  1. So apparently all my video converters cannot convert a MKV video if it has Opus audio. Google hasn't helped much, something about ffmpeg command lines and ffbatch. I tried ffbatch but it keeps asking for various different base files
    Windows 10, MPC-BE
    Quote Quote  
  2. Basic ffmpeg command to convert audio to aac:

    Code:
    ffmpeg -i filename.mkv -c:v copy -c:a aac output.mkv
    in a batch file (assuming all MKV files in the folder need converting):
    Code:
    for %%f in (*.mkv) do ffmpeg -i "%%f" -c:v copy  -c:a aac "%%f.aac.mp4"
    Quote Quote  
  3. I've never been good with the command line. I pasted ffmpeg to desktop and ran the line it says a dll file is missing
    Windows 10, MPC-BE
    Quote Quote  
  4. You should quote the entire error message.

    Make sure you have a ffmpeg with all the external libraries built in -- usually called a "static" build. Ffmpeg.exe should be something like 65 MB. If it's much smaller a bunch of dll are needed. The build from this site is a static build:

    https://www.videohelp.com/download/ffmpeg-4.3.1-win64-static.zip
    Quote Quote  
  5. Thanks that worked. For the batch command is it possible to make it a bat file? Maybe also pointing to mkv files on the desktop?
    Windows 10, MPC-BE
    Quote Quote  
  6. Originally Posted by Kracov View Post
    For the batch command is it possible to make it a bat file?
    What I gave you is the command for a batch file. Just paste that text into a batch file.

    Originally Posted by Kracov View Post
    Maybe also pointing to mkv files on the desktop?
    Just put the batch file on your Desktop and double click on it.
    Quote Quote  
  7. I created the batch file and clicking it opens cmd for an instant and disappears
    Windows 10, MPC-BE
    Quote Quote  
  8. I see now I have to move all ffmpegfiles on the desktop but is there a cleaner way via shortcuts?
    Windows 10, MPC-BE
    Quote Quote  
  9. Originally Posted by Kracov View Post
    I see now I have to move all ffmpegfiles on the desktop but is there a cleaner way via shortcuts?
    Just specify the full path to ffmpeg.exe in the batch file. I also recommend you put a pause at the end of the batch file so you can see any error messages. Something like:

    Code:
    for %%f in (*.mkv) do "c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%%f" -c:v copy  -c:a aac "%%f.aac.mp4"
    pause
    Change the path to wherever ffmpeg.exe is on your computer.
    Quote Quote  
  10. There's also that method if you intend to use it regularly.
    Quote Quote  
  11. Yes, you can edit the system PATH variable or put a copy of ffmpeg.exe anywhere in the current system PATH. I usually put one in C:\WINDOWS\SYSTEM32. That's where all the CLI exe files resize.
    Quote Quote  
  12. thanks guys. one last thing. the output name is good but can it be pointed to a dir as well?
    Windows 10, MPC-BE
    Quote Quote  
  13. Just change the output filename. For example, this will create a folder called New and encode the new file to that folder with the same name as the original file:

    Code:
    md New
    for %%f in (*.mkv) do "c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%%f" -c:v copy  -c:a aac "New\%%f"
    pause
    Quote Quote  
  14. That's where all the CLI exe files resize.
    Reside, you mean ?
    Quote Quote  
  15. Originally Posted by abolibibelot View Post
    That's where all the CLI exe files resize.
    Reside, you mean ?
    LOL. Yes.
    Quote Quote  
  16. "%%f.aac.mp4"
    Isn't the extension required as well? And wouldn't that folder be placed in the folder of ffmpeg? I tried your method and also tried using a full path to desktop but neither worked
    Windows 10, MPC-BE
    Quote Quote  
  17. Isn't the extension required as well?
    Not sure what you mean here. See this. “%%F” {*} gets expanded to each file's full path, including its extension, so if a file is named "dummy file name.mkv", the output with "%%F.aac.mp4" will be "dummy file name.mkv.aac.mp4". To replace the original extension with another (thus avoiding having several extensions in a row), it would be something like :
    Code:
    for %%F in (*.mkv) do "C:\wherever\ffmpeg\is located\ffmpeg.exe" -i "%%F" -c:v copy -c:a aac "%%~nF.mp4"
    It should be noted that ffmpeg's internal AAC encoder is generally considered inferior to some others (meaning : there are encoders which can better preserve the quality of the source at a given bitrate, or which can produce smaller files at a similar quality level). Apple's encoder is generally / currently considered as the reference, and is available in the form of qaac. But it gets more complicated, as two commands are necessary : 1) first convert the audio with qaac (using ffmpeg to load the audio stream and “pipe” it into qaac), 2) then mux the converted audio with the unchanged video.
    Code:
    ffmpeg -i "input.mkv" -vn -c:a pcm_s16le -f wav - | qaac - -o "audio.m4a"
    ffmpeg -i "input.mkv" -i "audio.m4a" -map 0:0 -map 1:0 -c:v copy -c:a copy "output.mkv"
    With the default settings qaac outputs files of excellent quality with an average bitrate usually slightly above 200kbps.
    But again it's more complicated, next level stuff. At least, if using ffmpeg's internal AAC encoder, it would be advised to specify a higher bitrate than the default 128kbps, by adding for instance “-b:a 192k”.
    Code:
    for %%F in (*.mkv) do "C:\wherever\ffmpeg\is located\ffmpeg.exe" -i "%%F" -c:v copy -c:a aac -b:a 192k "%%~nF.mp4"
    {*} It can be any letter — as long as the same letter is used everywhere in the command, and it's case-sensitive so for instance defining a "%%F" argument (upper case) and then calling it with "%%f" (lower case) wouldn't work.

    And wouldn't that folder be placed in the folder of ffmpeg?
    Not necessarily, if the full path to ffmpeg.exe is specified in the command, or if ffmpeg.exe is placed in a folder included in the system PATH (see above), then the command can be executed from anywhere. Or you mean the folder created with the “md” command ? It will be placed in the folder where the .bat script is located, unless specified otherwise in the script itself. For instance this would create a "New" folder on the desktop, because of the “CD” (= change directory) command at the beginning :
    Code:
    CD "C:\Users\[user name]\Desktop"
    md "New"
    It works if the .bat script is itself somewhere on C:\ ; if it's on another partition, then the drive letter has to be specified first.
    Code:
    C:
    CD "C:\Users\[user name]\Desktop"
    md "New"
    I tried your method and also tried using a full path to desktop but neither worked
    Then either copy the command and the output here, or upload a screenshot. (Don't forget to add “pause” at the end of the script.)
    Quote Quote  
  18. Originally Posted by Kracov View Post
    And wouldn't that folder be placed in the folder of ffmpeg?
    No, it will be created in the same folder as the batch file.

    I believe you can make up for ffmpeg's aac's inferior performance by specifying a higher bitrate than the default (128k). Something like "-b:a 192k".

    And you don't have to use aac at all. I just picked it because it's a commonly used audio codec.
    Last edited by jagabo; 30th Dec 2020 at 21:51.
    Quote Quote  
  19. Sorry, what I meant was that the folders, locations are inconvenient. I still have to put the mkvs in the ffmpeg folder and create a new folder on desktop for output. But not a big deal since mkvs with Opus audio is rare. I should email the converter people to tell them the apps need Opus support
    Windows 10, MPC-BE
    Quote Quote  
  20. Sorry, what I meant was that the folders, locations are inconvenient. I still have to put the mkvs in the ffmpeg folder and create a new folder on desktop for output.
    Again, no, it's more adaptable than that, actually with some experience it becomes more convenient than most GUI utilities. You can specify the complete path for all input files / folders, so as to run the command from anywhere, and get the output anywhere. Or, more simply, you can copy the .bat script only (it's a very small file) into the folder where the MKV/Opus files are located (you can also copy the ffmpeg.exe file but it's a bigger file and the only advantage is that you don't have to type its complete path in the .bat script {1}), it should work if the complete path to the executable is specified, or, again, if it's somewhere in the system PATH.
    With more experience one can type custom commands from the command prompt (it can be preferred if it's a simple command used once or very occasionally, otherwise creating a script is preferred for commands that are more complex or used regularly).
    There's also a way to make it so that a batch script processes any relevant file that is dragged-and-dropped onto its icon (so it can be put on the desktop for instance if used very often), this may be more convenient to you ; I have seen scripts meant to do that around here, but have never tried, someone may chime in to elaborate on that.

    I should email the converter people to tell them the apps need Opus support
    You can always do that {2}, but such utilities will always be lagging in available features compared with open source utilities with a very active developpement (while some such GUI utilities praised by newbies for their “convenience” can turn out to be not so safe, or not so good). Which one(s) are you using, if it's not an industrial secret ?

    @jagabo
    And you don't have to use aac at all. I just picked it because it's a commonly used audio codec.
    Depends on the purpose, but if the issue with Opus is for instance compatibility with a standalone device, then converting to AAC seems like the best choice, or even the only weasonable choice. Perhaps it's best not to add extra sources of confusion here ! (As I did when mentioning the intricacies of various AAC encoders... When I try to teach my mother something on tha computer I'm always tempted to mention several possible ways of doing the same thing, but she stops me right away : one way is enough for my little head, she says...)


    {1} There are enough copies of ffmpeg.exe on a video enthusiast's system nowadays, you don't want to create moar on your own...
    {2} I have been reporting the same bug to the developpers of Bulk Rename Utility for 2 years, it still hasn't been corrected... Just sent a rather pis*ed off message a few days ago when I tried the newest version and noticed with utter dismay that it was still there. (For those interested : when applying any name change, then undoing said operation, the files' timestamps get shifted back by 1 or 2 hour(s), apparently depending on the current DST settings ; and get shifted back again if another renaming operation is undone, and so forth ; this, despite the fact that any option pertaining to voluntarily modifying the timestamps is disabled. I noticed it first when doing a full comparison between my main all-purpose storage HDD and its backup — some files were detected as different by WinMerge in size + date analysis, and indeed the dates were shifted by 2 hours on the active HDD, sometimes 4 hours if I had undone two renaming operations...)
    Last edited by abolibibelot; 31st Dec 2020 at 04:13.
    Quote Quote  
  21. I tried AVC and Aimersoft VC and they didn't convert at all. I posted on here months ago for the same problem but I was looking for a VC that properly works with the styles in ASS subs. I believe I even tried Handbrake and mkvtoolnix and they did successfully "convert" but the videos were not playable on ps3, and still were not re-convertible in other apps. I have emailed them a few times already but maybe they don't care to modernize their apps for a fairly new audio format.
    Windows 10, MPC-BE
    Quote Quote  
  22. Originally Posted by Kracov View Post
    Sorry, what I meant was that the folders, locations are inconvenient. I still have to put the mkvs in the ffmpeg folder and create a new folder on desktop for output.
    With the bat file I gave in post #13 (once you've changed the path to ffmpeg.exe) all you have to do is copy the batch file to the folder full of MKV files you want to convert, then double click on it.

    Originally Posted by Kracov View Post
    But not a big deal since mkvs with Opus audio is rare.
    To quickly convert individual files you can put this batch file in your SendTo folder with the name ConvertAudioToAAC.bat. You only have to do this once. Then in Explorer you can right click on any video file and select Send To -> ConvertAudioToAAC.bat.

    Code:
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%~dpnx1" -c:v copy  -c:a aac "%~dpn1.aac%~x1"
    A new file will be created in the same folder with the same name but wth ".aac" added. For example, MyVideo.mkv will become MyVideo.aac.mkv. Again, you have to change the path to ffmpeg.exe.
    Quote Quote  
  23. MKVToolNix (GUI for mkvmerge which can also be used through command line) doesn't reencode anything by design, it only allows to add or reorganize streams in MKV files. It should be fully compatible with ASS subtitles, and seemingly has been for a long time (the MKV movie that is mentioned in this thread was generated with a 2015 build of mkvmerge, and it contains ASS files of a sophistication level I had never encountered before, with for instance translated rotated newspaper titles that move in perfect sync with the backward zoom + left travelling, truly awesome work).
    Handbrake, on the other hand, always reencodes video streams (only the audio can be copied unchanged in “pass through” mode), so it's not ideal for this particular task (you only want to convert the audio, converting the video as well would unnecessarily degrade the quality while also taking much longer).
    A video converted by Handbrake which is not playable on a (relatively old) standalone device : may be related with a “variable framerate” flag. Or an out of specifications AVC profile. Someone may elaborate on that.
    “AVC” AFAIK is the generic name of the H.264 codec (Advanced Video Codec), it would be surprising if a video conversion utility had that exact name. Don't know about Aimerfoft VC.
    If you absolutely, positively want a GUI, then perhaps the oft mentioned (by its author it would seem) clever FFmpeg GUI may suit your needs (disclaimer : I haven't tried it).


    @jagabo
    Code:
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%~dpnx1" -c:v copy  -c:a aac "%~dpn1.aac%~x1"
    And so that's also the kind of script that also works by dragging-and-dropping files onto the icon ? Just using “1” instead of a letter means “whatever file is provided as an input ? Also, is it necessary to specify “%~dpnx1” instead of simply “%1” ? Actually, shouldn't it be a double “%%” here ? (As far as I know using %% instead of % is always required in batch scripts, as opposed to commands executed from the command prompt.)
    Last edited by abolibibelot; 31st Dec 2020 at 08:07.
    Quote Quote  
  24. Originally Posted by abolibibelot View Post
    @jagabo
    Code:
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%~dpnx1" -c:v copy  -c:a aac "%~dpn1.aac%~x1"
    And so that's also the kind of script that also works by dragging-and-dropping files onto the icon ?
    Yes.

    Originally Posted by abolibibelot View Post
    Just using “1” instead of a letter means “whatever file is provided as an input ?
    It means argument #1 on the command line. Drag/drop or SendTo is the equivalent of typing the command with with the filename as argument #1. If you drag/drop multiple files they will be %1, %2, %3, etc.

    Originally Posted by abolibibelot View Post
    Also, is it necessary to specify “%~dpnx1” instead of simply “%1” ?
    No, but I used the former for consistency with the output filename. Also, %1 will already have quotes if there is a space in the filename. "%1" will then have two quotes ""x:\the path\to\filename.ext"" and will fail. %dpnx1 will never have quotes so you have to supply your own. "%dpnx1".

    Originally Posted by abolibibelot View Post
    Actually, shouldn't it be a double “%%” here ? (As far as I know using %% instead of % is always required in batch scripts, as opposed to commands executed from the command prompt.)
    %% is required in a for loop in a batch file. % works when there is no for loop.
    Quote Quote  



Similar Threads

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