Last active
February 3, 2018 12:58
-
-
Save kberov/be72370c544d6b2c85e5229d226dc497 to your computer and use it in GitHub Desktop.
Batch convert music/video files from one format to another using Perl (Mojo) and vlc. See also https://wiki.videolan.org/VLC_command-line_help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojo -strict; | |
use Mojo::File qw(path); | |
# cd to the directory where your files are | |
# and run this program | |
# $0 $format_in $format_out | |
my ($format_in, $format_out) = @ARGV; | |
say qq|Converting from "$format_in" to "$format_out"|; | |
for my $file ( path('./')->list->each ) { | |
#vlc -I dummy 0.$format_in --sout=#transcode{acodec=$format_out,channels=2,samplerate=44100}:standard{access=file,mux=raw,dst=0.$format_out} vlc://quit | |
if ( $file =~ /\.$format_in$/ ) { | |
my $out = $file; | |
$out =~ s/\.$format_in$/.$format_out/; | |
$out =~ s/\s+/_/g; #spaces to _ | |
$out =~ s/(\D)(\d)\./${1}0${2}./;# trak1 to track01 | |
say "converting $file to $out"; | |
system( | |
"vlc", | |
"-I", | |
"dummy", | |
$file, | |
"--sout=#transcode{acodec=$format_out,channels=2,samplerate=44100}:standard{access=file,mux=raw,dst=$out}", | |
"vlc://quit" | |
); | |
} | |
#last | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment