bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.55k stars 8.13k forks source link

求助,播放存在10s的延迟,如何处理,谢谢。 #4636

Open dadahellohello opened 5 years ago

dadahellohello commented 5 years ago

最近使用ijk_version_info: k0.8.8进行视频播放测试,在onNativeInvoke 1和131073之间有10s的延迟,百思不得其解,急切寻求各位的帮助和指导,谢谢了。

运行环境: 局域网(无外网访问),有内部dns服务器,为什么在onNativeInvoke 1和131073之间有10s的延迟?? 03-04 22:27:28.295 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 1 03-04 22:27:38.312 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 131073 03-04 22:27:38.319 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 131074 如果允许访问外网,则无10s的延迟,求助!!!

输出部分日志:

03-04 22:27:28.211 8200-8200/com.xxxx.launcher D/IjkWebPlayer: start called... url = http://abc.xxxx.com/upload/151625288.mp4 mSurfaceCreated = false 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.os.Build$VERSION' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.os.Build' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'java.nio.Buffer' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'java.nio.ByteBuffer' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'java.util.ArrayList' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher I/J4A: API-Level: 22 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.media.AudioTrack' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.media.MediaCodec$BufferInfo' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.media.MediaCodec' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.media.MediaFormat' loaded 03-04 22:27:28.230 8200-8200/com.xxxx.launcher W/J4A: J4ALoader: Ignore: 'android.media.PlaybackParams' need API 22 03-04 22:27:28.230 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'android.os.Bundle' loaded 03-04 22:27:28.231 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'tv.danmaku.ijk.media.player.misc.IMediaDataSource' loaded 03-04 22:27:28.231 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'tv.danmaku.ijk.media.player.misc.IAndroidIO' loaded 03-04 22:27:28.231 8200-8200/com.xxxx.launcher D/J4A: J4ALoader: OK: 'tv.danmaku.ijk.media.player.IjkMediaPlayer' loaded 03-04 22:27:28.233 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmediaplayer version : k0.8.8 03-04 22:27:28.257 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_native_profileBegin 03-04 22:27:28.257 8200-8200/com.xxxx.launcher D/aprof-fake: fake-monstartup libijkplayer.so 03-04 22:27:28.257 8200-8200/com.xxxx.launcher D/IJKMEDIA: monstartup: libijkplayer.so 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_native_init 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_native_setup 03-04 22:27:28.284 8200-8200/com.xxxx.launcher I/IJKMEDIA: av_version_info: ff3.4--ijk0.8.7--20180103--001 03-04 22:27:28.284 8200-8200/com.xxxx.launcher I/IJKMEDIA: ijk_version_info: k0.8.8 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: ffpipeline_create_from_android() 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_inject_opaque(0xec2) 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_inject_opaque()=void 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_ijkio_inject_opaque(0xec2) 03-04 22:27:28.284 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_ijkio_inject_opaque()=void 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_android_set_mediacodec_select_callback() 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: ffpipeline_set_mediacodec_select_callback 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_android_set_mediacodec_select_callback()=void 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_native_setLogLevel(3) 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: moncleanup 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOption 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOption 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOption 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOption 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setOptionLong 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/tv.danmaku.ijk.media.player.IjkMediaPlayer: Couldn't open file on client side, trying server side 03-04 22:27:28.285 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setDataSourceAndHeaders 03-04 22:27:28.286 8200-8200/com.xxxx.launcher V/IJKMEDIA: setDataSource: path http://abc.xxxx.com/upload/151625288.mp4 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_data_source(url="http://abc.xxxx.com/upload/151625288.mp4") 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_data_source(url="http://abc.xxxx.com/upload/151625288.mp4")=0 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_setVideoSurface 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_android_surface(surface=0xbee2d030) 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: ffpipeline_set_surface() 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_set_android_surface(surface=0xbee2d030)=void 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: IjkMediaPlayer_prepareAsync 03-04 22:27:28.286 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_prepare_async() 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: ===== versions ===== 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: ijkplayer : k0.8.8 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: FFmpeg : ff3.4--ijk0.8.7--20180103--001 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: libavutil : 55.78.100 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: libavcodec : 57.107.100 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: libavformat : 57.83.100 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: libswscale : 4.8.100 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: libswresample: 2.9.100 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: ===== options ===== 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : mediacodec = 1 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : mediacodec-auto-rotate = 1 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : mediacodec-handle-resolution-change = 1 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : opensles = 0 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : overlay-format = 842225234 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : framedrop = 1 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : start-on-prepared = 1 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : enable-accurate-seek = 1 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: player-opts : reconnect = 5 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : ijkapplication = -2012972224 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : ijkiomanager = -1622877824 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : http-detect-range-support = 0 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : rtsp_transport = tcp 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : rtsp_flags = prefer_tcp 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : fflags = fastseek 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: format-opts : protocol_whitelist = rtmp,concat,ffconcat,file,subfile,http,https,httpproxy,tls,pipe,rtp,tcp,udp,async,cache,data,crypto,rtsp,ijkhttphook,ijkinject,ijklivehook,ijklongurl,ijksegment,ijktcphook,ijkurlhook 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: codec-opts : skip_loop_filter = 0 03-04 22:27:28.286 8200-8200/com.xxxx.launcher I/IJKMEDIA: =================== 03-04 22:27:28.287 8200-8295/com.xxxx.launcher I/IJKMEDIA: SDL_RunThread: [8295] ff_msg_loop 03-04 22:27:28.287 8200-8295/com.xxxx.launcher D/IJKMEDIA: message_loop 03-04 22:27:28.288 8200-8296/com.xxxx.launcher I/IJKMEDIA: SDL_RunThread: [8296] ff_vout 03-04 22:27:28.288 8200-8200/com.xxxx.launcher D/IJKMEDIA: ijkmp_prepare_async()=0 03-04 22:27:28.288 8200-8295/com.xxxx.launcher D/IJKMEDIA: FFP_MSG_FLUSH: 03-04 22:27:28.291 8200-8297/com.xxxx.launcher I/IJKMEDIA: SDL_RunThread: [8297] ff_read 03-04 22:27:28.292 8200-8297/com.xxxx.launcher D/IJKMEDIA: Opening 'http://abc.xxxx.com/upload/151625288.mp4' for reading 03-04 22:27:28.295 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 1 03-04 22:27:38.312 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 131073 03-04 22:27:38.319 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 131074 03-04 22:27:38.319 8200-8297/com.xxxx.launcher I/IJKMEDIA: Add dns cache hostname = abc.xxxx.com, ip = 202.16.130.70 03-04 22:27:38.319 8200-8297/com.xxxx.launcher D/IJKMEDIA: request: GET /upload/151625288.mp4 HTTP/1.1 User-Agent: Lavf/57.83.100 Accept: / Range: bytes=0- Connection: close Host: abc.xxxx.com Icy-MetaData: 1 03-04 22:27:38.328 8200-8297/com.xxxx.launcher I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 2 03-04 22:27:38.329 8200-8297/com.xxxx.launcher D/IJKMEDIA: Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100 03-04 22:27:38.329 8200-8297/com.xxxx.launcher D/IJKMEDIA: ISO: File Type Major Brand: mp42 03-04 22:27:38.330 8200-8297/com.xxxx.launcher D/IJKMEDIA: Unknown dref type 0x206c7275 size 12 03-04 22:27:38.353 8200-8297/com.xxxx.launcher D/IJKMEDIA: Processing st: 0, edit list 0 - media time: 0, duration: 10992 03-04 22:27:38.356 8200-8297/com.xxxx.launcher D/IJKMEDIA: Unknown dref type 0x206c7275 size 12 03-04 22:27:38.364 8200-8297/com.xxxx.launcher D/IJKMEDIA: Processing st: 1, edit list 0 - media time: 0, duration: 21104640 03-04 22:27:38.412 8200-8295/com.xxxx.launcher D/IJKMEDIA: FFP_MSG_OPEN_INPUT: 03-04 22:27:38.412 8200-8297/com.xxxx.launcher E/IJKMEDIA: Option rtsp_flags not found. 03-04 22:27:38.412 8200-8297/com.xxxx.launcher D/IJKMEDIA: Before avformat_find_stream_info() pos: 199113 bytes read:221369 seeks:0 nb_streams:2 03-04 22:27:38.414 8200-8297/com.xxxx.launcher D/IJKMEDIA: nal_unit_type: 7, nal_ref_idc: 1 03-04 22:27:38.414 8200-8297/com.xxxx.launcher D/IJKMEDIA: nal_unit_type: 8, nal_ref_idc: 1 03-04 22:27:38.422 8200-8297/com.xxxx.launcher D/IJKMEDIA: nal_unit_type: 6, nal_ref_idc: 0 03-04 22:27:38.422 8200-8297/com.xxxx.launcher D/IJKMEDIA: nal_unit_type: 6, nal_ref_idc: 0 03-04 22:27:38.423 8200-8297/com.xxxx.launcher D/IJKMEDIA: nal_unit_type: 5, nal_ref_idc: 1 03-04 22:27:38.423 8200-8297/com.xxxx.launcher D/IJKMEDIA: nal_unit_type: 5, nal_ref_idc: 1

dadahellohello commented 5 years ago

参数配置里面使用了: ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp"); 是这个影响的延迟吗? 如果有影响的话,默认情况下,不同的视频类型rtsp rtmp hls m3u8 flv MP4 ,tcp和udp协议该如何选择使用? 谢谢。