Difference between revisions of "VLC HowTo/Transcode multiple videos"

From VideoLAN Wiki
Jump to navigation Jump to search
(→‎Unix / Linux: Simplify. Extensions are not used on Linux by convention, and can be done easily after transcoding)
m (Copy-edit prose (light), remove insignificant code indentation (relative code indentation has been retained), remove <big>...</big> for code, misc.)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
 
== Idea ==
 
== Idea ==
The idea is to use VLC to do some batch work to encode or transcode multiple files one after each other, without having to care about it.  
+
The idea is to use VLC to do some batch work to encode or [[transcode]] multiple files one after each other, without having to care about it.  
  
You may want to transcode all your videotheque to another format to play them on an [[IPod]], a [[Play on Zune|Zune]], a PS3 or a [[Play on Xbox|Xbox]].
+
You may want to transcode all your videotheque to another format to play them on an [[iPod]], a [[Play on Zune|Zune]], a PS3 or an [[Play on Xbox|Xbox]].
  
 
== Codecs / Muxers ==
 
== Codecs / Muxers ==
You have to choose the correct codecs for the device you want to transcode for.
+
You have to choose the correct [[codec]]s for the device you want to transcode for.
  
We choose here [[H.264]] with [[AAC]] in a [[MPEG-2#TS|MPEG-2/TS]] muxer as an example.
+
We choose here [[H.264]] with [[AAC]] in a [[MPEG-TS|MPEG-2/TS]] muxer as an example.
  
 
== GUI ==
 
== GUI ==
 
Batch convert is supported via the {{GUI}} in VLC 3.0.0
 
Batch convert is supported via the {{GUI}} in VLC 3.0.0
  
If you cannot wait, download a nightly build.  Otherwise, use command-line batch transcoding below.
+
Otherwise, use command-line batch transcoding below.
  
 
== Command Lines ==
 
== Command Lines ==
 
=== Windows ===
 
=== Windows ===
 
For example, to transcode a batch of m4a files (potentially in multiple subdirectories of a single common root directory) to mp3 files (512kb/s encoding with 44100 sampling frequency) you could use the following code in a Windows XP command prompt:
 
For example, to transcode a batch of m4a files (potentially in multiple subdirectories of a single common root directory) to mp3 files (512kb/s encoding with 44100 sampling frequency) you could use the following code in a Windows XP command prompt:
<big><big><syntaxhighlight lang="dos">
+
<syntaxhighlight lang="dos">
for %%a in (*.VOB) do "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %%a --sout=#transcode{vcodec=h264,vb=1024,acodec=mp4a,ab=192,channels=2,deinterlace}:standard{access=file,mux=ts,dst=%%a.mpg} vlc://quit
+
for %%a in (*.VOB) do "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %%a --sout=#transcode{vcodec=h264,vb=1024,acodec=mp4a,ab=192,channels=2,deinterlace}:standard{access=file,mux=ts,dst=%%a.mpg} vlc://quit
  
@ECHO OFF
+
@ECHO OFF
REM ########################################################################
+
REM ########################################################################
REM # A Windows XP cmd.com script to batch convert m4a files to mp3.      #
+
REM # A Windows XP cmd.com script to batch convert m4a files to mp3.      #
REM #                                                                      #
+
REM #                                                                      #
REM # Copyright (C) 2008 Andrew Boden                                      #
+
REM # Copyright (C) 2008 Andrew Boden                                      #
REM # (boden@graduate.uwa.edu.au)                                          #
+
REM # (boden@graduate.uwa.edu.au)                                          #
REM #                                                                      #
+
REM #                                                                      #
REM # This program is free software: you can redistribute it and/or modify #
+
REM # This program is free software: you can redistribute it and/or modify #
REM # it under the terms of the GNU General Public License as published by #
+
REM # it under the terms of the GNU General Public License as published by #
REM # the Free Software Foundation, either version 3 of the License, or    #
+
REM # the Free Software Foundation, either version 3 of the License, or    #
REM # (at your option) any later version.                                  #  
+
REM # (at your option) any later version.                                  #  
REM #                                                                      #
+
REM #                                                                      #
REM # This program is distributed in the hope that it will be useful,      #
+
REM # This program is distributed in the hope that it will be useful,      #
REM # but WITHOUT ANY WARRANTY; without even the implied warranty of      #
+
REM # but WITHOUT ANY WARRANTY; without even the implied warranty of      #
REM # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
+
REM # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
REM # GNU General Public License for more details.                        #
+
REM # GNU General Public License for more details.                        #
REM #                                                                      #
+
REM #                                                                      #
REM # You should have received a copy of the GNU General Public License    #
+
REM # You should have received a copy of the GNU General Public License    #
REM # along with this program.  If not, see <http://www.gnu.org/licenses/>.#
+
REM # along with this program.  If not, see <http://www.gnu.org/licenses/>.#
REM #                                                                      #
+
REM #                                                                      #
REM # Version 1.0 (June 27th 2008)                                        #
+
REM # Version 1.0 (June 27th 2008)                                        #
REM # Uses VideoLAN VLC 0.8.6h (www.videolan.org)                          #
+
REM # Uses VideoLAN VLC 0.8.6h (www.videolan.org)                          #
REM # Gracefully handles commas and apostrophes in file names.            #
+
REM # Gracefully handles commas and apostrophes in file names.            #
REM # Not aware of any other characters needing graceful handling.        #
+
REM # Not aware of any other characters needing graceful handling.        #
REM # 512kbps encoding with 44100 sampling.                                #
+
REM # 512kbps encoding with 44100 sampling.                                #
REM ########################################################################
+
REM ########################################################################
+
 
FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
+
FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
+
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
GOTO :eof
+
GOTO :eof
+
 
:SUB_VLC
+
:SUB_VLC
  SET _firstbit=%1
+
SET _firstbit=%1
  SET _qt="
+
SET _qt="
  CALL SET _newnm=%%_firstbit:%_qt%=%%
+
CALL SET _newnm=%%_firstbit:%_qt%=%%
  SET _commanm=%_newnm:,=_COMMA_%
+
SET _commanm=%_newnm:,=_COMMA_%
  REM echo %_commanm%
+
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
+
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
+
GOTO :eof
+
 
:SUB_RENAME
+
:SUB_RENAME
  SET _origfnm=%1
+
SET _origfnm=%1
  SET _endbit=%_origfnm:*.m4a=%
+
SET _endbit=%_origfnm:*.m4a=%
  CALL SET _newfilenm=%%_origfnm:.m4a%_endbit%=.mp3%%
+
CALL SET _newfilenm=%%_origfnm:.m4a%_endbit%=.mp3%%
  SET _newfilenm=%_newfilenm:_COMMA_=,%
+
SET _newfilenm=%_newfilenm:_COMMA_=,%
  COPY %1 %_newfilenm%
+
COPY %1 %_newfilenm%
  DEL %1
+
DEL %1
GOTO :eof
+
GOTO :eof
+
 
:eof
+
:eof
</syntaxhighlight></big></big>
+
</syntaxhighlight>
  
 
The same as above, for vlc >= 0.9:
 
The same as above, for vlc >= 0.9:
<big><big><syntaxhighlight lang="dos">
+
<syntaxhighlight lang="dos">
@ECHO OFF
+
@ECHO OFF
FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
+
FOR /R %%G IN (*.m4a) DO (CALL :SUB_VLC "%%G")
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
+
FOR /R %%G IN (*.m4a.mp*) DO (CALL :SUB_RENAME "%%G")
GOTO :eof
+
GOTO :eof
+
 
:SUB_VLC
+
:SUB_VLC
  SET _firstbit=%1
+
SET _firstbit=%1
  SET _qt="
+
SET _qt="
  CALL SET _newnm=%%_firstbit:%_qt%=%%
+
CALL SET _newnm=%%_firstbit:%_qt%=%%
  SET _commanm=%_newnm:,=_COMMA_%
+
SET _commanm=%_newnm:,=_COMMA_%
  REM echo %_commanm%
+
REM echo %_commanm%
  CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{acodec="mpga",ab="512","channels=2"}:standard{access="file",mux="raw",dst="%_commanm%.mp3"} vlc://quit
+
CALL "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{acodec="mpga",ab="512","channels=2"}:standard{access="file",mux="raw",dst="%_commanm%.mp3"} vlc://quit
GOTO :eof
+
GOTO :eof
+
 
:SUB_RENAME
+
:SUB_RENAME
  SET _origfnm=%1
+
SET _origfnm=%1
  SET _endbit=%_origfnm:*.m4a=%
+
SET _endbit=%_origfnm:*.m4a=%
  CALL SET _newfilenm=%%_origfnm:.m4a%_endbit%=.mp3%%
+
CALL SET _newfilenm=%%_origfnm:.m4a%_endbit%=.mp3%%
  SET _newfilenm=%_newfilenm:_COMMA_=,%
+
SET _newfilenm=%_newfilenm:_COMMA_=,%
  COPY %1 %_newfilenm%
+
COPY %1 %_newfilenm%
  DEL %1
+
DEL %1
GOTO :eof
+
GOTO :eof
+
 
:eof
+
:eof
</syntaxhighlight></big></big>
+
</syntaxhighlight>
  
 
=== Windows 7 SendTo ===
 
=== Windows 7 SendTo ===
This batch file allows to use the Windows SendTo context menue in Exlorer.
+
This batch file allows to use the Windows SendTo context menu in Explorer.<br />
 
Copy the content in a file named MOV_to_MPG_Converter.bat and copy it to your SendTo directory (CMD SHELL:sendto)
 
Copy the content in a file named MOV_to_MPG_Converter.bat and copy it to your SendTo directory (CMD SHELL:sendto)
<big><big><syntaxhighlight lang="dos">
+
<syntaxhighlight lang="dos">
 +
 
 +
@ECHO OFF
 +
rem ***********************************************************************
 +
rem * MOV to MPG batch converter. (2014-09-29 Sinx)                      *
 +
rem *                                                                    *
 +
rem * For installation just copy batch file to SendTo directory.          *
 +
rem * On Win8 execute "SHELL:sendto" to go to Sendto folder.              *
 +
rem *                                                                    *
 +
rem * I got quite good compression rations with these parameters:        *
 +
rem * vcodec=h264      codec used                                        *
 +
rem * vb=10000        video bandwidth                                    *
 +
rem * deinterlace=1    rebuild full pictures from keyframes and diffs.    *
 +
rem * acodec=mp3      audio codec                                        *
 +
rem * ab=128          128kbps mp3 quality                                *
 +
rem * channels=2      stereo                                            *
 +
rem *                                                                    *
 +
rem * for parameters see                                                  *
 +
rem * http://www.videolan.org/doc/vlc-user-guide/de/ch04.html            *
 +
rem ***********************************************************************
 +
echo **********************************************************************
 +
echo MOV to MPG VLC batch converter called: %0 %1 %2 %3 %4 %5 %6 %7 %8
 +
echo **********************************************************************
 +
echo.
 +
echo For installation, just copy batch file to SendTo folder..
 +
echo.
 +
 
 +
SET _new_extention=mpg
 +
 
 +
:start
 +
if "%~1"=="" (call goto :the_end)
 +
CALL :SUB_CONVERT %1
 +
SHIFT
 +
goto :start
 +
 
 +
 
 +
:SUB_CONVERT
 +
SET _orig_path=%~1
 +
rem SET _orig_extention=%_orig_filename:*.=%
 +
echo %_orig_path%
 +
SET _orig_extention=%_orig_path:*.=%
 +
CALL SET _new_path=%%_orig_path%:.%_orig_extention%=.%_new_extention%%%
 +
set _new_path="%_new_path%"
 +
echo.
 +
echo Converting %1 ======TO===== %_new_path% ...
 +
echo.
 +
 
 +
if exist "%ProgramFiles%\VideoLAN\VLC\vlc.exe" (
 +
SET _vlc_path="%ProgramFiles%\VideoLAN\VLC\vlc"
 +
) else (
 +
SET _vlc_path="%ProgramFiles(x86)%\VideoLAN\VLC\vlc"
 +
)
 +
 
 +
CALL %_vlc_path% -I dummy -vvv %1 --sout=#transcode{vcodec=h264,vb=10000,deinterlace=1,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access=file,mux=ts,dst=%_new_path%} vlc://quit
 +
GOTO :eof
  
@ECHO OFF
+
:the_end
rem ***********************************************************************
+
echo **********************************************************************
rem * MOV to MPG batch converter. (2014-09-29 Sinx)                      *
+
echo * FINISHED                                                          *
rem *                                                                    *
+
echo **********************************************************************
rem * For installation just copy batch file to SendTo directory.          *
+
pause
rem * On Win8 execute "SHELL:sendto" to go to Sendto folder.              *
+
</syntaxhighlight>
rem *                                                                    *
 
rem * I got quite good compression rations with these parameters:        *
 
rem * vcodec=h264      codec used                                        *
 
rem * vb=10000        video bandwidth                                    *
 
rem * deinterlace=1    rebuild full pictures from keyframes and diffs.    *
 
rem * acodec=mp3      audio codec                                        *
 
rem * ab=128          128kbps mp3 quality                                *
 
rem * channels=2      stereo                                            *
 
rem *                                                                    *
 
rem * for parameters see                                                  *
 
rem * http://www.videolan.org/doc/vlc-user-guide/de/ch04.html            *
 
rem ***********************************************************************
 
echo **********************************************************************
 
echo MOV to MPG VLC batch converter called: %0 %1 %2 %3 %4 %5 %6 %7 %8
 
echo **********************************************************************
 
echo.
 
echo For installation, just copy batch file to SendTo folder..
 
echo.
 
 
SET _new_extention=mpg
 
 
:start
 
if "%~1"=="" (call goto :the_end)
 
CALL :SUB_CONVERT %1
 
SHIFT
 
goto :start
 
 
 
:SUB_CONVERT
 
SET _orig_path=%~1
 
rem SET _orig_extention=%_orig_filename:*.=%
 
echo %_orig_path%
 
SET _orig_extention=%_orig_path:*.=%
 
CALL SET _new_path=%%_orig_path%:.%_orig_extention%=.%_new_extention%%%
 
set _new_path="%_new_path%"
 
echo.
 
echo Converting %1 ======TO===== %_new_path% ...
 
echo.
 
 
if exist "%ProgramFiles%\VideoLAN\VLC\vlc.exe" (
 
SET _vlc_path="%ProgramFiles%\VideoLAN\VLC\vlc"
 
) else (
 
SET _vlc_path="%ProgramFiles(x86)%\VideoLAN\VLC\vlc"
 
)
 
 
CALL %_vlc_path% -I dummy -vvv %1 --sout=#transcode{vcodec=h264,vb=10000,deinterlace=1,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access=file,mux=ts,dst=%_new_path%} vlc://quit
 
GOTO :eof
 
 
:the_end
 
echo **********************************************************************
 
echo * FINISHED                                                          *
 
echo **********************************************************************
 
pause
 
</syntaxhighlight></big></big>
 
  
 
=== Powershell ===
 
=== Powershell ===
<big><big><syntaxhighlight lang="powershell">     
+
<syntaxhighlight lang="powershell">     
    $outputExtension = ".mp3"
+
$outputExtension = ".mp3"
    $bitrate = 160
+
$bitrate = 160
    $channels = 2
+
$channels = 2
   
+
 
    foreach($inputFile in get-childitem -recurse -Filter *.wav)
+
foreach($inputFile in get-childitem -recurse -Filter *.wav)
    {  
+
{  
      $outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + $outputExtension;
+
  $outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + $outputExtension;
      $outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);
+
  $outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);
     
+
 
      $programFiles = ${env:ProgramFiles(x86)};
+
  $programFiles = ${env:ProgramFiles(x86)};
      if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }
+
  if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }
     
+
 
      $processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
+
  $processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
      $processArgs = "-I dummy -vvv `"$($inputFile.FullName)`" --sout=#transcode{acodec=`"mp3`",ab=`"$bitrate`",`"channels=$channels`"}:standard{access=`"file`",mux=`"wav`",dst=`"$outputFileName`"} vlc://quit"
+
  $processArgs = "-I dummy -vvv `"$($inputFile.FullName)`" --sout=#transcode{acodec=`"mp3`",ab=`"$bitrate`",`"channels=$channels`"}:standard{access=`"file`",mux=`"wav`",dst=`"$outputFileName`"} vlc://quit"
     
+
 
      start-process $processName $processArgs -wait
+
  start-process $processName $processArgs -wait
    }
+
}
</syntaxhighlight></big></big>
+
</syntaxhighlight>
 
      
 
      
 
=== Unix / Linux ===
 
=== Unix / Linux ===
This can take one file (file.flv), or a wildcard (*.flv). Also supports path with spaces.
+
Transcodes all files in current directory (except hidden files), saving with suffix <code>.transcoded</code>.
  
<big><big><syntaxhighlight lang="bash">
+
<syntaxhighlight lang="bash">
#!/bin/sh                                                                                                                                                     
+
#!/bin/sh                                                                                                                                                     
+
######################## Transcode the files using ... ########################
vcodec="mp4v"
+
vcodec="mp4v"
acodec="mp4a"
+
acodec="mp4a"
bitrate="1024"
+
vb="1024"
arate="128"
+
ab="128"
mux="mp4"
+
mux="mp4"
+
###############################################################################
# For Linux                                                                                                                                                  
+
 
