Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video medias in magnum #327

Closed
al-sabr opened this issue Mar 15, 2019 · 8 comments
Closed

Video medias in magnum #327

al-sabr opened this issue Mar 15, 2019 · 8 comments

Comments

@al-sabr
Copy link

al-sabr commented Mar 15, 2019

Greetings to all!

I wanted to know if there is a way to render ffmpeg decoded frame inside Magnum or if it is possible to display video file like in a browser simply.

Thanx

@mosra
Copy link
Owner

mosra commented Mar 16, 2019

Hi!

Yes, this is possible if you write the decoding on your own and then pass the decoded frame data via an ImageView to some texture. More integrated support for en/decoding video with ffmpeg is planned (audio as well, see mosra/magnum-plugins#55), but at the moment nothing prevents you from doing the decoding directly.

IIRC there are also some OpenGL extensions and ffmpeg APIs that should allow you to do the decoding on the GPU and pass the decoded frames directly, without extra copies.

@al-sabr
Copy link
Author

al-sabr commented Mar 17, 2019

Are there any exemples I can inspire myself from?
I never used OpenGL or anything raw graphic oriented so
I'm totally a noob in this area, but I'm not a noob programmer.

@mosra
Copy link
Owner

mosra commented Mar 17, 2019

Ah okay, sorry for assuming you already know all this :) Hopefully this will give you something to start from:

I don't have any ready-made ffmpeg code for decoding frame data, unfortunately. When I was learning it myself (for the audio) I studied various code snippets scattered on the internet (but be aware that these are of varying quality and some of them make use of long-deprecated features). Then there's an example section in the ffmpeg documentation including a plain C video decoder, so maybe that helps? :)

Once you get the raw frame data, pass them to the ImageView, specify the pixel format (you'll need RGB8Unorm or RGBA8Unorm, not YUV, check the ffmpeg examples again for a way how to convert YUV to RGB) and dimensions and then upload the image to a texture (similarly as done in the Textured triangle example). There's also a ready-made Primitives::squareSolid() that you could apply the texture to (using, transforming and rendering the primitives is described in the Primitives example).

@al-sabr
Copy link
Author

al-sabr commented Mar 17, 2019

Ok that is a better explanation but I still need to understand all of the technical term.

Maybe the results of my searches can be of any help to you. I will list all the great resources I found
concerning FFMPEG and let know if you have the same.

https://github.com/mpenkov/ffmpeg-tutorial
https://github.com/abdullahfarwees/screen-recorder-ffmpeg-cpp
http://dranger.com/ffmpeg/tutorial04.html
https://github.com/andreanobile/opencv_ffmpeg_streaming
http://ffmpeg.org/doxygen/trunk/doc_2examples_2decoding_encoding_8c-example.html
https://github.com/leandromoreira/ffmpeg-libav-tutorial#intro

@mosra
Copy link
Owner

mosra commented Mar 18, 2019

Maybe the results of my searches can be of any help to you.

Not sure what's the question here? :) I do know my way around ffmpeg, I just don't have any example code with ffmpeg+magnum for you. From the links, I think this is the one you're looking for.

@al-sabr
Copy link
Author

al-sabr commented Mar 18, 2019

I have found an App which makes use of ImGui and FFMPEG pushing videos in OpenGL with the source code. I'm trying to gather the whole information that I need before starting my project.

The part I wanted to understand is the ImGui and FFMPEG but it was not easy to find something uncomplicated until today. Now the part with ImGui+FFMPEG is covered since Magnum is also integrating ImGui. What is remaining now is to create a basic prototype With Magnum, Imgui and take the part from the other project and try to push the FFMPEG in Magnum,ImGui.

I hope this will not be a pain in the butt.

@mosra
Copy link
Owner

mosra commented Mar 22, 2019

Anything left to be done here? Otherwise I'd suggest to close this issue.

For general questions, discussion and asking for help please use the Gitter channel instead (you can log in with your GitHub account), issues are more suited for feature requests or bug reports -- and I'm trying to be nice to the almost 200 people watching the repository, since each of them gets an e-mail notification for every comment ;)

@al-sabr
Copy link
Author

al-sabr commented Mar 24, 2019

Yes you can close this ticket. Let us know when video support is on its way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants