2002-02-04 19:57:35 +00:00
|
|
|
#!/usr/bin/perl -w
|
2002-11-03 13:43:01 +00:00
|
|
|
use strict;
|
2002-02-04 19:57:35 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
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-10-29 19:12:14 +00:00
|
|
|
my $ext;
|
|
|
|
|
|
|
|
# get only the bit after the last period. We don't deal with
|
|
|
|
# .tar.gz extensions do we ?
|
|
|
|
if ($path =~ /\./)
|
|
|
|
{
|
2002-11-03 13:43:01 +00:00
|
|
|
$ext = $path;
|
2002-10-29 19:12:14 +00:00
|
|
|
$ext =~ s/^.*\.//;
|
|
|
|
}
|
|
|
|
else { $ext = ""; }
|
|
|
|
|
2002-02-04 19:57:35 +00:00
|
|
|
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-11-03 13:50:21 +00:00
|
|
|
print "This is not an error, just a friendly reminder... Check the man page.\n\n";
|
2002-02-04 20:57:13 +00:00
|
|
|
}
|
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-11-03 13:50:21 +00:00
|
|
|
my $command;
|
|
|
|
my $pipe;
|
|
|
|
|
2002-07-09 10:45:37 +00:00
|
|
|
$ext = lc $ext;
|
2002-02-04 22:35:09 +00:00
|
|
|
|
2002-02-05 16:39:43 +00:00
|
|
|
if ($cfg{VISUALIZER} && ($pipe = $pipes{"vis." . $ext}))
|
|
|
|
{
|
|
|
|
$command = "gst-launch filesrc location=\"$file\" ! $pipe";
|
2002-11-26 14:51:34 +00:00
|
|
|
print "Running command-line\n$command\n\n";
|
2002-02-05 16:39:43 +00:00
|
|
|
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";
|
2002-11-26 14:51:34 +00:00
|
|
|
print "Running command-line\n$command\n\n";
|
2002-02-04 22:35:09 +00:00
|
|
|
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}",
|
2003-01-11 22:50:23 +00:00
|
|
|
"avi", "avidemux video_%02d! { queue ! ffmpegdecall ! $cfg{VIDEOSINK} } avidemux0.audio_%02d! { queue ! mad ! $cfg{AUDIOSINK} }",
|
2002-11-03 13:43:01 +00:00
|
|
|
"flac", "flacdec ! $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-11-01 21:41:29 +00:00
|
|
|
"ogg", "vorbisfile ! $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);
|
2002-11-03 13:43:01 +00:00
|
|
|
if (!$ext) {
|
|
|
|
print "file $file doesn't have an extension !\n";
|
2002-11-03 13:50:21 +00:00
|
|
|
exit;
|
2002-11-03 13:43:01 +00:00
|
|
|
}
|
2002-02-04 22:35:09 +00:00
|
|
|
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
|
|
|
}
|