vlc="/usr/bin/vlc"                                                                                                                                          
+
# Store path to VLC in $vlc
# For OSX                                                                                                                                                   
+
if command -pv vlc >/dev/null 2>&1; then
#vlc="/Applications/Utilities/VLC.app/Contents/MacOS/VLC"
+
    # Linux should find "vlc" when searching PATH
+
    vlc="vlc"
if [ ! -e "$vlc" ]; then
+
else
    printf '%s\n' "Command '$vlc' does not exist" >&2
+
    # macOS seems to need an alias
    exit 1
+
    vlc="/Applications/Utilities/VLC.app/Contents/MacOS/VLC"
fi
+
fi
+
# Sanity check
for filename in "$@"; do
+
if ! command -pv "$vlc" >/dev/null 2>&1; then
    printf '%s\n' "=> Transcoding '$filename'... "
+
    printf '%s\n' "Cannot find path to VLC. Abort." >&2
 
+
    exit 1
    "$vlc" -I dummy -q "$filename" \
+
fi
        --sout '#transcode{vcodec=mp4v,vb=1024,acodec=mp4a,ab=128}:standard{mux=mp4,dst="$filename.transcoded",access=file}' \
+
 
        vlc://quit
+
for filename in *; do
    ls -lh "$filename" "$filename.transcoded"
