summaryrefslogtreecommitdiffstats
path: root/tools/gst-launch-ext
blob: 909438f6b093f73149b5076aa37e48d94519d7d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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;

### defaults
my $VIDEOSINK = "xvideosink";
my $AUDIOSINK = "osssink";
my $GST_CVS_PATH = "~/gst/cvs";

my %pipes = ( 
  "mp3", "mad ! $AUDIOSINK",
  "ogg", "vorbisdec ! $AUDIOSINK",
  "mpg", "mpegdemux video_00! { queue ! mpeg2dec ! $VIDEOSINK } audio_00! { queue ! mad ! $AUDIOSINK }",
  "avi", "avidemux video_00! { queue ! windec ! $VIDEOSINK }",
  "vob", "mpegdemux video_00! { queue ! mpeg2dec ! $VIDEOSINK }",

);

sub extension
{
  my $path = shift;
  my $ext = (fileparse ($path, '\..*'))[2];
  $ext =~ s/^\.//;
  return $ext;
}

### main

my $file = shift @ARGV or die "Please give a file name !";

my $ext = extension ($file);

if ($pipe = $pipes{$ext})
{
  $command = "$GST_CVS_PATH/gstreamer/tools/gst-launch filesrc location=\"$file\" ! $pipe";
  print "Running $command\n";
  system ($command);
}
else
{
  print "No suitable pipe found for extension $ext.\n";
}