5

I have close to 0 programming experience but would like to figure out how to do this and have been trying to figure out how to do this for awhile. I'm getting very frustrated - wish I could understand it. I'm trying to convert a bunch of MP4 files to MP3 files. I would like to keep the original file and just spit out a bunch of MP3 files with same name as the original file.

From here: https://wiki.videolan.org/How_to_Batch_Encode/

Apparently, all you need to do is use this code in the Command-Prompt. I have never really used the Command-Prompt before so no idea what to do.

FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
GOTO :eof

:SUB_VLC
 SET _firstbit=%1
 SET _qt="
 CALL SET _newnm=%%_firstbit:%_qt%=%%
 SET _commanm=%_newnm:,=_COMMA_%
 REM echo %_commanm%
 CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{acodec="mpga",ab="512","channels=2",samplerate="44100"}:standard{access="file",mux="mpeg1",dst="%_commanm%.mp3"} vlc://quit
GOTO :eof

:SUB_RENAME
 SET _origfnm=%1
 SET _endbit=%_origfnm:*.m4a=%
 CALL SET _newfilenm=%%_origfnm:.m4a%_endbit%=.mp3%%
 SET _newfilenm=%_newfilenm:_COMMA_=,%
 COPY %1 %_newfilenm%
 DEL %1
GOTO :eof

:eof
  1. So far I changed the directory in the Command-Prompt to the folder where the MP4 files are located.
  2. In the code, I've changed all mention of .m4a to .mp4.
  3. I've change mpga to mp3.
  4. I've changed "C:\Program Files\VideoLAN\VLC\vlc" to where my vlc program is located.

What else do I need to do? And what do all the %% mean in the code?

Thank you so much!

1

1 Answer 1

7

The %% are variables. The issue I was having using the sample was that my filenames contained spaces so it was necessary to wrap the %%a in quotes.

The following works for me:

for %%a in (*.mp4) do "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I dummy "%%a" --sout=#transcode{acodec=mp3,ab=128,vcodec=dummy}:std{access="file",mux="raw",dst="%%a.mp3"} vlc://quit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.