+
    printf '%s\n' "=> Transcoding '$filename'... "
    printf '\n'
+
    "$vlc" -I dummy -q "$filename" \
done
+
      --sout '#transcode{vcodec="$vcodec",vb="$vb",acodec="$acodec",ab="$ab"}:standard{mux="$mux",dst="$filename.transcoded",access=file}' \
</syntaxhighlight></big></big>
+
      vlc://quit
 +
    ls -lh "$filename" "$filename.transcoded"
 +
    printf '\n'
 +
done
 +
</syntaxhighlight>
 +
 
 +
The wildcard <code>*.transcoded</code> will select all of the transcoded files for group operations.
  
To convert filename extensions after (e.g. from <code>.old</code> to <code>.new</code>):
+
To move files:
 +
<syntaxhighlight lang="bash">
 +
mv *.transcoded <directory>
 +
</syntaxhighlight>
 +
To remove all filename extensions (including <code>.transcoded</code>):
 +
<syntaxhighlight lang="bash">
 +
for filename in *.transcoded; do mv "$filename" "${filename%%.*}"; done
 +
</syntaxhighlight>
 +
To remove all filename extensions and replace with another (e.g. <code>.mp3</code>):
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
for filename in *.old; do mv "$filename" "${filename%.old}.new"; done
+
for filename in *.transcoded; do mv "$filename" "${filename%%.*}.mp3"; done
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 07:56, 9 June 2019

