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

iOS/Android Video Decoding #2469

Closed
swoolcock opened this issue Jun 3, 2019 · 4 comments · Fixed by #2705
Closed

iOS/Android Video Decoding #2469

swoolcock opened this issue Jun 3, 2019 · 4 comments · Fixed by #2705

Comments

@swoolcock
Copy link
Collaborator

swoolcock commented Jun 3, 2019

VideoDecoder does not currently work on iOS nor Android, as we do not include compatible native libraries for ffmpeg.

We have a couple of options:

  1. Attempt to get MobileFFmpeg static libraries working with the FFmpeg.AutoGen package. https://github.com/tanersener/mobile-ffmpeg

  2. Abstract VideoDecoder to not be implementation-specific, then subclass it per platform.
    Android could use Xamarin.Android.MP4Transcoder, which is based on ffmpeg.
    iOS would likely need to use AVFoundation, as I could not find an ffmpeg-based wrapper.
    Desktop would continue to use FFmpeg.AutoGen.

Edit: It looks like there are potentially licensing issues with using ffmpeg under Android. The previously mentioned MP4Transcoder is actually based on this custom transcoder: https://github.com/ypresto/android-transcoder

@peppy
Copy link
Sponsor Member

peppy commented Jun 3, 2019

I think we'll probably want #2 for performance reasons.

@peppy peppy added this to the Candidate Issues milestone Jun 3, 2019
@UselessToucan
Copy link
Contributor

UselessToucan commented Jun 3, 2019

Not sure that it can be used in our case, but VideoLAN recently released .NET bindings for LibVLC(with Xamarin.Android and Xamarin.iOS support)
You can find the library here https://code.videolan.org/videolan/LibVLCSharp

@swoolcock
Copy link
Collaborator Author

@UselessToucan Yeah I might take a look at that, I don't think AVFoundation is going to do what we need it to do. It's tricky to process raw data in realtime, unless we fully read the stream first. That's not really an option if you want to play large video files.

@swoolcock
Copy link
Collaborator Author

Looking deeper into this, I feel that LibVLC may not be a good solution for us. Calling Stop() on the player is a blocking action, since it waits for all the active LibVLC threads to join. It's incredibly fiddly to make sure all LibVLC threads have exited, otherwise it's likely to freeze and/or crash the app. I would rather find a native solution that is proven for the platform.

I think I've worked out a way of asynchronously reading/playing an AVAsset from a System.IO.Stream, so that should cover iOS. I'll look at Xamarin.Android.MP4Transcoder when I get a chance, but I'm guessing it will be a lot easier to implement than iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants