VLC bash transcoding script output to file

0


I'm running such script to transcode my audio files:

#!/bin/bash
acodec="vorb"  
arate="256" 
ext="ogg" 
vlc="/usr/bin/vlc" 
fmt="mp3" 

for a in *$fmt; do 
$vlc -I dummy -vvv "$a" --sout "#transcode{acodec=$acodec,ab=$arate,channels=2}:duplicate{dst=std{access=file,mux=ogg,dst=\"$a.$ext\"}" vlc://quit 
done

And trying to redirect this script output to file like this:

./transcode.sh > /media/sf_Downloads/transcode.log

But receive only 0 byte file. Why?

Suncatcher

Posted 2014-03-11T18:06:06.600

Reputation: 908

Answers

0

VLC is writing to stderr and not stdout. You can mend this in your log redirection by calling the script like:

./transcode.sh > /media/sf_Downloads/transcode.log 2>&1

or in the Bash specific way:

./transcode.sh &> /media/sf_Downloads/transcode.log

You can also do the redirection to stdout within the script by adding 2>&1 at the end of the line with the VLC command within the loop. Then you can call the script just as you tried before:

./transcode.sh > /media/sf_Downloads/transcode.log

and get the intended logging result directly.

For more information, see e.g.

Daniel Andersson

Posted 2014-03-11T18:06:06.600

Reputation: 20 465