This page describes how to batch transcode or encode. Other "how to" pages
This page contains example code.
This code is licensed under the GNU General public license

Idea

The idea is to use VLC to do some batch work to encode or transcode multiple files one after each other, without having to care about it.

You may want to transcode all your videotheque to another format to play them on an iPod, a Zune, a PS3 or an Xbox.

Codecs / Muxers

You have to choose the correct codecs for the device you want to transcode for.

We choose here H.264 with AAC in a MPEG-2/TS muxer as an example.

GUI

Batch convert is supported via the GUI in VLC 3.0.0

Otherwise, use command-line batch transcoding below.

Command Lines

Windows

For example, to transcode a batch of m4a files (potentially in multiple subdirectories of a single common root directory) to mp3 files (512kb/s encoding with 44100 sampling frequency) you could use the following code in a Windows XP command prompt:

for %%a in (*.VOB) do "C:\Program Files\VideoLAN\VLC\vlc" -I dummy -vvv %%a --sout=#transcode{vcodec=h264,vb=1024,acodec=mp4a,ab=192,channels=2,deinterlace}:standard{access=file,mux=ts,dst=%%a.mpg} vlc://quit

@ECHO OFF
REM ########################################################################
REM # A Windows XP cmd.com script to batch convert m4a files to mp3.       #
REM #                                                                      #
REM # Copyright (C) 2008 Andrew Boden                                      #
REM # (boden@graduate.uwa.edu.au)                                          #
REM #                                                                      #
REM # This program is free software: you can redistribute it and/or modify #
REM # it under the terms of the GNU General Public License as published by #
REM # the Free Software Foundation, either version 3 of the License, or    #
REM # (at your option) any later version.                                  # 
REM #                                                                      #
REM # This program is distributed in the hope that it will be useful,      #
REM # but WITHOUT ANY WARRANTY; without even the implied warranty of       #
REM # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        #
REM # GNU General Public License for more details.                         #
REM #                                                                      #
REM # You should have received a copy of the GNU General Public License    #
REM # along with this program.  If not, see <http://www.gnu.org/licenses/>.#
REM #                                                                      #
REM # Version 1.0 (June 27th 2008)                                         #
REM # Uses VideoLAN VLC 0.8.6h (www.videolan.org)                          #
REM # Gracefully handles commas and apostrophes in file names.             #
REM # Not aware of any other characters needing graceful handling.         #
REM # 512kbps encoding with 44100 sampling.                                #
REM ########################################################################

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

