Forum Cross Platform with Xamarin

Render a ffmpeg video with Xamarin Forms

bbb0xbbb0x USMember

Hi all,

I'm working on an app that involves editing movie files and I wanted to use Xamarin Forms so I can share the same frontend.
I have ffmpeg running but now I need to output the video (or let's say an image of the video, to get started) to the screen.
My problem is that I see multiple solutions but all are not optimal. I hope you can help me in this so that I know what to do.
I'm talking about Android below as this is the platform I'm writing it first.
So let's say I want to output an image from the video.

Solution 1: Pinvoke

The most straight ahead solution, but I have serious performance concern which is why I did not even try it. I somehow had to get the unmanaged class holding the image to C# (with manually reading pixel by pixel in the worst case) and then the Pinvoke interface is also slow, which can matter when the final result is playing a movie and this operation needs to be done many times per seconds.

Solution 2: SDL2

This solution would be perfect if SDL isn't built as it is! The android SDL port requires a Java SDLActivity class. So I could rewrite the SDLActivity class for C#, but the actual code (SDL_android.c) is calling it's functions per JNI - which wouldn't work I guess since it's C# now? Is there any way to include an actual Java Activity in Xamarin Android? Otherwise I could rewrite the SDL class too, but lots of work without even knowing if it would work!

Solution 3: OpenGL ES 2

First of all, the documentation doesn't seem to be as good and I'm having a bit trouble with it. Pointing myself back to SDL that it would be much easier without that little problem. I'm sure I can work through this, but it will take time again. Also OpenGL cannot output audio, where I would take OpenAL which hopefully works. Also code may not be 100% cross platform and SDL supports multiple outputs at once.

Solution 4: Developing native for the target devices

I know the advantages, but there is a very large disadvantage. It may give me a head start, but afterwards it would be much more work for me. Plus I wouldn't consider porting to UWP when having to do it natively (too much work for the smallest audience), but with Xamarin I would.

Also another potential issue: The video should not be fullscreen. A perfect solution would be having the video rendering inside a view, with letting the graphics output think the view is it's world. I did this with DirectX and Windows Forms before. This way scrolling etc would also be done by the Xamarin backend. Is this possible?

Thanks for your time & help!

Sign In or Register to comment.