Video player component using ffmpeg?

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Video player component using ffmpeg?

Post 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
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Video player component using ffmpeg?

Post by New Pagodi »

This is a wrapper around FFMpeg that sounds like it does what you want.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Video player component using ffmpeg?

Post by doublemax »

You could also try wxVLC:
viewtopic.php?f=20&t=44697&p=185130
Use the source, Luke!
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: Video player component using ffmpeg?

Post 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
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Video player component using ffmpeg?

Post 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.
Use the source, Luke!
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: Video player component using ffmpeg?

Post 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?
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Video player component using ffmpeg?

Post 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.
Use the source, Luke!
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: Video player component using ffmpeg?

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Video player component using ffmpeg?

Post 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?
Use the source, Luke!
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: Video player component using ffmpeg?

Post 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.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Video player component using ffmpeg?

Post 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
Use the source, Luke!
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: Video player component using ffmpeg?

Post 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.
dolmens
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Jan 12, 2021 1:15 am

Re: Video player component using ffmpeg?

Post by dolmens »

User avatar
bsenftner
Experienced Solver
Experienced Solver
Posts: 85
Joined: Thu May 26, 2016 9:19 pm

Re: Video player component using ffmpeg?

Post by bsenftner »

dolmens, I tried compiling your wxFFmpeg project and ran into some issues. I posted where I'm at on your github issue queue.
Post Reply