4 # launch a gst-launch pipeline for the supplied media file
5 # use the extension to determine the gst-launch pipeline
6 # make use of default output sinks
15 # get only the bit after the last period. We don't deal with
16 # .tar.gz extensions do we ?
31 my $config_file = $ENV{HOME}."/.gst";
34 open CONFIG, $config_file;
41 my ($var, $value) = split (/\s*=\s*/, $_, 2);
44 if (!($cfg{AUDIOSINK}))
46 print "Please add an AUDIOSINK to $config_file !\n";
48 if (!($cfg{VIDEOSINK}))
50 print "Please add a VIDEOSINK to $config_file !\n";
55 print "No configuration file $config_file found. You might want to create one.\n";
56 print "This is not an error, just a friendly reminder... Check the man page.\n\n";
58 if (!defined $cfg{AUDIOSINK}) { $cfg{AUDIOSINK} = "osssink"; }
59 if (!defined $cfg{VIDEOSINK}) { $cfg{VIDEOSINK} = "ffmpegcolorspace ! xvimagesink"; }
60 if (!defined $cfg{CVS_PATH}) { $cfg{CVS_PATH} = $ENV{HOME}."/gst/cvs"; }
62 if ($command =~ /(.+)\/gst-launch-ext-@GST_MAJORMINOR@$/)
63 { $cfg{COMMAND_PATH} = "$1"; }
65 { $cfg{COMMAND_PATH} = ""; }
70 my ($file, $ext) = @_;
73 my $path = "\$PATH:".$cfg{CVS_PATH}."/gstreamer/tools";
75 if ($cfg{COMMAND_PATH} ne "") {
76 $path = $cfg{COMMAND_PATH}.":$path";
81 if ($cfg{VISUALIZER} && ($pipe = $pipes{"vis." . $ext}))
83 $command = "gst-launch-@GST_MAJORMINOR@ filesrc location=\"$file\" ! $pipe";
84 print "Running command-line\n$command\n\n";
85 system ("PATH=$path $command");
87 elsif ($pipe = $pipes{$ext})
89 $command = "gst-launch-@GST_MAJORMINOR@ filesrc location=\"$file\" ! $pipe";
90 print "Running command-line\n$command\n\n";
91 system ("PATH=$path $command");
95 print "No suitable pipe found for extension $ext.\n";
104 "ac3", "a52dec ! $cfg{AUDIOSINK}",
105 "au", "auparse ! $cfg{AUDIOSINK}",
106 "avi", "decodebin name=d { d. ! queue ! $cfg{VIDEOSINK} } { d. ! queue ! audioconvert ! audioscale ! $cfg{AUDIOSINK} }",
107 "asf", "decodebin name=d ! { d. ! queue ! $cfg{VIDEOSINK} } { d. ! queue ! audioconvert ! audioscale ! $cfg{AUDIOSINK} }",
108 "flac", "flacdec ! $cfg{AUDIOSINK}",
109 "fli", "flxdec ! colorspace ! $cfg{VIDEOSINK}",
110 "m1v", "mpeg2dec ! $cfg{VIDEOSINK}",
111 "m2v", "mpeg2dec ! $cfg{VIDEOSINK}",
112 "m4a", "qtdemux .audio_00 ! { queue ! faad ! $cfg{AUDIOSINK} }",
113 "aac", "faad ! $cfg{AUDIOSINK}",
114 "mod", "modplug ! $cfg{AUDIOSINK}",
115 "mpc", "musepackdec ! $cfg{AUDIOSINK}",
116 "mp2", "mad ! $cfg{AUDIOSINK}",
117 "mp3", "mad ! $cfg{AUDIOSINK}",
118 "mp4", "decodebin name=d { d. ! queue ! ffmpegcolorspace ! videoscale ! $cfg{VIDEOSINK} } { d. ! queue ! audioconvert ! audioscale ! $cfg{AUDIOSINK} }",
119 "mpeg", "mpegdemux name=d { d.audio_00 ! queue ! mad ! audioconvert ! audioscale ! $cfg{AUDIOSINK} } { d.video_00 ! queue ! mpeg2dec ! $cfg{VIDEOSINK} }",
120 "mpg", "mpegdemux name=demux { demux.video_00 ! queue ! mpeg2dec ! ffmpegcolorspace ! $cfg{VIDEOSINK} } { demux.audio_00 ! queue ! mad ! $cfg{AUDIOSINK} }",
121 "ogg", "oggdemux ! vorbisdec ! audioconvert ! $cfg{AUDIOSINK}",
122 "sid", "siddec ! $cfg{AUDIOSINK}",
123 "swf", "swfdec name=swfdec ! { queue ! colorspace ! $cfg{VIDEOSINK} } { swfdec. ! queue ! $cfg{AUDIOSINK} }",
124 "vob", "mpegdemux name=d { d.video_00 ! queue ! mpeg2dec ! $cfg{VIDEOSINK} } { d.audio_00 ! queue ! a52dec ! audioconvert ! audioscale ! $cfg{AUDIOSINK} }",
125 "wav", "wavparse ! $cfg{AUDIOSINK}",
126 "wm", "asfdemux name=demux ! { queue ! spider ! $cfg{VIDEOSINK} } { demux. ! queue ! spider ! $cfg{AUDIOSINK} }",
127 ### a wma file can use wmav1 or wmav2 codec so we must use spider to decode it
128 "wma", "asfdemux name=demux ! spider ! $cfg{AUDIOSINK}",
129 "wmv", "asfdemux name=demux ! { queue ! spider ! $cfg{VIDEOSINK} } { demux. ! queue ! spider ! $cfg{AUDIOSINK} }",
130 "mkv", "matroskademux name=demux ! { queue ! spider ! $cfg{VIDEOSINK} } { demux. ! queue ! spider ! $cfg{AUDIOSINK} }",
131 "mka", "matroskademux ! spider ! $cfg{AUDIOSINK}",
132 "mov", "decodebin name=d { d. ! queue ! ffmpegcolorspace ! videoscale ! $cfg{VIDEOSINK} } { d. ! queue ! audioconvert ! audioscale ! $cfg{AUDIOSINK} }",
135 if ($cfg{VISUALIZER}) {
138 "vis.mp3", "mad ! tee name=tee silent=true ! queue leaky=1 ! { $cfg{VISUALIZER} ! ffmpegcolorspace ! $cfg{VIDEOSINK} } tee. ! $cfg{AUDIOSINK}",
139 "vis.ogg", "vorbisdec ! tee name=tee silent=true ! queue leaky=1 ! { $cfg{VISUALIZER} ! ffmpegcolorspace ! $cfg{VIDEOSINK} } tee. ! $cfg{AUDIOSINK}",
140 "vis.wav", "wavparse ! tee name=tee silent=true ! queue leaky=1 ! { $cfg{VISUALIZER} ! ffmpegcolorspace ! $cfg{VIDEOSINK} } tee. ! $cfg{AUDIOSINK}",
145 print STDERR "Usage: gst-launch-ext-@GST_MAJORMINOR@ filename[s]\n";
150 while ($file = shift @ARGV) {
151 my $ext = extension ($file);
153 print "file $file doesn't have an extension !\n";
158 open (PLAYLIST, '<', $file);
160 while ($file2 = <PLAYLIST>) {
162 my $ext2 = extension ($file2);
163 playfile($file2, $ext2);
167 playfile($file, $ext);