befovy / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support. Backend for https://github.com/befovy/fijkplayer, fijkplayer 的播放内核
GNU General Public License v2.0
154 stars 92 forks source link

Great Work! Some questions I wanted to ask. #15

Closed ammarahm-ed closed 4 years ago

ammarahm-ed commented 4 years ago

Hello there, so I have been working on a library for react native based on ijkplayer. Your ijkplayer fork is very well mantained. is there any possibility of it being available on cocoapods as a framework?

Also IJKPlayer supports native subtitle render on android only but nothing for iOS. Do you have any plans to implement that feature?

befovy commented 4 years ago

Thanks.

No. 1: it's available on cocoapods. Just pod 'FIJKPlayer' More details: https://github.com/befovy/ijkplayer/blob/master/ios/CocoaPodsPub/FIJKPlayer.podspec

No. 2: No plan to support subtitle recently.

ijkplayer post subtitle from native video refresh thread. see it here https://github.com/befovy/ijkplayer/blob/master/ijkmedia/ijkplayer/ff_ffplay.c#L917 But iOS does not response to this message.

ammarahm-ed commented 4 years ago

That is great. I started working on Ijkplayer due to its smaller binary size and more format support compared to exoplayer that does not have any decoders of avi, wmv formats etc. vlc is also an option but it has a very large binary and it cant be modifed or made smaller easily.

Well as much as I understand, iOS and android recieve message from native code. All these messages have same data if you take a look. like here:

Android: https://github.com/befovy/ijkplayer/blob/master/android/ijkplayer/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IjkMediaPlayer.java#L1051

iOS: https://github.com/befovy/ijkplayer/blob/master/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m#1177

my guess is that code in ffplay.c for ios and java is almost same because ijkplayer is based on ffplay from ffmpeg, that is why all the event called on android are also available on ios except timed_text event. maybe a peek into vlc-ios code can help in understanding how it could be done possibly.

befovy commented 4 years ago

timed_text is convert to Java String and then send to IjkMediaPlayer.java object. See it here: https://github.com/befovy/ijkplayer/blob/master/ijkmedia/ijkplayer/android/ijkplayer_jni.c#L1012

When the java player get this message, it just display it on screen. See: https://github.com/befovy/ijkplayer/blob/master/android/ijkplayer/ijkplayer-java/src/main/java/tv/danmaku/ijk/media/player/IjkMediaPlayer.java#L1113 and https://github.com/befovy/ijkplayer/blob/master/android/ijkplayer/ijkplayer-example/src/main/java/tv/danmaku/ijk/media/example/widget/media/IjkVideoView.java#L602

To display subtitle on iOS. convert the char *(comes from message timed_text) to NSString * and then display it.

ammarahm-ed commented 4 years ago

Seems like this could work on ios after looking at the code deeply on ios side. I will give it a try and send a pull request if I got it to work.

btw how does ijkplayer on android show and hide subtitle after sometime? we are only sending text to timedtext so how does it know?

befovy commented 4 years ago

Maybe it doesn't hide subtitle. It just displays empty subtitle