2005年5月10日

gstreamer lauch video!

OK, here after installed the gstreamer-ffmpeg on my Debian box from deb http://debian.ressukka.net/ unstable/ , I have to test it.



I use this gst-launch command for my test. First for this clip I have, I use mplayer to find out what the codecs were used. Well, it is a .avi with msmpeg4v2 video codec and mp3/mp2 mad audio codec. Since my mplayer already installed w32codecs, I'm all set. Now we are ready, here is the command I used to play the clip with gst-launch:



  • gst-launch filesrc location=test.avi ! ffdemux_avi name=demuxer ! { queue ! ffdec_msmpeg4v2 ! ffcolorspace ! xvimagesink } { demuxer. ! queue ! mad ! esdsink }



Some notes:

  • The elements used are:









    filesrc: load video file from source.
    ffdemux_avi: demux avi into streams, from the gstreamer-ffmpeg plugin.
    queue: Since we want to play both video and audio, need to use threads for video and audio playing at the same time. queue is used to bridge a thread to other threads.
    ffdec_msmpeg4v2: well, we want to play a msmpeg4v2 video.
    ffcolorspace: convert the decoded video stream into something our video display can understand.
    xvimagesink: we use xv as our video output devicde. Other options: sdlvideosink, ximagesink. Somehow, autovideosink don't work for me.
    mad: this element handle mp3 audio codec.
    esdsink: I use esd as audio output device. Of cause alsasink should work too, if it is not used by someone else.

  • There are 2 threads as denoted by the curly bracket {...}. Since we want to play the video and audio at the sametime, we put them together using the blocks.



    To make sure our audio links from the demuxer ffdemux_avi, we assign a name to that demuxer instant, "demux". At audio thread, we link it using the name "demux." to link with our audio decoder.



    Notice the Dot->. after the "demux". Because this "demux" is not a real element, it is a ghost element, so we tell gst-lauch about this by putting a dot(.) after "demux".




Wow, what a mess! How about make it simpler? We all know gstreamer can autodetect all those codecs. OK, the element that do the autodect is decodebin. So here we go:



  • gst-launch filesrc location=test.avi ! decodebin name=debin ! { queue ! xvimagesink } { debin. ! queue ! esdsink }



That's it! We don't even need to know all the codecs things. The element "playbin" does not work for me because its video-sink/audio-sink properties only take element objects as paramenters. Cannot do that with gst-launch.



Gstreamer with gstreamer-ffmpeg and w32codecs are fun.

没有评论: