2002-02-04 19:57:35 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
# launch a gst-launch pipeline for the supplied media file
|
|
|
|
# use the extension to determine the gst-launch pipeline
|
|
|
|
# make use of default output sinks
|
|
|
|
|
|
|
|
### packages
|
|
|
|
|
|
|
|
use File::Basename;
|
|
|
|
|
2002-03-02 00:31:56 +00:00
|
|
|
my (%pipes, %cfg);
|
2002-02-04 19:57:35 +00:00
|
|
|
|
|
|
|
sub extension
|
|
|
|
{
|
|
|
|
my $path = shift;
|
2002-02-04 22:09:40 +00:00
|
|
|
my $ext = (fileparse ($path, '\..*?'))[2];
|
2002-02-04 19:57:35 +00:00
|
|
|
$ext =~ s/^\.//;
|
|
|
|
return $ext;
|
|
|
|
}
|
|
|
|
|
2002-02-04 20:57:13 +00:00
|
|
|
sub read_config
|
|
|
|
{
|
2002-02-04 21:39:45 +00:00
|
|
|
my $config_file = `echo -n ~`."/.gst";
|
2002-02-04 20:57:13 +00:00
|
|
|
if (-e $config_file)
|
|
|
|
{
|
|
|
|
open CONFIG, $config_file;
|
|
|
|
while (<CONFIG>)
|
|
|
|
{
|
|
|
|
chomp;
|
|
|
|
s/#.*//;
|
|
|
|
s/\s+$//;
|
|
|
|
next unless length;
|
|
|
|
my ($var, $value) = split (/\s*=\s*/, $_, 2);
|
|
|
|
$cfg{$var} = $value;
|
|
|
|
}
|
|
|
|
if (!($cfg{AUDIOSINK}))
|
|
|
|
{
|
|
|
|
print "Please add an AUDIOSINK to $config_file !\n";
|
|
|
|
}
|
|
|
|
if (!($cfg{VIDEOSINK}))
|
|
|
|
{
|
|
|
|
print "Please add a VIDEOSINK to $config_file !\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "No configuration file $config_file found. You might want to create one.\n";
|
|
|
|
}
|
2002-03-02 00:31:56 +00:00
|
|
|
if (!defined $cfg{AUDIOSINK}) { $cfg{AUDIOSINK} = "osssink"; }
|
2002-09-09 20:20:24 +00:00
|
|
|
if (!defined $cfg{VIDEOSINK}) { $cfg{VIDEOSINK} = "colorspace ! xvideosink"; }
|
2002-03-02 00:31:56 +00:00
|
|
|
if (!defined $cfg{CVS_PATH}) { $cfg{CVS_PATH} = `echo -n ~`."/gst/cvs"; }
|
2002-02-04 20:57:13 +00:00
|
|
|
}
|
|
|
|
|
2002-02-04 22:35:09 +00:00
|
|
|
sub playfile($$)
|
|
|
|
{
|
|
|
|
my ($file, $ext) = @_;
|
2002-07-09 10:45:37 +00:00
|
|
|
$ext = lc $ext;
|
2002-02-04 22:35:09 +00:00
|
|
|
|
|
|
|
my $pipe;
|
2002-02-05 16:39:43 +00:00
|
|
|
if ($cfg{VISUALIZER} && ($pipe = $pipes{"vis." . $ext}))
|
|
|
|
{
|
|
|
|
$command = "gst-launch filesrc location=\"$file\" ! $pipe";
|
|
|
|
print "Running $command\n";
|
|
|
|
system ("PATH=\$PATH:".$cfg{CVS_PATH}."/gstreamer/tools $command");
|
|
|
|
}
|
|
|
|
elsif ($pipe = $pipes{$ext})
|
2002-02-04 22:35:09 +00:00
|
|
|
{
|
|
|
|
$command = "gst-launch filesrc location=\"$file\" ! $pipe";
|
|
|
|
print "Running $command\n";
|
|
|
|
system ("PATH=\$PATH:".$cfg{CVS_PATH}."/gstreamer/tools $command");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "No suitable pipe found for extension $ext.\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-04 19:57:35 +00:00
|
|
|
### main
|
|
|
|
|
2002-02-04 20:57:13 +00:00
|
|
|
read_config ();
|
|
|
|
|
2002-02-04 22:35:09 +00:00
|
|
|
%pipes = (
|
2002-10-28 01:09:17 +00:00
|
|
|
"ac3", "a52dec ! $cfg{AUDIOSINK}",
|
2002-04-13 00:46:23 +00:00
|
|
|
"au", "auparse ! $cfg{AUDIOSINK}",
|
2002-04-15 14:40:59 +00:00
|
|
|
"avi", "avidemux video_%02d! { queue ! windec ! $cfg{VIDEOSINK} } avidemux0.audio_%02d! { queue ! mad ! $cfg{AUDIOSINK} }",
|
2002-03-04 18:15:14 +00:00
|
|
|
"fli", "flxdec ! colorspace ! $cfg{VIDEOSINK}",
|
2002-10-28 01:09:17 +00:00
|
|
|
"m1v", "mpegdemux video_%02d! { queue ! mpeg2dec ! $cfg{VIDEOSINK} }",
|
|
|
|
"m2v", "mpegdemux video_%02d! { queue ! mpeg2dec ! $cfg{VIDEOSINK} }",
|
2002-03-04 18:15:14 +00:00
|
|
|
"mod", "modplug ! $cfg{AUDIOSINK}",
|
2002-10-28 01:09:17 +00:00
|
|
|
"mp2", "mad ! $cfg{AUDIOSINK}",
|
2002-04-13 00:46:23 +00:00
|
|
|
"mp3", "mad ! $cfg{AUDIOSINK}",
|
2002-04-15 09:27:03 +00:00
|
|
|
"mpg", "mpegdemux video_%02d! { queue ! mpeg2dec ! $cfg{VIDEOSINK} } mpegdemux0.audio_%02d! { queue ! mad ! $cfg{AUDIOSINK} }",
|
2002-04-13 00:46:23 +00:00
|
|
|
"ogg", "vorbisdec ! $cfg{AUDIOSINK}",
|
2002-03-04 18:15:14 +00:00
|
|
|
"sid", "siddec ! $cfg{AUDIOSINK}",
|
2002-08-25 05:29:23 +00:00
|
|
|
"swf", "swfdec video_%02d! { queue ! colorspace ! $cfg{VIDEOSINK} } swfdec0.audio_%02d! { queue ! $cfg{AUDIOSINK} }",
|
2002-09-23 09:08:51 +00:00
|
|
|
"vob", "mpegdemux video_%02d! { queue ! mpeg2dec ! $cfg{VIDEOSINK} } mpegdemux0.private_stream_1_%02d! { queue ! a52dec ! $cfg{AUDIOSINK} }",
|
|
|
|
"wav", "wavparse ! $cfg{AUDIOSINK}",
|
2002-02-04 20:57:13 +00:00
|
|
|
);
|
2002-02-04 19:57:35 +00:00
|
|
|
|
2002-03-02 00:31:56 +00:00
|
|
|
if ($cfg{VISUALIZER}) {
|
|
|
|
%pipes = (
|
|
|
|
%pipes,
|
|
|
|
"vis.mp3", "mad ! tee silent=true 'tee1.src0!' queue leaky=1 ! { $cfg{VISUALIZER} ! colorspace ! $cfg{VIDEOSINK} } 'tee1.src1!' $cfg{AUDIOSINK}",
|
|
|
|
"vis.ogg", "vorbisdec ! tee silent=true 'tee1.src0!' queue leaky=1 ! { $cfg{VISUALIZER} ! colorspace ! $cfg{VIDEOSINK} } 'tee1.src1!' $cfg{AUDIOSINK}",
|
|
|
|
"vis.wav", "wavparse ! tee silent=true 'tee1.src0!' queue leaky=1 ! { $cfg{VISUALIZER} ! colorspace ! $cfg{VIDEOSINK} } 'tee1.src1!' $cfg{AUDIOSINK}",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2002-02-04 22:35:09 +00:00
|
|
|
if ($#ARGV == -1) {
|
|
|
|
print STDERR "Usage: gst-launch-ext filename[s]\n";
|
|
|
|
exit 1;
|
2002-02-04 19:57:35 +00:00
|
|
|
}
|
2002-02-04 22:35:09 +00:00
|
|
|
|
|
|
|
my $file;
|
|
|
|
while ($file = shift @ARGV) {
|
|
|
|
my $ext = extension ($file);
|
|
|
|
if ($ext eq 'm3u')
|
|
|
|
{
|
|
|
|
open (PLAYLIST, '<', $file);
|
|
|
|
my $file2;
|
|
|
|
while ($file2 = <PLAYLIST>) {
|
|
|
|
chomp $file2;
|
|
|
|
my $ext2 = extension ($file2);
|
|
|
|
playfile($file2, $ext2);
|
|
|
|
}
|
|
|
|
close PLAYLIST;
|
|
|
|
} else {
|
|
|
|
playfile($file, $ext);
|
|
|
|
}
|
2002-02-04 19:57:35 +00:00
|
|
|
}
|