VideoHelp Forum




+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 31 to 52 of 52
  1. If I understand you correctly I made the following script:

    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
    As expected the script failed because the video has a -120ms delay. The script only works on videos without a delay.
    Quote Quote  
  2. Originally Posted by poisondeathray View Post
    Originally Posted by MrBiggles View Post
    Source 2GB video is in 1st post which I've updated. It's MKV 1080i h264 with WAV. I would ideally like the video copied and the audio re-encoded to WAV. But you could use any video to test your script. If that's not possible then the audio encoded to AAC max bitrate would be fine. Post 22 or 25 has different scripts so perhaps you could modify those or do whatever you feel is best.
    If it's already h.264 with wav, why re-encode the audio to wav ? That does nothing - it's already uncompressed pcm wav
    Because I just want to see if it works. Could you indulge me please.
    Quote Quote  
  3. Originally Posted by MrBiggles View Post
    Originally Posted by poisondeathray View Post
    Originally Posted by MrBiggles View Post
    Source 2GB video is in 1st post which I've updated. It's MKV 1080i h264 with WAV. I would ideally like the video copied and the audio re-encoded to WAV. But you could use any video to test your script. If that's not possible then the audio encoded to AAC max bitrate would be fine. Post 22 or 25 has different scripts so perhaps you could modify those or do whatever you feel is best.
    If it's already h.264 with wav, why re-encode the audio to wav ? That does nothing - it's already uncompressed pcm wav
    Because I just want to see if it works. Could you indulge me please.
    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.
    Quote Quote  
  4. 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
    Quote Quote  
  5. 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
    Quote Quote  
  6. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "output0.wav" -c:a pcm_s16le -ac 2 -ar 48000 "output.wav"

    Epic!

    Quote Quote  
  7. Originally Posted by poisondeathray View Post
    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.
    Quote Quote  
  8. 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.
    1) What happens when you don't convert wav to wav ?

    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?
    How is that even possible ? If you are starting with h.264/wav/mkv it will thrown an error. Or there are some steps or information you are not mentioning, or maybe a switcharoo with different videos ?

    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?
    Obviously part of the problem is megui. That was conclusively proven in the other thread. Even if you "fix" the audio, it will mess up the delay because it's reading the delay value off mediainfo

    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?
    Are you sure MKV, not TS ? Are you sure AAC not AC3 ?

    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.
    Quote Quote  
  9. 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?
    How is that even possible ? If you are starting with h.264/wav/mkv it will thrown an error. Or there are some steps or information you are not mentioning, or maybe a switcharoo with different videos ?

    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"
    Quote Quote  
  10. Originally Posted by MrBiggles View Post
    Yes it's in sync before MeGUI but it has 200ms delay.

    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"
    Quote Quote  
  11. I wanted to use NeroAACCodec-1.5.1. What would the script be for that?
    Quote Quote  
  12. Originally Posted by MrBiggles View Post
    I wanted to use NeroAACCodec-1.5.1. What would the script be for that?


    For nero - if you have an input WAV source, it's just "-if" for input file, "-of" for output file, "-br" for bitrate, in bits/s e.g. 256000 for 256kbps

    Code:
    neroAacEnc.exe -if "input.wav" -br 256000 -of "output.aac"
    Quote Quote  
  13. 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
    Is that correct? I assume the underlined part is wrong because the script gives a video with no audio.
    Quote Quote  
  14. 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).
    Quote Quote  
  15. Thanks for your help. I tried everything, the only thing that works is converting the MKV WAV to TS AC3 (any other audio format such as AAC or WAV doesn't work). Then I can demux and remux the TS file OR encode it with MeGUI and it will still by in sync.
    Quote Quote  
  16. 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
    Quote Quote  
  17. 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
    Quote Quote  
  18. 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?
    Quote Quote  
  19. " Levelator? " not sure, I've never heard of it
    Quote Quote  
  20. Originally Posted by MrBiggles View Post
    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.
    http://www.blogarithms.com/2010/01/07/levelator-2-0/
    Quote Quote  
  21. 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
    What do I add to the script to delete all files once the script has finished except the x264 and Wav?
    Quote Quote  
  22. Originally Posted by MrBiggles View Post

    What do I add to the script to delete all files once the script has finished except the x264 and Wav?



    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
    Quote Quote  



Similar Threads

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