If I understand you correctly I made the following script:
As expected the script failed because the video has a -120ms delay. The script only works on videos without a delay.Code:"C:\Portable Installations\FFMPEG\bin\ffmpeg.exe" -i %1 -c:v copy -c:a pcm_s16le "%~d1%~p1%~n1.MKV.mkv" "C:\Sounds\VideoRedo Completed Sound Short.WAV" pause
+ Reply to Thread
Results 31 to 52 of 52
-
-
-
Sure - it's the same thing, just change it to wav instead of ac3
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.wav" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\Temp\output0.wav" -vn -c:a pcm_s16le -ac 2 -ar 48000 "E:\2 = New\Temp\output.wav" "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.wav" ")" "--track-order" "0:0,1:0" del "E:\2 = New\Temp\video.h264" del "E:\2 = New\Temp\output0.wav" del "E:\2 = New\Temp\output.wav" pause )
The reason why it might produce a difference, is because of mkvextract for the reasons mentioned earlier . It's not the encoding wav to wav doing anything (that's a no-op), it's because it was demuxed with mkvextract
You can test that by omitting the ffmpeg line - this would be a straight demux, remux
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.wav" "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\output0.wav" ")" "--track-order" "0:0,1:0" del "E:\2 = New\Temp\video.h264" del "E:\2 = New\Temp\output0.wav" pause
Last edited by poisondeathray; 1st Jun 2015 at 14:01.
-
Sorry bud I just remembered that muxing to MKV with that script is no good as you get the delay back when you mux to mkv which is why I used the below script to mux to TS: Could you please modify this script like you did before so a MKV h264 Wav is converted to TS WAV. Thanks
Code:"X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks %1 0:"video.h264" 1:"gain0.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "gain0.m4a" -vn -c:a copy -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 "output.ac3" SET tsmuxer="X:\Portable Installations\tsMuxeR_1.10.6\tsMuxeR.exe" echo MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500 > remux.meta echo V_MPEG4/ISO/AVC, "video.h264", insertSEI, contSPS >> remux.meta echo A_AC3, "output.ac3" >> remux.meta %tsmuxer% remux.meta "%~d1%~p1%~n1.AC3.ts" DEL /Q remux.meta del gain.m4a del gain0.m4a del video.h264 del output.ac3 "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
-
Sure , I left the PCM WAV to PCM WAV re-encode step in there, but it shouldn't be necessary. Just in case you think it's doing something or you have time to waste
Code:"X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks %1 0:"video.h264" 1:"output0.wav" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "output0.wav" -c:a pcm_s16le -ac 2 -ar 48000 "output.wav" SET tsmuxer="X:\Portable Installations\tsMuxeR_1.10.6\tsMuxeR.exe" echo MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500 > remux.meta echo V_MPEG4/ISO/AVC, "video.h264", insertSEI, contSPS >> remux.meta echo A_LPCM, "output.wav" >> remux.meta %tsmuxer% remux.meta "%~d1%~p1%~n1.AC3.ts" DEL /Q remux.meta del output0.wav del output.wav del video.h264 pause
-
This is bizarre. Using your script to mux to TS and convert wav to wav gives -200ms delay. Encoding that to MeGUI gives a video without sound. The MKV script gave a video that was out of sync when I encoded it in MeGUI.
I used the original AAC to AC3 script and got no delay. Encoded that with MeGUI and got 200ms delay but it was IN SYNC. Why do I get a file that's in sync when using the AAC to AC3 script but using the modded script to convert to Wav gives a delay?
Also I tried adding a +120ms delay to the wav in an audio editor (via the "Delay" menu) to remove the -120ms delay but when I muxed the files back it still had a -120ms delay. Encoding that with MeGUI gave the same problems as before. Perhaps I've added the delay wrong? Is there an audio editor you can suggest that will work?
The only thing I can think of that will work to prevent losing too much quality is using the AAC to AC3 script below (same script you modded before). That works so maybe you could please change it to convert MKV WAV to MKV AAC 1024 Kbps?
Code:"X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks %1 0:"video.h264" 1:"gain0.m4a" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "gain0.m4a" -vn -c:a copy -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 "output.ac3" SET tsmuxer="X:\Portable Installations\tsMuxeR_1.10.6\tsMuxeR.exe" echo MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500 > remux.meta echo V_MPEG4/ISO/AVC, "video.h264", insertSEI, contSPS >> remux.meta echo A_AC3, "output.ac3" >> remux.meta %tsmuxer% remux.meta "%~d1%~p1%~n1.AC3.ts" DEL /Q remux.meta del gain.m4a del gain0.m4a del video.h264 del output.ac3 "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
Last edited by MrBiggles; 1st Jun 2015 at 16:44.
-
This is bizarre. Using your script to mux to TS and convert wav to wav gives -200ms delay. Encoding that to MeGUI gives a video without sound. The MKV script gave a video that was out of sync when I encoded it in MeGUI.
2) Is the audio in sync in the TS before megui ?
3) HOW are you determining there is a delay, and the +/- delay value ? Is this an AUDIO delay or VIDEO delay ? Does the audio come before the pictures or after ? (e.g. watch when people speak) in a media player for the TS file before megui , and the file exported from megui
I used the original AAC to AC3 script and got no delay. Encoded that with MeGUI and got 200ms delay but it was IN SYNC. Why do I get a file that's in sync when using the AAC to AC3 script but using the modded script to convert to Wav gives a delay?
One possible explanation for a minor delay (maybe in the order of ~40ms, but not 200ms ) is compressed audio will always have delay compared to uncompressed audio . Typical AAC encoder delay will be ~40ms, and ~20ms for AC3 . ~20 ms is not distinguisable for most humans, but ~40ms is on the cusp .
Also I tried adding a +120ms delay to the wav in an audio editor (via the "Delay" menu) to remove the -120ms delay but when I muxed the files back it still had a -120ms delay. Encoding that with MeGUI gave the same problems as before. Perhaps I've added the delay wrong? Is there an audio editor you can suggest that will work?
And why 120ms when you said 200ms earlier ? Some things in your statements don't add up . Or is this for something else ?
The only thing I can think of that will work is using the AAC to AC3 script below (same script you modded before). That works so maybe you could please change it to convert MKV WAV to MKV AAC 1024 Kbps?
You should be able to modify it yourself from the examples posted. But I don't know what the maximum AAC bitrate is for ffmpeg's AAC encoder. In the other thread, the AAC audio wasn't encoded, only replaygain (metadata). Only the AC3 audio was encoded. -
1) What happens when you don't convert wav to wav ?
When I don't convert Wav to Wav and then re-encode with MeGUI the video has no sound. Yes it's in sync before MeGUI but it has 200ms delay.
I used the original AAC to AC3 script and got no delay. Encoded that with MeGUI and got 200ms delay but it was IN SYNC. Why do I get a file that's in sync when using the AAC to AC3 script but using the modded script to convert to Wav gives a delay?
I was referring to if I re-encode MKV Wav to AAC in Videoredo and then use the AAC to AC3 script.
One possible explanation for a minor delay (maybe in the order of ~40ms, but not 200ms ) is compressed audio will always have delay compared to uncompressed audio . Typical AAC encoder delay will be ~40ms, and ~20ms for AC3 . ~20 ms is not distinguisable for most humans, but ~40ms is on the cusp .
And why 120ms when you said 200ms earlier ? Some things in your statements don't add up . Or is this for something else ?
You get different delay in TSmuxer and MKVMerge.
What would I use instead of the line below to convert Wav to AAC 400 Kbps:
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "output0.wav" -c:a pcm_s16le -ac 2 -ar 48000 "output.wav"
-
It's in sync before megui, how are you determining that there is an actual delay ? don't tell me megui or mediainfo
If you demux, then remux without any delay specified in the any muxer , and it's in sync, there is no actual muxing delay. That is the very definition of "in sync and no delay". That means audio and video are perfectly aligned.
If you have good streams (or are able "fix" an actual delay by adding silence if it's a (+) audio delay) you should be able to workaround that megui bug by loading elementary (separate) video and audio streams into megui . Since the problem is reading the container delay value from mediainfo, separate streams shouldn't have a delay (but if they have a "delay_xxx_ms" or something written into the flename from another demuxer, then megui will apply the appropriate delay). Or use something other than megui
What would I use instead of the line below to convert Wav to AAC 400 Kbps:
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "output0.wav" -c:a pcm_s16le -ac 2 -ar 48000 "output.wav"
I don't know what the max bitrate is for ffmpeg's aac encoder, maybe 256k ? Try a higher value if you want, Also try a high frequency cutoff, i think it cuts off higher frequencies by default. It's not a very good AAC encoder
-c:v libvo_aacenc specifies the free AAC encoder
-b:a 256k means 256 kbps audio bitrate
-cutoff 20000 means 20000Hz cutoff (I think default is like 16000 or something if you don't set it, which might be ok for lower bandwith quality internet streams, but not for higher quality encodes)
note the extension has changed from output.wav to output.aac
Code:"X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "output0.wav" -c:a libvo_aacenc -ac 2 -ar 48000 -b:a 256k -cutoff 20000 "output.aac"
-
I tried with the libav script and it gave a video without sound. Moving on, I have this for the Nero script:
Code:"X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks %1 0:"video.h264" 1:"output0.wav" "X:\Portable Installations\NeroAACCodec-1.5.1\win32\neroAacEnc.exe -if "output0.wav" -br 256000 -of "output.aac" SET tsmuxer="X:\Portable Installations\tsMuxeR_1.10.6\tsMuxeR.exe" echo MUXOPT --no-pcr-on-video-pid --vbr --vbv-len=500 > remux.meta echo V_MPEG4/ISO/AVC, "video.h264", insertSEI, contSPS >> remux.meta echo A_LPCM, "output.aac" >> remux.meta %tsmuxer% remux.meta "%~d1%~p1%~n1.aac.ts" DEL /Q remux.meta del output0.wav del output.aac del video.h264 pause
-
Change it to A_AAC for tsmuxer for aac audio
Here are the codes for the tsmuxer meta file
Names of codecs in the meta file:
V_MPEG4/ISO/AVC - H264
V_MS/VFW/WVC1 - VC1
V_MPEG-2 - MPEG2
A_AC3 - DD (AC3) / DD (E-AC3) / True HD (True HD only tracks with AC3 core inside).
A_AAC - AAC
A_DTS - DTS / DTS-HD
A_MP3 - MPEG audio layer 1/2/3
A_LPCM - raw pcm data or PCM WAVE file
S_HDMV / PGS - subtitle format presentation graphic stream.
S_TEXT/UTF8 - subtitle format SRT. The text file should be in unicode. Any formats: UTF-8, UTF-16 (little-endian, big-endian), UTF-32 (little-endian, big-endian).
-
For videos that are in sync to start off with I'm going to use a script to demux the video and convert the AAC to WAV. So I will end up with a separate WAV and h264 file. This is what I've got so far. It's working but it's giving me an empty wav file. Also after completion the script just makes a beeping sound until I close FFMPEG in Task Manager. I don't want it to do that. I want it to end without that happening and to open an audio file so I know it's finished.
Also do you know how to change the script so that the h264, wav and aac files generated match the name of the source video?
Code:for %%a in ("*.mkv") do ( "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"E:\2 = New\video.h264" 1:"E:\2 = New\output0.aac" "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "E:\2 = New\output0.aac" -vn -c:a pcm_s16le -ac 2 -ar 48000 -f wav - "E:\2 = New\output.wav" ) "X:\Daves Folder\Sounds\VideoRedo Completed Sound Short.WAV" pause
-
That "-" before the output file is for a pipe, but you're not piping to another program so you get no wav
Here is the basic script without any paths or directories, just add them where you want the temp files or binaries . Currently , the same folder is used
Code:for %%a in ("*.mkv") do "mkvextract.exe" --ui-language en tracks "%%a" 0:"%%~na.h264" 1:"%%~na.aac" for %%b in ("*.aac") do "ffmpeg.exe" -i "%%b" -vn -c:a pcm_s16le -ac 2 -ar 48000 -f wav "%%~nb.wav" pause
-
Thanks. It's working now. I was wondering if you know how to get "The Levelator" working in a command line so I can add it to the script so it normalizes the wav?
-
It can't be done:
It will likely never have a command-line interface, but not because anyone is withholding one. It’s just that the parameters to the algorithm aren’t related to how one normally thinks of theses things. -
So I've got this script which demuxes the video and AAC and converts the AAC to wav. It puts the files in the same folder as the source.
Code:for %%a in ("*.mkv") do "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"%%~na.h264" 1:"%%~na.aac" for %%b in ("*.aac") do "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%b" -vn -c:a pcm_s16le -ac 2 -ar 48000 -f wav "%%~nb.wav" "D:\VideoRedo Completed Sound Short.WAV" pause
-
Did you mean delete all aac files ? Because you probably don't want to delete the originals?
del *.aac
Be careful about deleting things. Some people like to separate things into different named folders and temp folders so it's more organized and as anotehr layer of security. Also if you have multiple HDD's is faster to read and write to different HDD's
Similar Threads
-
Can 720p 50fps be converted back to 1080i?
By VideoFanatic in forum RestorationReplies: 3Last Post: 5th Feb 2015, 10:52 -
Muxing m2v and wav
By SameSelf in forum Video ConversionReplies: 8Last Post: 18th Aug 2014, 14:09 -
joined video plays back fast
By bsimon in forum EditingReplies: 1Last Post: 9th Nov 2012, 02:54 -
MKV video plays with artifacts on TV
By mateus560276 in forum Software PlayingReplies: 4Last Post: 3rd Jan 2012, 17:05 -
1080i .TS Video file to Blu-ray .ISO file Help !
By SiNnOFf in forum Authoring (Blu-ray)Replies: 19Last Post: 3rd Nov 2010, 13:12