VLC command line batch video conversion

batchvlc-media-player

I am trying to convert some .webm file to mp4. In the GUI I select the following settings for the conversion:

Video:

  • Codec: H-264
  • List item
  • Bitrate: 512 kb/s
  • Frame Rate: 23.97 fps
  • Scale: 1

Audio:

  • Codec: MPEG 4 Audio (AAC)
  • Bitrate: 128 kb/s
  • Channels: 2
  • Sample Rate: 44100

And it worked perfectly. Now I wanted to convert all my webm video files to mp4 in a batch. So I try this batch script (mostly taken form VLC wiki page)


@echo off
FOR /R %%G IN (*.webm) DO (CALL :SUB_VLC "%%G")
GOTO :eof

:SUB_VLC
 SET _firstbit=%1
 SET _qt="
 CALL SET _newnm=%%_firstbit:%_qt%=%%
 SET _commanm=%_newnm:,=_COMMA_%
 echo %_commanm%
 CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{vcodec="h264", vb="512", fps="23.97", scale="1", acodec="mpga",ab="128","channels=2",samplerate="44100"}:standard{access="file",mux="dummy",dst="%_commanm%.mp4"} vlc://quit
GOTO :eof

:eof

But it does not seem to work (i.e. I am not getting any output). Instead I am getting these messages on the dummy window of vlc:


[023332fc] dummy interface: VLC media player - 1.1.11 The Luggage
[023332fc] dummy interface: Copyright © 1996-2011 the VideoLAN team
[023332fc] dummy interface:
Warning: if you can't access the GUI anymore, open a command-line window, go to
the directory where you installed VLC and run "vlc -I qt"