The same as above, for vlc >= 0.9:

@ECHO OFF
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"}:standard{access="file",mux="raw",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

Windows 7 SendTo

This batch file allows to use the Windows SendTo context menu in Explorer.
Copy the content in a file named MOV_to_MPG_Converter.bat and copy it to your SendTo directory (CMD SHELL:sendto)

@ECHO OFF
rem ***********************************************************************
rem * MOV to MPG batch converter. (2014-09-29 Sinx)                       *
rem *                                                                     *
rem * For installation just copy batch file to SendTo directory.          *
rem * On Win8 execute "SHELL:sendto" to go to Sendto folder.              *
rem *                                                                     *
rem * I got quite good compression rations with these parameters:         *
rem * vcodec=h264      codec used                                         *
rem * vb=10000         video bandwidth                                    *
rem * deinterlace=1    rebuild full pictures from keyframes and diffs.    *
rem * acodec=mp3       audio codec                                        *
rem * ab=128           128kbps mp3 quality                                *
rem * channels=2       stereo                                             *
rem *                                                                     *
rem * for parameters see                                                  *
rem * http://www.videolan.org/doc/vlc-user-guide/de/ch04.html             *
rem ***********************************************************************
echo **********************************************************************
echo MOV to MPG VLC batch converter called: %0 %1 %2 %3 %4 %5 %6 %7 %8
echo **********************************************************************
echo.
echo For installation, just copy batch file to SendTo folder..
echo.

