Page 1 of 1

Video player component using ffmpeg?

Posted: Sun Feb 17, 2019 10:58 pm
by stefan__o
Hey,
I'm looking for a way to load video inside a wxWidget application. The format support should be platform independent (not using DirectShow, GStreamer, QuickTime etc.) and it should be possible to access and manipulate the pixel data.
My idea is using the ffmpeg libraries for video decoding, but what is the best way to display video (scaling should also be possible)? I do not need maximum performance like 4k120p or high-end scalers, but it should be easily possible to play normal FullHD video on standard hardware.

I looked around and couldn't find anything, has anybody already done something like that?

Best regards,
Stefan

Re: Video player component using ffmpeg?

Posted: Mon Feb 18, 2019 2:50 am
by New Pagodi
This is a wrapper around FFMpeg that sounds like it does what you want.

Re: Video player component using ffmpeg?

Posted: Mon Feb 18, 2019 6:07 am
by doublemax
You could also try wxVLC:
viewtopic.php?f=20&t=44697&p=185130

Re: Video player component using ffmpeg?

Posted: Mon Feb 18, 2019 9:45 am
by stefan__o
Thanks for your fast answers!
New Pagodi wrote:This is a wrapper around FFMpeg that sounds like it does what you want.
I know that project, but I don't see any connection to wxWidgets or am I missing something? I'm looking for a connection between ffmpeg and wxWidgets
doublemax wrote:You could also try wxVLC:
viewtopic.php?f=20&t=44697&p=185130
That seems to be more what I'm looking for, I thought VLC was not option after they switched to Qt. Question is if I can access the video data, I need more that just a wrapper that allows me to include the VLC player in my application. Also I would prefer ffmpeg based on the simple fact is much smaller to build.

Best regards
Stefan

Re: Video player component using ffmpeg?

Posted: Mon Feb 18, 2019 9:54 am
by doublemax
That seems to be more what I'm looking for, I thought VLC was not option after they switched to Qt.
Qt is only used for the GUI. The component uses libvlc which has a plain C interface.
Question is if I can access the video data, I need more that just a wrapper that allows me to include the VLC player in my application.
The wxVLC component probably doesn't expose all libvlc functions, but in libvlc you can install callbacks that are called for each frame with the frame data in RGB.

Re: Video player component using ffmpeg?

Posted: Wed Feb 20, 2019 4:53 pm
by stefan__o
I had a look a libvlc, but it doesn't seem to expose all the internals I need to access compared to the ffmpeg api.
Is there a simple way to display video (decoded data from some buffer) using wxWidgets efficiently? Or do I need some other library like SDL for that?

Re: Video player component using ffmpeg?

Posted: Wed Feb 20, 2019 5:25 pm
by doublemax
Is there a simple way to display video (decoded data from some buffer) using wxWidgets efficiently? Or do I need some other library like SDL for that?
The only information libvlc gets from wxWidgets in wxVLC is a window handle. If you can find a way to let ffmpeg render into a window given by a window handle, that should be enough.

Re: Video player component using ffmpeg?

Posted: Wed Feb 20, 2019 9:27 pm
by stefan__o
As far as I understand the ffmpeg api, what I get is a buffer with a decoded image and metainformation (width, height, pixel format, timestamp...)
The functions from the API do not display any video. What I would need is something I could que buffers in and that displays it according to the timestamps.

Re: Video player component using ffmpeg?

Posted: Wed Feb 20, 2019 10:51 pm
by doublemax
What I would need is something I could que buffers in and that displays it according to the timestamps.
There is nothing like that in wxWidgets.

Just out of curiosity: What features that you need are missing in libvlc?

Re: Video player component using ffmpeg?

Posted: Wed Feb 20, 2019 11:29 pm
by stefan__o
doublemax wrote:
Wed Feb 20, 2019 10:51 pm
There is nothing like that in wxWidgets.
I already assumed that, because I found a lot of posts of people having trouble combining wxWidgets and SDL...
doublemax wrote:
Wed Feb 20, 2019 10:51 pm
Just out of curiosity: What features that you need are missing in libvlc?
I need to able to access the raw frame data, which seems to possible but complicated, but I also need to access the exact timestamp of each frame and be able to control what frame is shown precisely, not just play/pause, but show next frame, show previous, goto frame 1234 etc. This is possible with ffmpeg, although not for all formats perfectly and requires some additional steps (like scanning the entire file at the beginning, the project previously linked is able to do exactly that). libvlc seems to be lacking this features.

Re: Video player component using ffmpeg?

Posted: Thu Feb 21, 2019 12:10 am
by doublemax
This sound more like the requirements for a video editor. So, is high performance, hardware accelerated output a necessity? If not, you could just take the frame data, convert it to a bitmap and display it.

Last year someone needed to display a video stream from a camera on a Raspberry and i hacked together some code that could display a 640x480 bitmap at 1300 fps on a fast PC using OpenGL.

viewtopic.php?p=183279#p183279

Re: Video player component using ffmpeg?

Posted: Thu Feb 21, 2019 1:06 am
by stefan__o
doublemax wrote:
Thu Feb 21, 2019 12:10 am
This sound more like the requirements for a video editor. So, is high performance, hardware accelerated output a necessity? If not, you could just take the frame data, convert it to a bitmap and display it.
Not a video editor, because no video export is needed, but actually video analysis. High performance is not needed, but normal non-jerky playback of 1080p30 should be easily possible (with resize to the panel).
doublemax wrote:
Thu Feb 21, 2019 12:10 am
Last year someone needed to display a video stream from a camera on a Raspberry and i hacked together some code that could display a 640x480 bitmap at 1300 fps on a fast PC using OpenGL.
That looks very interesting and 1300fps is way more than I need.