Page 1 of 1

Decode at same width and height that encoded video

Posted: 12 Aug 2010 16:21
by jortola
Hi,
I've the following problem, when I open the media, and bind it to the player, I can't retrieve the media width and height values, so I can't get the same output as input. Is there any way to get this?
PD: I've tryed libvlc_video_get_size, but it's not working.
Thanks!

J.Ortola

Code: Select all

libvlc_instance_t* m_pVLCInstance; libvlc_media_player_t* m_pMediaPlayer; libvlc_media_t* m_pMedia; int w, h; ... m_pMedia = libvlc_media_new_path(m_pVLCInstance, pszMediaPathName); libvlc_media_player_set_media (m_pMediaPlayer, m_pMedia); libvlc_video_set_callbacks(m_pMediaPlayer, Lock, Unlock, Display, this); //libvlc_video_get_size(pMediaPlayer, 0, &w, &h); <-- Doesn't retrieve any value libvlc_video_set_format(m_pMediaPlayer, "RGBA", 640, 480, 640*4);

Re: Decode at same width and height that encoded video

Posted: 12 Aug 2010 18:12
by Rémi Denis-Courmont
It's a chicken and egg problem. You can't get the size until after the video track is initialized. And it's too late to use libvlc_set_format() then.

Currently, you need to implement your own video output plugin if you want to get the raw video frames.

Re: Decode at same width and height that encoded video

Posted: 13 Aug 2010 16:56
by Rémi Denis-Courmont
...or to extend the LibVLC API.

Re: Decode at same width and height that encoded video

Posted: 17 Aug 2010 15:29
by jortola
How is this posible? (Extend vlc API)

Re: Decode at same width and height that encoded video

Posted: 30 Aug 2010 23:46
by xdenser
I start video in two steps

1. I setup rendering to some small dummy buffer i.e. 10x10 pixels, i run it and call periodically libvlc_video_get_size until it returns 0 (success)
2. When I get size, I setup proper buffer and thats it.

Re: Decode at same width and height that encoded video

Posted: 16 Sep 2010 02:23
by d3x0r
So, this is still an issue? Can't set the format after the play starts? Can't start the video paused? Can't make a media_list and get information? vlc is able to show information about videos in its playlist... Tried this libvlc_media_parse but that just hangs...

I used the event manager to hook to all known events, I get a libvlc_MediaPlayerLengthChanged - would think that it might have a clue about the size of the stream at that point, and it hasn't yet created the vout; so I would think setting the format here would be good...
but vlc.libvlc_video_get_size( pmyi->mp, 0, &x, &y ) still returns -1

Then after that the next event I would get is the frame lock; of which I get 3 locks and get another event ...

if I wait until libvlc_MediaPlayerPositionChanged, then I can get the size, but the size returned is the size I set in my format... which is not what the function indicates it should do.

Re: Decode at same width and height that encoded video

Posted: 16 Sep 2010 02:58
by Rémi Denis-Courmont
It's still an issue for the simple reason that nobody is working on this problem.

Re: Decode at same width and height that encoded video

Posted: 16 Sep 2010 04:11
by d3x0r
I've gotten as far as ...

**/

void InfoPanel::update( input_item_t *p_item)

{
.. fills the content of the info panel with stuff from p_item->pp_categories
}

I've tried to track back references to pp_categories, and found a list manager in input.c... but I can't find references to that to put the information in in the first place, so I still dont' know where the info under 'right click a playlist item'->Information [Codec Details]

Re: Decode at same width and height that encoded video

Posted: 19 Oct 2010 12:54
by fishstyc
@xdenser

Could you explain a bit more how you do it?

Should you be able to use set_format multiple times? Do you call stop first, and play again after you have set the new format?

Or do you create a new media_player and use set_format on that one?

Re: Decode at same width and height that encoded video

Posted: 19 Oct 2010 19:49
by Rémi Denis-Courmont
The video format is whatever the last invocation of set_format set before the playback started.

Re: Decode at same width and height that encoded video

Posted: 19 Oct 2010 23:31
by xdenser
Or do you create a new media_player and use set_format on that one?
yes, new one

1. I create media_player
2. Setup dummy buffer
3. Setup single event handler for all events
4. Create Event Object and reset it
5. Start playing
6. Wait for Event Object with some reasonable timeout (i.e. 5 sec)
6. In event handler call get_video_size, when I got size I set Event
7. Stop and destroy old media player with relevant resources - buffer, event, etc.
(you also should avoid calling get_video_size when stoping player)
8. Start new media player with size got from first one

it works for udp MPEG2/MPEG4 TS streaming for me