Page 1 of 1

Batch extraction of audio streams

Posted: 24 Sep 2011 10:15
by JinF
Hello,

I have a bunch of MP4 files that I need to re-encode the audio of, so I decided to see if I could simply extract and encode it with VLC. It works when using the GUI with the options of RAW encapsulation, no video and AAC audio @128Kbit,2Channel,44100. All I do afterward is remux it and I am done. However I have over 300 files and doing this by hand would take forever, so I decided to see how to do batch work with VLC. I came up with the following script which I think uses the same settings as I see in the GUI, but the files it creates are broken. They are about 1MB smaller than the ones created with VLC by hand and will not play in any player. I know that VLC can do what I want because I made several extractions like this by hand, so it must be something in my script.

Code: Select all

@ECHO OFF FOR /R %%G IN (*.mp4) DO (CALL :SUB_VLC "%%G") GOTO :eof :SUB_VLC SET _firstbit=%1 SET _qt=" CALL SET _newnm=%%_firstbit:%_qt%=%% SET _commanm=%_newnm:,=_COMMA_% REM echo %_commanm% CALL "G:\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{vcodec="none",acodec="mp4a",ab="128","channels=2",samplerate="44100"}:standard{access="file",mux="raw",dst="%_commanm%.mp4"} vlc://quit PAUSE GOTO :eof :eof PAUSE
I've tried using --no-sout-video as well, but that didn't change anything. Any help is appreciated.

Re: Batch extraction of audio streams

Posted: 06 Oct 2011 00:45
by JinF
Nobody can see what the problem could be?

Re: Batch extraction of audio streams

Posted: 06 Oct 2011 20:50
by mederi
There is something wrong with the code. You have just created an endless loop as it adds new mp4 files in the same folder. I would make subfolder "OUTPUT" and direct results there.
What is this part supposed to do?

Code: Select all

SET _firstbit=%1 SET _qt=" CALL SET _newnm=%%_firstbit:%_qt%=%% SET _commanm=%_newnm:,=_COMMA_%
It gives me just unquoted %1. In this case you could simply use %~1.
"GOTO eof" jumps to a label called "eof" as you have defined at the end of your code (:eof), but GOTO:EOF is internal command to leave a file immediately (jump to a very End Of File).
But first of all, is standalone VLC command correct?