That's weird. Your TS batch script worked on my test clip here: https://www.dropbox.com/s/08nflm8k91kge5k/TS%20clip.ts
However the demuxed AAC file has slowdown!: https://www.dropbox.com/s/jpg8tk9qp9c2mos/TS%20clip.aac
How the heck would that happen to the demuxed AAC but not to the MKV AC3 output which is where the AAC came from?
I tested the clip with my non-batch TS script and that never caused any problems.
I tested the same clip but in MKV format and the MKV batch script never caused any problems.
Regarding the MPEG2 script in post 148: You told me before that the easiest way to get the AAC file for feeding the script is to just save the Video in VideoRedo choosing to re-encode to AAC. That's fine for h264 but VideoRedo doesn't support saving to AAC for standard definition MPEG2 videos. So in the MPEG2 script before the audio portions of the script runs I'd like to add a command to convert the AC3/MPA of the MPEG2 to AAC.
+ Reply to Thread
Results 151 to 180 of 199
-
-
I don' t know about the slowdown, I'll take a look later
For the other one you already have AAC. Source is MPEG2+AAC . What am I missing ?
This script is MPEG2 AAC to MPEG2 AC3 128 + Demux AAC. -
For the MPEG2 script what happens if the source is MPEG2 + AC3/MPA? I need to add something to the top of the script to convert AC3/MPA to AAC before the rest of the script can run. At the moment the script assumes the source is MPEG2 + AAC.
-
If you're starting with MPEG2+AC3 or MPEG2+MP2, use -c:a libvo_aacenc -b:a 128k (or whatever bitrate you want) to enccde to AAC, instead of -c:a copy to stream copy if you are using ffmpeg
-
For the speed issue, not sure why splitting out the ffmpeg command works. It should give you the same thing when using -map with 2 outputs in 1 line
Code:for %%a in ("*.ts") do ( eac3to "%%a" 1:"video.h264" ffmpeg -i "%%a" -vn -c:a copy -absf aac_adtstoasc "gain.m4a" aacgain -r -k -m 0 "gain.m4a" ffmpeg -i "gain.m4a" -vn -c:a copy "%%~da%%~pa%%~na.aac" ffmpeg -i "gain.m4a" -vn -c:a ac3 -b:a 128k "output.ac3" mkvmerge -o "%%~da%%~pa%%~na.AC3.mkv" "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "video.h264" ")" "--language" "0:eng" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "output.ac3" ")" "--track-order" "0:0,1:0" del "gain.m4a" del "video.h264" del "output.ac3" ) pause
-
Thanks. OK so this is what I've got for the MPEG2 script:
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i %1 -map 0:0 -map 0:1 -c:v copy -an "copy.m2v" -vn -c:a libvo_aacenc -b:a 400k -absf aac_adtstoasc "gain.m4a" "X:\Portable Installations\AAC Gain 1.9\aacgain" -r -k -m 0 gain.m4a "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i gain.m4a -map 0:0 -vn -c:a copy "%~d1%~p1%~n1.aac" -map 0:0 -vn -c:a ac3 -b:a 128k "128kbps_ac3.ac3" "X:\Portable Installations\MJPEG Tools\bin\mplex.exe" -o "%~d1%~p1%~n1.AC3.mpg" "copy.m2v" "128kbps_ac3.ac3" -f 3 del "copy.m2v" del "128kbps_ac3.ac3" del "gain.m4a" "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
-
Thanks the Batch TS script works and so does the MPEG non-batch script!
Now I'm trying to make a batch version of the MPEG2 script. This is what I've got however when I run the script nothing happens:
Code:for %%a in ("*.mpg") do ( "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%a" -map 0:0 -map 0:1 -c:v copy -an "E:\2 = New\Temp\copy.m2v" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -map 0:0 -vn -c:a copy "%~d1%~p1%~n1.aac" -map 0:0 -vn -c:a ac3 -b:a 128k "E:\2 = New\Temp\128kbps_ac3.ac3" "X:\Portable Installations\MJPEG Tools\bin\mplex.exe" -o "%~d1%~p1%~n1.AC3.mpg" "E:\2 = New\Temp\copy.m2v" "E:\2 = New\Temp\128kbps_ac3.ac3" -f 3 del "E:\2 = New\Temp\copy.m2v" del "E:\2 = New\Temp\128kbps_ac3.ac3" del "E:\2 = New\Temp\gain.m4a" "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
-
In batch mode with a .bat file, you need to use %%, not %. You have some instances where only % is used.
And you're missing the closing bracket ")"
To debug what is going wrong, just test 1 line at a time and look at the error message if any (REM out or delete all the other lines)
For example test this, check if it works out as expected. If it works ok, then add the next line
Code:for %%a in ("*.mpg") do ( "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%a" -map 0:0 -map 0:1 -c:v copy -an "E:\2 = New\Temp\copy.m2v" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" ) pause
-
So everywhere a % is used I should just use %% instead? I thought it was just the first line in the script that needed: "%%a"
-
Yes, for example, this
Code:"X:\Portable Installations\MJPEG Tools\bin\mplex.exe" -o "%~d1%~p1%~n1.AC3.mpg" "E:\2 = New\Temp\copy.m2v" "E:\2 = New\Temp\128kbps_ac3.ac3" -f 3
should be
Code:"X:\Portable Installations\MJPEG Tools\bin\mplex.exe" -o "%%~d1%%~p1%%~n1.AC3.mpg" "E:\2 = New\Temp\copy.m2v" "E:\2 = New\Temp\128kbps_ac3.ac3" -f 3
But more importantly, you missed the closing bracket, that's why it's not working -
I understand how to make the batch scripts now. I never really noticed before but as you say you need 2 percentage signs and also instead of "1" you need to use "a" and the closing bracket as well.
I've noticed that when using VidoeRedo to encode from h264 AC3 to AAC that some of the videos output have no sound or are out of sync for some reason even though I cut them properly so there shouldn't be a delay. I'd like to add the same thing that you added to the top of the MPEG2 script - convert the AC3 to AAC 320kbps before using the h264 TS or MKV batch script
In the TS script the first couple of line are like this:
Code:"X:\Portable Installations\eac3to\eac3to.exe" "%%a" 1:"E:\2 = New\Temp\video.h264" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "%%a" -vn -c:a copy -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a"
Code:"X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"E:\2 = New\Temp\video.h264" 1:"E:\2 = New\Temp\gain0.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain0.m4a" -vn -c:a copy -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a"
-
I'm confused on what you want to do
Don't the TS and MKV already start with AAC ? If you want to re-encode the audio (I don't know why) use the same thing -c:a libvo_aacenc -b:a 320k -cutoff 22000 , instead of -c:a copy -
Some of my videos have AC3 audio, I would use VideoRedo to convert to MKV with AAC but VideoRedo has some issues. Instead I need to convert to AAC in the script then do the other stuff as normal - convert to MKV + AC3 and demux AAC
Doesn't work with this script which works with MKV sources:
Code:for %%a in ("*.mkv") do ( "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"E:\2 = New\Temp\video.h264" 1:"E:\2 = New\Temp\gain0.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain0.m4a" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -map 0:0 -vn -c:a copy "%%~da%%~pa%%~na.aac" -map 0:0 -vn -c:a ac3 -b:a 128k "E:\2 = New\Temp\output.ac3" "X:\Portable Installations\MKV Toolnix\mkvmerge.exe" -o "%%~da%%~pa%%~na.AC3.mkv" "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\video.h264" ")" "--language" "0:eng" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\output.ac3" ")" "--track-order" "0:0,1:0" del "E:\2 = New\Temp\gain0.m4a" del "E:\2 = New\Temp\gain.m4a" del "E:\2 = New\Temp\video.h264" del "E:\2 = New\Temp\output.ac3" ) "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
Doesn't work with this script which works with TS sources:
Code:for %%a in ("*.ts") do ( "X:\Portable Installations\eac3to\eac3to.exe" "%%a" 1:"E:\2 = New\Temp\video.h264" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "%%a" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -vn -c:a copy "%%~da%%~pa%%~na.aac" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -vn -c:a ac3 -b:a 128k "E:\2 = New\Temp\output.ac3" "X:\Portable Installations\MKV Toolnix\mkvmerge.exe" -o "%%~da%%~pa%%~na.AC3.mkv" "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\video.h264" ")" "--language" "0:eng" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\output.ac3" ")" "--track-order" "0:0,1:0" del "E:\2 = New\Temp\gain.m4a" del "E:\2 = New\Temp\video.h264" del "E:\2 = New\Temp\output.ac3" ) "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
-
Tell me what the input files are.
If the 1st one is MKV with AC3 audio, then obviously you can't extract AAC directly from mkvextract "gain0.m4a" - because it doesn't exist! You would have to extract AC3. Similarly the next line with ffmpeg won't use "gain0.m4a" as input, because it was never extracted in the first place
If you change those instances to "somename.ac3", it should work for the 1st 2 lines.
Just debug the scripts one line at a time as I told you above -
I just added the underlined line you told me to add!
OK for the MKV script I tried this:
Code:for %%a in ("*.mkv") do ( "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"E:\2 = New\Temp\video.h264" 1:"E:\2 = New\Temp\output.ac3" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\output.ac3" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" ) pause
-
The problem was I was running the batch file from the Temp folder and the video source was located there too. Not sure why that would make a difference to the script not running. Anyway, I've run the script properly now
Is there a way to get the script to write a log file so I can copy and paste the errors?
CMD says something about libvo_aac unable to set encoding parameters. Error while opening encoder for output. Maybe incorrect parameters. Those errors don't really help me as I already know the script doesn't work but it doesn't tell me how to fix it.
Those couple of lines look logical to me as I thought it's saying extract the h264 & AC3 then convert the AC3 to AAC.Last edited by VideoFanatic; 13th Aug 2014 at 08:53.
-
You should be able to copy & paste, but if you want each step to print a log, add 1>step1.log to the end of each line, or whatever name. ffmpeg uses 2>somename.log , and eac3to automatically prints a log .
After you figure everything out, don't forget to add del statements for the logs, or change the script if you don't want clutter
eg.
Code:for %%a in ("*.mkv") do ( "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"E:\2 = New\Temp\video.h264" 1:"E:\2 = New\Temp\output.ac3" 1>mkvextract.log "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\output.ac3" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" 2>ffmpeg1.log ) pause
Most common error is a typo. If it doesn't work, and you still can't figure it out, post a sample. It works on your other MKV/AC3 sample posted, maybe something is wrong with this other batch of files? -
Well you have to specify 2 channel -ac 2, but I can't recall if it does a proper downmix
There should be a "video.h264" as well
Post the error, post a sample -
Added -ac 2 to the script and the full script is now working.
Here's the MKV AC3 5.1 to AAC 2 channel to MKV AC3 2 channel script:
Code:for %%a in ("*.mkv") do ( "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"E:\2 = New\Temp\video.h264" 1:"E:\2 = New\Temp\output0.ac3" 1>mkvextract.log "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\output0.ac3" -vn -c:a libvo_aacenc -ac 2 -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" 2>ffmpeg1.log "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -map 0:0 -vn -c:a copy "%%~da%%~pa%%~na.aac" -map 0:0 -vn -c:a ac3 -b:a 128k "E:\2 = New\Temp\output.ac3" "X:\Portable Installations\MKV Toolnix\mkvmerge.exe" -o "%%~da%%~pa%%~na.AC3.mkv" "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\video.h264" ")" "--language" "0:eng" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\output.ac3" ")" "--track-order" "0:0,1:0" del "E:\2 = New\Temp\video.h264" del "E:\2 = New\Temp\output0.ac3" del "E:\2 = New\Temp\gain.m4a" del "E:\2 = New\Temp\output.ac3" ) "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause ) pause
Here's the TS AC3 5.1 to AAC 2 channel to MKV AC3 2 channel script:
Code:for %%a in ("*.ts") do ( "X:\Portable Installations\eac3to\eac3to.exe" "%%a" 1:"E:\2 = New\Temp\video.h264" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "%%a" -vn -c:a libvo_aacenc -ac 2 -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -vn -c:a copy "%%~da%%~pa%%~na.aac" "X:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -vn -c:a ac3 -b:a 128k "E:\2 = New\Temp\output.ac3" "X:\Portable Installations\MKV Toolnix\mkvmerge.exe" -o "%%~da%%~pa%%~na.AC3.mkv" "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\video.h264" ")" "--language" "0:eng" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "E:\2 = New\Temp\output.ac3" ")" "--track-order" "0:0,1:0" del "E:\2 = New\Temp\gain.m4a" del "E:\2 = New\Temp\video.h264" del "E:\2 = New\Temp\output.ac3" ) "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
-
I learned from starting out with various GUI's, looking at log files. But you have more control when you understand what is being done in the background, it's more versatile and powerful and you can customize to do exactly what you want
Yes, FFMpeg documentation is very messy, and they need better examples, but it can do almost everything (swiss army knife), so detailed documentation would be like dictionary -
Noticed something weird with the MPEG2 script that converts AC3 to AAC, Normalizes AAC, converts to AC3 then muxes AC3 with MPEG2.
The resulting audio has a slight distortion. Some clips are HERE.
- MPEG2 TS Clip Source with MPA Audio.
- MPEG2 TS Clip after used script on. This has a distortion in the last few secs in the copyright screen. As far as I can tell the rest of the audio is fine.
- MPEG2 TS Clip. MPA source to AAC DBpoweramp then to WAV then to WAV to AC3 Encoder
Is it something to do with the -cutoff 22000?
Here's the batch script I used:
Code:for %%a in ("*.ts") do ( "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%a" -map 0:0 -map 0:1 -c:v copy -an "E:\2 = New\Temp\copy.m2v" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "E:\2 = New\Temp\gain.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\gain.m4a" -map 0:0 -vn -c:a copy "%%~da%%~pa%%~na.aac" -map 0:0 -vn -c:a ac3 -b:a 128k "E:\2 = New\Temp\128kbps_ac3.ac3" "X:\Portable Installations\MJPEG Tools\bin\mplex.exe" -o "%%~da%%~pa%%~na.AC3.mpg" "E:\2 = New\Temp\copy.m2v" "E:\2 = New\Temp\128kbps_ac3.ac3" -f 3 del "E:\2 = New\Temp\copy.m2v" del "E:\2 = New\Temp\128kbps_ac3.ac3" del "E:\2 = New\Temp\gain.m4a" ) "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
Last edited by VideoFanatic; 14th Aug 2014 at 13:51.
-
Find out when the distortion occurs , at which step. Go step by step, examine the output
Is it a decoding issue, or encoding issue ? If you use uncompressed pcm wav, that will help determine if it's an encoding issue (since libvo_aacenc is considered "experimental" AAC encoder) -
Not sure what you mean about WAV.
It must be an encoding issue with AAC because I've used FFMPEG to convert MPA to AC3 before and AC3 plays back fine in MPC-HC.
The issue happens on the first line as follows:
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%a" -map 0:0 -map 0:1 -c:v copy -an "E:\2 = New\Temp\copy.m2v" -vn -c:a libvo_aacenc -b:a 320k -cutoff 48000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a"
Is it possible to use a better encoder instead of libvo_aacenc? How about Nero AAC Codec 1.5.4.0, that's considered to be the best AAC encoder isn't it? Any idea what script I should use for that?
That codec is what I used when I manually demuxed and converted the audio to AAC then I converted to WAV and then to AC3. It played back fine. -
Ok instead of libvo_aacenc, try -c:a pcm_s16le . That is uncompressed pcm wav . If that has distortion, then problem is DEcoding, not encoding. Rule that out first by checking "gain.wav"
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vn-c:a pcm_s16le "E:\2 = New\Temp\gain.wav"
libvo_aacenc is one of the only free AAC choices that can be compiled with ffmpeg. NeroAAC is definitely better, but cannot be distributed with ffmpeg, so you could pipe to Nero (or other "good" AAC encoders like QAAC, FDKAAC ) . Those are probably the top 3 AAC encoders. ffmpeg can be compiled with FDKAAC (so you don't have to pipe) but, you have to compile it yourself (not allowed to be publically distributed) -
Tried the WAV script and the audio was fine so it looks to be an AAC encoding issue.
I've heard that FDKAAC has bugs and isn't as good as NeroAAC.
Do you know how to modify the first line of my script as follows to use NeroAAC?:
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%a" -map 0:0 -map 0:1 -c:v copy -an "E:\2 = New\Temp\copy.m2v" -vn -c:a libvo_aacenc -b:a 320k -cutoff 22000 -absf aac_adtstoasc "E:\2 = New\Temp\gain.m4a"
-
Before you do that, do a quick test and try removing the -cutoff 22000 with the original script to m4a
-
Same thing. The reason we added the cutoff thing was because the demuxed AAC would have slowdown but the AC3 output did not.