Conversão de vídeo em lote de linha de comando VLC

3

Estou tentando converter alguns arquivos .webm para mp4. Na GUI, seleciono as seguintes configurações para a conversão:

Vídeo:

  • Codec: H-264
  • Item da lista
  • Taxa de bits: 512 kb / s
  • Taxa de quadros: 23,97 fps
  • Escala: 1

Áudio:

  • Codec: Áudio MPEG 4 (AAC)
  • Taxa de bits: 128 kb / s
  • Canais: 2
  • Taxa de amostragem: 44100

E funcionou perfeitamente. Agora eu queria converter todos os meus arquivos de vídeo webm para mp4 em um lote. Então, eu tento este script em lote (na maior parte tomado forma página wiki do VLC )


@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

Mas isso não parece funcionar (ou seja, não estou recebendo nenhuma saída). Em vez disso, recebo essas mensagens na janela fictícia da 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_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_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_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_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

O que estou fazendo de errado?

    
por sowrov 08.04.2012 / 15:55

2 respostas

3

Eu estou fazendo uma resposta do meu comentário, acho que é a causa do seu problema.

No seu script você usa

 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

e o erro mostra

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

isso me leva à conclusão de que o analisador corta a cada espaço em branco (espaço, tabulação, etc) e, portanto, não consegue entender o comando. No link para o wiki VLC também não há espaços em branco.

tente esta linha:

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

Por que não podemos lidar com esses espaços em branco estúpidos que você pode perguntar? (na verdade você faz;))

Quando um programa é chamado para ser executado pelo sistema operacional - eu só sei isso para o Linux, com certeza, mas eu tenho certeza que o Windows lida com ele muito semelhante - os parâmetros para o comando são divididos pelo sistema operacional (nos espaços ) e depois entregue ao programa como uma lista, cada contendo apenas o conteúdo entre os espaços.

Assim, seria tarefa dos programas reconhecer e ler todas as entradas individuais nessa lista e colá-las novamente, isso é realmente possível, mas custa tempo, tanto no desenvolvimento do software quanto na avaliação dos parâmetros.

    
por 08.04.2012 / 17:16
0

Para converter meus arquivos .mod da minha camcorder para .m4v, no linux eu escrevi este script

#!/bin/sh
NAME='echo "$1" | cut -d'.' -f1'
vlc $1 -I dummy --play-and-exit --sout='#transcode{vcodec=h264,acodec=mp4a,ab=128,samplerate=44100,deinterlace,audio-sync}:std{access=file, mux=mp4,dst=./'"$NAME"'.m4v}

que eu dei o nome mod2h264.sh e tornei executável.

Em seguida, na linha de comando, basta digitar

for file in *.MOD; do ~/MyScripts/mod2h264.sh "$file"; done

e você converte todos os arquivos .MOD no diretório atual. Você pode ajustar as opções para corresponder ao resultado desejado.

    
por 05.03.2017 / 20:50