[023332fc] dummy interface: using the dummy interface module...
[023332fc] main interface debug: using interface module "dummy"
[023332fc] main interface debug: TIMER module_need() : 45.000 ms - Total 45.000
ms / 1 intvls (Avg 45.000 ms)
[02315e04] main playlist debug: rebuilding array of current - root Playlist
[02315e04] main playlist debug: rebuild done - 5 items, index -1
[02315e04] main playlist debug: processing request item null node Playlist skip
0
[02315e04] main playlist debug: starting new item
[02315e04] main playlist debug: creating new input thread
[022ffbe4] main input debug: Creating an input for 'a.webm'
[022ffbe4] main input debug: thread (input) created at priority 1 (../.././src/i
nput/input.c:220)
[022ffbe4] main input debug: thread started
[02343144] main stream output debug: using sout chain=`transcode{vcodec=h264,'
[02343144] main stream output debug: stream=`transcode'
[023400dc] main stream out debug: looking for sout stream module: 1 candidate
[023400dc] stream_out_transcode stream out error: cannot create chain
[023400dc] main stream out debug: no sout stream module matching "transcode" cou
ld be loaded
[023400dc] main stream out debug: TIMER module_need() : 5.000 ms - Total 5.000 m
s / 1 intvls (Avg 5.000 ms)
[023400dc] main stream out debug: destroying chain... (name=(null))
[023400dc] main stream out debug: destroying chain done
[02343144] main stream output error: stream chain failed for `transcode{vcodec=h
264,'
[022ffbe4] main input error: cannot start stream output instance, aborting
[02315e04] main playlist debug: finished input
[022ffbe4] main input debug: thread ended
[02315e04] main playlist debug: dead input
[022ffbe4] main input debug: thread times: real 0m0.015000s, kernel 0m0.000000s,
 user 0m0.000000s
[022ffbe4] main input debug: TIMER input launching for 'a.webm' : 15.000 ms - To
tal 15.000 ms / 1 intvls (Avg 15.000 ms)
[02315e04] main playlist debug: changing item without a request (current 0/5)
[02315e04] main playlist debug: using item 1
[02315e04] main playlist debug: starting new item
[02315e04] main playlist debug: creating new input thread
[022ffbe4] main input debug: Creating an input for 'New Folder/vb=512,'
[022ffbe4] main input debug: thread started
[022ffbe4] main input debug: thread (input) created at priority 1 (../.././src/i
nput/input.c:220)
[02343204] main stream output debug: using sout chain=`transcode{vcodec=h264,'
[02343204] main stream output debug: stream=`transcode'
[02340194] main stream out debug: looking for sout stream module: 1 candidate
[02340194] stream_out_transcode stream out error: cannot create chain
[02340194] main stream out debug: no sout stream module matching "transcode" cou
ld be loaded
[02340194] main stream out debug: TIMER module_need() : 5.000 ms - Total 5.000 m
s / 1 intvls (Avg 5.000 ms)
[02340194] main stream out debug: destroying chain... (name=(null))
[02340194] main stream out debug: destroying chain done
[02343204] main stream output error: stream chain failed for `transcode{vcodec=h
264,'
[022ffbe4] main input error: cannot start stream output instance, aborting
[02315e04] main playlist debug: finished input
[022ffbe4] main input debug: thread ended
[02315e04] main playlist debug: dead input
[022ffbe4] main input debug: thread times: real 0m0.030000s, kernel 0m0.000000s,
 user 0m0.000000s
[022ffbe4] main input debug: TIMER input launching for 'New Folder/vb=512,' : 30
.000 ms - Total 30.000 ms / 1 intvls (Avg 30.000 ms)
[02315e04] main playlist debug: changing item without a request (current 1/5)
[02315e04] main playlist debug: using item 2
[02315e04] main playlist debug: starting new item
[02315e04] main playlist debug: creating new input thread
[022ffbe4] main input debug: Creating an input for 'New Folder/fps=23.97,'
[022ffbe4] main input debug: thread (input) created at priority 1 (../.././src/i
nput/input.c:220)
[022ffbe4] main input debug: thread started
[02343144] main stream output debug: using sout chain=`transcode{vcodec=h264,'
[02343144] main stream output debug: stream=`transcode'
[02315e04] main playlist debug: meta ok for (null), need to fetch art
[0231871c] main stream out debug: looking for sout stream module: 1 candidate
[02cd3b5c] main demux meta debug: looking for meta fetcher module: 1 candidate
[0231871c] stream_out_transcode stream out error: cannot create chain
[02cd3b5c] lua demux meta debug: Trying Lua scripts in C:\Users\mmz\AppData\Roam
ing\vlc\lua\meta\fetcher
[0231871c] main stream out debug: no sout stream module matching "transcode" cou
ld be loaded
[02cd3b5c] lua demux meta debug: Trying Lua scripts in C:\Program Files (x86)\Vi
deoLAN\VLC\lua\meta\fetcher
[0231871c] main stream out debug: TIMER module_need() : 0.000 ms - Total 0.000 m
s / 1 intvls (Avg 0.000 ms)
[0231871c] main stream out debug: destroying chain... (name=(null))
[02cd3b5c] lua demux meta debug: Trying Lua playlist script C:\Program Files (x8
6)\VideoLAN\VLC\lua\meta\fetcher\tvrage.lua
[0231871c] main stream out debug: destroying chain done
[02343144] main stream output error: stream chain failed for `transcode{vcodec=h
264,'
[02cd3b5c] main demux meta debug: using meta fetcher module "lua"
[022ffbe4] main input error: cannot start stream output instance, aborting
[02315e04] main playlist debug: finished input
[02cd3b5c] main demux meta debug: TIMER module_need() : 5.000 ms - Total 5.000 m
s / 1 intvls (Avg 5.000 ms)
[022ffbe4] main input debug: thread ended
[02315e04] main playlist debug: dead input
[02cd3b5c] main demux meta debug: removing module "lua"
[022ffbe4] main input debug: thread times: real 0m0.010000s, kernel 0m0.000000s,
 user 0m0.000000s
[02315e04] main playlist debug: searching art for a.webm
[022ffbe4] main input debug: TIMER input launching for 'New Folder/fps=23.97,' :
 15.000 ms - Total 15.000 ms / 1 intvls (Avg 15.000 ms)
[02315e04] main playlist debug: changing item without a request (current 2/5)
[022c74d4] main art finder debug: looking for art finder module: 2 candidates
[02315e04] main playlist debug: using item 3
[022c74d4] lua art finder debug: Trying Lua scripts in C:\Users\mmz\AppData\Roam
ing\vlc\lua\meta\art
[02315e04] main playlist debug: starting new item
[022c74d4] lua art finder debug: Trying Lua scripts in C:\Program Files (x86)\Vi
deoLAN\VLC\lua\meta\art
[02315e04] main playlist debug: creating new input thread
[022c74d4] lua art finder debug: Trying Lua playlist script C:\Program Files (x8
6)\VideoLAN\VLC\lua\meta\art\01_googleimage.lua
[022ffbe4] main input debug: Creating an input for 'New Folder/scale=1,'
[022c74d4] lua art finder debug: Trying Lua playlist script C:\Program Files (x8
6)\VideoLAN\VLC\lua\meta\art\02_frenchtv.lua
[022ffbe4] main input debug: thread (input) created at priority 1 (../.././src/i
nput/input.c:220)
[022ffbe4] main input debug: thread started
[022c74d4] lua art finder debug: Trying Lua playlist script C:\Program Files (x8
6)\VideoLAN\VLC\lua\meta\art\03_lastfm.lua
[02ca2f6c] main stream output debug: using sout chain=`transcode{vcodec=h264,'
[02ca2f6c] main stream output debug: stream=`transcode'
[022c74d4] lua art finder debug: Trying Lua playlist script C:\Program Files (x8
6)\VideoLAN\VLC\lua\meta\art\04_musicbrainz.lua
[023187d4] main stream out debug: looking for sout stream module: 1 candidate
[023187d4] stream_out_transcode stream out error: cannot create chain
[022c74d4] main art finder debug: no art finder module matching "any" could be l
oaded
[023187d4] main stream out debug: no sout stream module matching "transcode" cou
ld be loaded
[022c74d4] main art finder debug: TIMER module_need() : 10.000 ms - Total 10.000
 ms / 1 intvls (Avg 10.000 ms)
[02315e04] main playlist debug: art not found for a.webm
[023187d4] main stream out debug: TIMER module_need() : 10.000 ms - Total 10.000
 ms / 1 intvls (Avg 10.000 ms)
[023187d4] main stream out debug: destroying chain... (name=(null))
[023187d4] main stream out debug: destroying chain done
[02ca2f6c] main stream output error: stream chain failed for `transcode{vcodec=h
264,'
[022ffbe4] main input error: cannot start stream output instance, aborting
[02315e04] main playlist debug: finished input
[022ffbe4] main input debug: thread ended
[02315e04] main playlist debug: dead input
[022ffbe4] main input debug: thread times: real 0m0.015000s, kernel 0m0.000000s,
 user 0m0.015600s
[022ffbe4] main input debug: TIMER input launching for 'New Folder/scale=1,' : 1
5.000 ms - Total 15.000 ms / 1 intvls (Avg 15.000 ms)
[02315e04] main playlist debug: changing item without a request (current 3/5)
[02315e04] main playlist debug: using item 4
[02315e04] main playlist debug: starting new item
[02315e04] main playlist debug: creating new input thread
[022ffbe4] main input debug: Creating an input for 'a.webm.mp4}'
[022ffbe4] main input debug: thread (input) created at priority 1 (../.././src/i
nput/input.c:220)
[022ffbe4] main input debug: thread started
[02ca302c] main stream output debug: using sout chain=`transcode{vcodec=h264,'
[02ca302c] main stream output debug: stream=`transcode'
[02cc8c24] main stream out debug: looking for sout stream module: 1 candidate
[02cc8c24] stream_out_transcode stream out error: cannot create chain
[02cc8c24] main stream out debug: no sout stream module matching "transcode" cou
ld be loaded
[02cc8c24] main stream out debug: TIMER module_need() : 0.000 ms - Total 0.000 m
s / 1 intvls (Avg 0.000 ms)
[02cc8c24] main stream out debug: destroying chain... (name=(null))
[02cc8c24] main stream out debug: destroying chain done
[02ca302c] main stream output error: stream chain failed for `transcode{vcodec=h
264,'
[022ffbe4] main input error: cannot start stream output instance, aborting
[02315e04] main playlist debug: finished input
[022ffbe4] main input debug: thread ended
[02315e04] main playlist debug: dead input
[022ffbe4] main input debug: thread times: real 0m0.015000s, kernel 0m0.015600s,
 user 0m0.000000s
[022ffbe4] main input debug: TIMER input launching for 'a.webm.mp4}' : 15.000 ms
 - Total 15.000 ms / 1 intvls (Avg 15.000 ms)
[02315e04] main playlist debug: changing item without a request (current 4/5)
[02315e04] main playlist debug: nothing to play

What am I doing wrong?

Best Answer

I am making an answer out of my comment, I think it is the cause of your problem.

In your script you use

 CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{vcodec="h264", vb="512", fps="23.97", scale="1", acodec="mpga",ab="128","channels=2",samplerate="44100"}:standard{access="file",mux="dummy",dst="%_commanm%.mp4"} vlc://quit

and the error shows

main stream output error: stream chain failed for `transcode{vcodec=h264,'

this leads me to the conclusion that the parser cuts at every whitespace (space, tab etc) and thus cannot understand the command. In the link to the VLC wiki there are no whitespaces as well.

try this line:

CALL "C:\Program Files (x86)\VideoLAN\VLC\vlc" -I dummy -vvv %1 --sout=#transcode{vcodec="h264",vb="512",fps="23.97",scale="1",acodec="mpga",ab="128","channels=2",samplerate="44100"}:standard{access="file",mux="dummy",dst="%_commanm%.mp4"} vlc://quit

Why can't vlc cope with those stupid whitespace you might ask? (actually you do ;) )

When a programm is called to be executed by the OS - I only know this for linux for sure, but I am pretty sure windows handles it very similar - the parameters to the command are split by the operating system (at the spaces) and then handed to the program as a list, each containing only the content between the spaces.

So it would be the programs task to recognize and read all the individual entries in that list and glue them together again, this is indeed possible but costs time, both when developing the software and when evaluating the parameters.