Finding out resolution of video of input file using decodebin2?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding out resolution of video of input file using decodebin2?

Alberto Vigata
Dear gstreamer experts,

I need to find out the resolution of the video in my input file, and
in general characteristics of my input streams for later use, like
audio sampling frequency, audio channels and the like. I need this
information to setup some stuff before I can continue building my
pipeline.

My original though was to wait for the 'new-decoded-pad' signal coming
out of decodebin2 but from what I'm seeing, while decodebin2 generates
a pad for every stream it finds the caps of the pad only have the main
decoded format and not other stuff like resolutions or framerates.
Usually decoded video pads come out with caps="video/x-raw-rgb;
video/x-raw-yuv" and decoded audio pads with caps ="audio/x-raw-int,
channels=(int)[ 1, 2 ] ...".  they are not fixed caps.

It does seem though, that precise information about the streams is
available using the 'autoplug-select' signal as this is generating the
actual encoded stream pads for decoding. Inspecting the caps coming
out of 'autoplug-select' one can retrieve precise info of the streams
in the input. Sadly, the pads exposed with 'autoplug-select' are not
the final decoded pads from before so I don't see an easy way to
relate the caps information all the way down to when the decoded pads
are emitted. One could assume certain order in which the pads are
being generated but that route sounds funky.

I'm sure there is an easier way to get this sorted out and thus I'm
looking for your enlightenment,

Thanks in advance,
Alberto

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding out resolution of video of input file using decodebin2?

wl2776
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Finding out resolution of video of input file using decodebin2?

Vincent Torri


On Wed, 16 Jun 2010, wl2776 wrote:

>
> http://gstreamer-devel.966125.n4.nabble.com/How-can-I-get-full-information-about-a-media-file-tp1745331p1745534.html

http://trac.enlightenment.org/e/browser/trunk/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c#L470

(decoder is the decodebin element). This is done after PAUSE state. So:

  * you iterate on the pad of the decodebin element (line 483)
  * you check if it's video or audio (line 496 for example)
  * then, for video, for example, look at the emotion_video_sink_fill()
function (line 560):

http://trac.enlightenment.org/e/browser/trunk/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c#L559

This was for decodebin. I think that it's not very different for
decodebin2

hth

Vincent Torri

> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Finding-out-resolution-of-video-of-input-file-using-decodebin2-tp2258081p2258265.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding out resolution of video of input file using decodebin2?

wl2776
Administrator
In reply to this post by wl2776
However, using FFmpeg seems to be more convenient to me.
Since gst-ffmpeg is installed, FFmpeg libraries (libavformat, libavcodec, libavutil ) are installed also.

It is as easy as:

AVFormatContext *input;
char *filename;

// create the filename

int r=av_open_input_file(&input,filename,NULL,0,NULL);
if(!r){
  r=av_find_stream_info(input);
  if(r>=0){
// iterate all media streams in the file.
    for(int j=0;j<input->nb_streams;j++){                    
       if(input->streams[j]->codec->codec_type==CODEC_TYPE_VIDEO){
          //extract video stream properties.
       }
       if(input->streams[j]->codec->codec_type==CODEC_TYPE_AUDIO){
         // extract audio stream properties.
       }
    }
  }
  av_close_input_file(input); 
}

More details are here: http://ffmpeg.org/documentation.html
Please, see the "Public API Documentation"
Reply | Threaded
Open this post in threaded view
|

Re: Finding out resolution of video of input file using decodebin2?

Alberto Vigata
In reply to this post by Vincent Torri
Thanks guys, I'll give this a try to see if this works out for what
I'm trying to do.

It still feels like to me you have to be extremely verbose with
GStreamer to accomplish simple tasks like this.

On Wed, Jun 16, 2010 at 11:57 PM, Vincent Torri <[hidden email]> wrote:

>
>
> On Wed, 16 Jun 2010, wl2776 wrote:
>
>>
>> http://gstreamer-devel.966125.n4.nabble.com/How-can-I-get-full-information-about-a-media-file-tp1745331p1745534.html
>
> http://trac.enlightenment.org/e/browser/trunk/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c#L470
>
> (decoder is the decodebin element). This is done after PAUSE state. So:
>
>  * you iterate on the pad of the decodebin element (line 483)
>  * you check if it's video or audio (line 496 for example)
>  * then, for video, for example, look at the emotion_video_sink_fill()
> function (line 560):
>
> http://trac.enlightenment.org/e/browser/trunk/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c#L559
>
> This was for decodebin. I think that it's not very different for
> decodebin2
>
> hth
>
> Vincent Torri
>
>> --
>> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Finding-out-resolution-of-video-of-input-file-using-decodebin2-tp2258081p2258265.html
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>> lucky parental unit.  See the prize list and enter to win:
>> http://p.sf.net/sfu/thinkgeek-promo
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding out resolution of video of input file using decodebin2?

Alberto Vigata
In reply to this post by wl2776
Definitely not optimal to end using ffmpeg to do media discovery when
you are trying to build a solution based on GStreamer...

AVP

On Thu, Jun 17, 2010 at 12:09 AM, wl2776 <[hidden email]> wrote:

>
>
> wl2776 wrote:
>>
>> http://gstreamer-devel.966125.n4.nabble.com/How-can-I-get-full-information-about-a-media-file-tp1745331p1745534.html
>>
>
> However, using FFmpeg seems to be more convenient to me.
> Since gst-ffmpeg is installed, FFmpeg libraries (libavformat, libavcodec,
> libavutil ) are installed also.
>
> It is as easy as:
>
>
> AVFormatContext *input;
> char *filename;
>
> // create the filename
>
> int r=av_open_input_file(&input,filename,NULL,0,NULL);
> if(!r){
>  r=av_find_stream_info(input);
>  if(r>=0){
> // iterate all media streams in the file.
>    for(int j=0;j<input->nb_streams;j++){
>       if(input->streams[j]->codec->codec_type==CODEC_TYPE_VIDEO){
>          //extract video stream properties.
>       }
>       if(input->streams[j]->codec->codec_type==CODEC_TYPE_AUDIO){
>         // extract audio stream properties.
>       }
>    }
>  }
>  av_close_input_file(input);
> }
>
>
> More details are here: http://ffmpeg.org/documentation.html
> Please, see the "Public API Documentation"
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Finding-out-resolution-of-video-of-input-file-using-decodebin2-tp2258081p2258288.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding out resolution of video of input file using decodebin2?

wl2776
Administrator
Alberto Vigata wrote
Definitely not optimal to end using ffmpeg to do media discovery when
you are trying to build a solution based on GStreamer...
Yes, if you're going to use that pipeline.

However, if you need only media parameters and are going to destruct that pipeline after retrieving them, libav* can provide shorter and, probably, faster code.