SET _new_extention=mpg

:start
if "%~1"=="" (call goto :the_end)
CALL :SUB_CONVERT %1
SHIFT
goto :start


:SUB_CONVERT
SET _orig_path=%~1
rem SET _orig_extention=%_orig_filename:*.=%
echo %_orig_path%
SET _orig_extention=%_orig_path:*.=%
CALL SET _new_path=%%_orig_path%:.%_orig_extention%=.%_new_extention%%%
set _new_path="%_new_path%"
echo.
echo Converting %1 ======TO===== %_new_path% ...
echo.

if exist "%ProgramFiles%\VideoLAN\VLC\vlc.exe" (
SET _vlc_path="%ProgramFiles%\VideoLAN\VLC\vlc"
) else (
SET _vlc_path="%ProgramFiles(x86)%\VideoLAN\VLC\vlc"
)

CALL %_vlc_path% -I dummy -vvv %1 --sout=#transcode{vcodec=h264,vb=10000,deinterlace=1,acodec=mp3,ab=128,channels=2,samplerate=44100}:standard{access=file,mux=ts,dst=%_new_path%} vlc://quit
GOTO :eof

:the_end
echo **********************************************************************
echo * FINISHED                                                           *
echo **********************************************************************
pause

Powershell

    
$outputExtension = ".mp3"
$bitrate = 160
$channels = 2

foreach($inputFile in get-childitem -recurse -Filter *.wav)
{ 
  $outputFileName = [System.IO.Path]::GetFileNameWithoutExtension($inputFile.FullName) + $outputExtension;
  $outputFileName = [System.IO.Path]::Combine($inputFile.DirectoryName, $outputFileName);
  
  $programFiles = ${env:ProgramFiles(x86)};
  if($programFiles -eq $null) { $programFiles = $env:ProgramFiles; }
  
  $processName = $programFiles + "\VideoLAN\VLC\vlc.exe"
  $processArgs = "-I dummy -vvv `"$($inputFile.FullName)`" --sout=#transcode{acodec=`"mp3`",ab=`"$bitrate`",`"channels=$channels`"}:standard{access=`"file`",mux=`"wav`",dst=`"$outputFileName`"} vlc://quit"
  
  start-process $processName $processArgs -wait
}

Unix / Linux

Transcodes all files in current directory (except hidden files), saving with suffix .transcoded.

#!/bin/sh                                                                                                                                                     
######################## Transcode the files using ... ########################
vcodec="mp4v"
acodec="mp4a"
vb="1024"
ab="128"
mux="mp4"
###############################################################################

# Store path to VLC in $vlc
if command -pv vlc >/dev/null 2>&1; then
    # Linux should find "vlc" when searching PATH
    vlc="vlc"
else
    # macOS seems to need an alias
    vlc="/Applications/Utilities/VLC.app/Contents/MacOS/VLC"
fi
# Sanity check
if ! command -pv "$vlc" >/dev/null 2>&1; then
    printf '%s\n' "Cannot find path to VLC. Abort." >&2
    exit 1
fi

for filename in *; do
    printf '%s\n' "=> Transcoding '$filename'... "
    "$vlc" -I dummy -q "$filename" \
       --sout '#transcode{vcodec="$vcodec",vb="$vb",acodec="$acodec",ab="$ab"}:standard{mux="$mux",dst="$filename.transcoded",access=file}' \
       vlc://quit
    ls -lh "$filename" "$filename.transcoded"
    printf '\n'
done

The wildcard *.transcoded will select all of the transcoded files for group operations.

To move files:

mv *.transcoded <directory>

To remove all filename extensions (including .transcoded):

for filename in *.transcoded; do mv "$filename" "${filename%%.*}"; done

To remove all filename extensions and replace with another (e.g. .mp3):

for filename in *.transcoded; do mv "$filename" "${filename%%.*}.mp3"; done