rockcarry / fanplayer

A portable video player based on ffmpeg for windows and android platform.
GNU Lesser General Public License v3.0
616 stars 163 forks source link

Android version compile completely but apk is crash when I run on simulator or android device. #11

Closed RenHu closed 5 years ago

RenHu commented 5 years ago

Hi rockcarry, Happy New Year! and I hope everything will come out all right for New year - 2019!

I am appreciate your project fanplayer for windows, but it's not work for android. Could you pls explain me is it working on android? Because, I build everything correct step by step according to your guide and it's build successfully to make apk. But apk is crash when It run on simulator or android device. I am so urgent with this problem. So, I kindly ask you about problems for android version. I hope to get good response with you. Thanks

pabloxid commented 5 years ago

Same situation here. If I build android project as it comes, using the libfanplayer_jni.so that is already in the project, everything works fine and I can play a mpeg_ts streaming. Both audio and video work well and it's pretty stable.

But if I build the native code, and then test the project with that libfanplayer_jni.so, I get a segmentation fault 11. I found that error occurs in the function vdev_android_unlock(), at vdev-android.cpp, in this line: c-> cmninfos-> vpts = pts; It turns out that c->cmninfos is a NULL pointer since it wasn't initialized. I fixed that problem by adding: render->cmninfos = cmninfos in render_open() function.

Anyway, although I no longer have the segmentation fault, now the player itself is working bad. Tested with the same streaming, now the audio is choppy, and the video freezes after a few seconds.

The player as it comes doesn't work for me, because I need to play rtmps. For that reason I wanted to build with with an openssl-enabled version of ffmpeg. And finally I managed to open the rtmps, but the player has those problems.

rockcarry commented 5 years ago

new commit fix this issue. player update the latest code.

rockcarry commented 5 years ago

rtmps need openssl support. you need modify the build_ffmpeg_for_android.sh to enable openssl support for ffmpeg.

pabloxid commented 5 years ago

It improved a lot!

Now the only problem that I have is, when playing rtmps, the latency is extremely low, but the audio is choppy. I don't need such low latency. Is there some buffer size adjust to improve streaming stability?

Thank you very much.

rockcarry commented 5 years ago

try set init param avts_syncmode to 1.

and in adev-android.cpp try to modify code:

define DEF_ADEV_BUF_NUM 3

RenHu commented 5 years ago

Hi rockcarry, Can I get native code project for fully build on locally?

pabloxid commented 5 years ago

avts_syncmode is already set to 1, afaics.

I tried to increase adev buffer number and size, but audio remains always choppy. Video is kind of broken too, and it gets worse over time.

Log is plenty of such messages:

D/FANPLAYER( 3111): Stream discovered after head already parsed D/FANPLAYER( 3111): No accelerated colorspace conversion found from yuv420p to rgba.

D/FANPLAYER( 3111): Number of bands (29) exceeds limit (19). D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Reserved bit set. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): AVC: nal size 20198956 D/FANPLAYER( 3111): no frame! D/FANPLAYER( 3111): an error occurred during decoding video. D/FANPLAYER( 3111): channel element 3.1 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Sample rate index in program config element does not match the sample rate index configured by the container. D/FANPLAYER( 3111): decode_pce: Input buffer exhausted before END element found D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): channel element 3.8 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): channel element 3.10 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): channel element 3.14 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): channel element 3.7 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Prediction is not allowed in AAC-LC. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Number of bands (15) exceeds limit (13). D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Prediction is not allowed in AAC-LC. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Input buffer exhausted before END element found D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): invalid band type D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Reserved bit set. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Input buffer exhausted before END element found D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): channel element 2.13 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): TYPE_FIL: Input buffer exhausted before END element found D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): channel element 3.10 is not allocated D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): skip_data_stream_element: Input buffer exhausted before END element found D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): AVC: nal size 18757165 D/FANPLAYER( 3111): no frame! D/FANPLAYER( 3111): an error occurred during decoding video. D/FANPLAYER( 3111): Reserved bit set. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Prediction is not allowed in AAC-LC. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Prediction is not allowed in AAC-LC. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Number of bands (35) exceeds limit (31). D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): invalid band type D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Number of bands (43) exceeds limit (27). D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Prediction is not allowed in AAC-LC. D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): Number of bands (48) exceeds limit (31). D/FANPLAYER( 3111): an error occurred during decoding audio. D/FANPLAYER( 3111): AVC: nal size 17839660 D/FANPLAYER( 3111): no frame! D/FANPLAYER( 3111): an error occurred during decoding video.

Stream is h.264 / AAC over rtmps. I also tryed mpeg_ts. I this case, audio sounds right, without any glitch, but video is slow and out of sync; log is clean, no messages about decoding errors.

RenHu commented 5 years ago

So, android version of Fanplayer is not good for using development?

RenHu commented 5 years ago

or using FFmpeg library is not correct choose for development?

rockcarry commented 5 years ago

@pabloxid do you have same problem when using fanplayer win32 version? when you using aac, the sound is incorrect, maybe the rtmp pusher have some problem in aac encoding. if video is slow and out of sync, you need check the audio pts and video pts is correct or not. change the av_log_set_level(AV_LOG_WARNING); AV_LOG_WARNING -> AV_LOG_TRACE to see more debug log message.

rockcarry commented 5 years ago

@RenHu all source code of fanplayer is put on github. which part of source code do you want to build ?

RenHu commented 5 years ago

android version for locally not connect internet.

RenHu commented 5 years ago

because I already start development for windows version, and it's very good to play over 3GB video in 5 seconds. I almost complete windows version but now try to android version but it's not working well. I need just simple android video player which is using FFMpeg library & able to play over 3GB video in 5 seconds.

RenHu commented 5 years ago

ofcourse I don't want not good latency android source code. I want same quality as windows version.

rockcarry commented 5 years ago

pls modify code, try the modifiction I said here before.

rockcarry commented 5 years ago

if crash problem fixed, we'd better close this issue.