bilibili / ijkplayer

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

iso版本,苹果5手机在播放m3u8的视频。播放一段时间后,会一直缓存。导致视频无法继续播放 #1641

Open andyjmzheng opened 8 years ago

andyjmzheng commented 8 years ago

iso版本,苹果5手机在播放m3u8的视频。播放一段时间后,会一直缓存中,导致视频无法继续播放。

OCer commented 8 years ago

我也出现了这个问题,不知道什么时候缓存结束

andyjmzheng commented 8 years ago

现在的场景是 如果在播放到视频快结束的时候。开始缓存。这样就会一直停留在缓存的状态开始:FFP_MSG_BUFFERING_START。没有来状态FFP_MSG_BUFFERING_END。 通过分析代码发现:要切换到FFP_MSG_BUFFERING_END需要满足下面的if 要保证音频和视频中的队列数据大于队列的总大小。并且音频和视频的队列中的nb_packet大小也要大于50000.如果快到文件尾缓存了。上边的俩个条件都达不到。所以就不会来FFP_MSG_BUFFERINGEND 消息了。 /* if the queue are full, no need to read more / if (ffp->infinite_buffer<1 && !is->seek_req &&

ifdef FFP_MERGE

          (is->audioq.size + is->videoq.size + is->subtitleq.size > MAX_QUEUE_SIZE

else

          (is->audioq.size + is->videoq.size > ffp->dcc.max_buffer_size

endif

        || (   stream_has_enough_packets(is->audio_st, is->audio_stream, &is->audioq, MIN_FRAMES)
            && stream_has_enough_packets(is->video_st, is->video_stream, &is->videoq, MIN_FRAMES)

ifdef FFP_MERGE

            && stream_has_enough_packets(is->subtitle_st, is->subtitle_stream, &is->subtitleq, MIN_FRAMES)))) {

else

            ))) {

endif

        if (!is->eof) {
            ffp_toggle_buffering(ffp, 0);
        }
        /_ wait 10 ms */
        SDL_LockMutex(wait_mutex);
        SDL_CondWaitTimeout(is->continue_read_thread, wait_mutex, 10);
        SDL_UnlockMutex(wait_mutex);
        continue;
    }

@bbcallen @OCer @ousenko

andyjmzheng commented 8 years ago

log如下: ===== custom modules begin ===== register demuxer : ijklivehook ===== custom modules end ===== av_version_info: ff3.1--ijk0.6.0--20160715--001 ijkmp_set_inject_opaque(0x7fee4b4573c0) ijkmp_set_inject_opaque()=void 2016-07-21 19:24:28.835 IJKMediaDemo[43783:9754184] OK setup GL ijkmp_ios_set_view(glView=0x7fee4b43f970) ijkmp_ios_set_view(glView=0x7fee4b43f970)=void 2016-07-21 19:24:28.839 IJKMediaDemo[43783:9754184] invalidateRenderBuffer 2016-07-21 19:24:28.840 IJKMediaDemo[43783:9754217] IJKSDLGLView: setupDisplay not ready ijkmp_set_data_source(url="http://ssports.vod.smgbb.cn.cloudcdn.net/otv/vod/600k/72b5fd714451916e3f4c492cb8149b76_600k_list.m3u8") ijkmp_set_data_source(url="http://ssports.vod.smgbb.cn.cloudcdn.net/otv/vod/600k/72b5fd714451916e3f4c492cb8149b76_600k_list.m3u8")=0 ijkmp_prepare_async() ===== versions ===== FFmpeg : ff3.1--ijk0.6.0--20160715--001 libavutil : 55.27.100 libavcodec : 57.48.101 libavformat : 57.40.101 libswscale : 4.1.100 libswresample: 2.1.100 ===== options ===== player-opts : video-pictq-size = 3 player-opts : overlay-format = fcc-_es2 player-opts : max-fps = 30 player-opts : framedrop = 0 player-opts : videotoolbox-max-frame-width = 960 player-opts : videotoolbox = 0 player-opts : start-on-prepared = 1 format-opts : ijkinject-opaque = 140661441786816 format-opts : ijkapplication = 140661441742480 format-opts : user-agent = ijkplayer format-opts : auto_convert = 0 format-opts : timeout = 30000000 format-opts : reconnect = 1

format-opts : safe = 0

ijkmp_prepare_async()=0 Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy' 2016-07-21 19:24:28.871 IJKMediaDemo[43783:9754184] invalidateRenderBuffer 2016-07-21 19:24:28.871 IJKMediaDemo[43783:9754217] IJKSDLGLView:display: unable to tryLock GL active: 0 2016-07-21 19:24:28.881 IJKMediaDemo[43783:9754184] invalidateRenderBuffer Format hls,applehttp probed with size=2048 and score=100 HLS request for url 'http://ssports.vod.smgbb.cn.cloudcdn.net/otv/vod/600k/72b5fd714451916e3f4c492cb8149b76_600k_000.ts', offset 0, playlist 0 Format mpegts probed with size=2048 and score=50 stream=0 stream_type=f pid=100 prog_reg_desc= stream=1 stream_type=1b pid=101 prog_reg_desc= Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:2 skip whole frame, skip left: 0 user data:"x264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=36 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00" user data:"x264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=36 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00" no picture max_analyze_duration 7000000 reached at 7018667 microseconds st:0 After avformat_find_stream_info() pos: 643712 bytes read:655360 seeks:0 frames:508 Option safe not found. Before avformat_find_stream_info() pos: 5862 bytes read:5862 seeks:0 nb_streams:2 skip whole frame, skip left: 0 Ignoring NAL type 9 in extradata user data:"x264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=36 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00" no picture All info found After avformat_find_stream_info() pos: 5862 bytes read:5862 seeks:0 frames:60 max_frame_duration: 10.000 Input #0, hls,applehttp, from 'http://ssports.vod.smgbb.cn.cloudcdn.net/otv/vod/600k/72b5fd714451916e3f4c492cb8149b76_600k_list.m3u8': Duration: 00:15:00.08, start: 0.064433, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0, 39, 1/90000: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, mono, fltp, 67 kb/s Stream #0:1, 21, 1/90000: Video: h264 (High), 1 reference frame ([27][0][0][0] / 0x001B), yuv420p(left), 640x360 (640x368) [SAR 1:1 DAR 16:9], 0/1, 25 fps, 25 tbr, 90k tbn, 50 tbc aout_open_audio() AudioCodec: avcodec, aac aout_pause_audio(0) detected 4 logical cores Ignoring NAL type 9 in extradata vtb fail!!! switch to ffmpeg decode!!!! VideoCodec: avcodec, h264 fps: 25.000000 (normal) fps: 25.000000 (normal) ijkmp_get_msg: FFP_MSG_PREPARED skip whole frame, skip left: 0 2016-07-21 19:24:30.217 IJKMediaDemo[43783:9754184] FFP_MSG_VIDEO_DECODER_OPEN: false user data:"x264 - core 130 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=36 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00" 2016-07-21 19:24:30.217 IJKMediaDemo[43783:9754184] FFP_MSG_VIDEO_SIZE_CHANGED: 640, 360 no picture no picture 2016-07-21 19:24:30.236 IJKMediaDemo[43783:9754184] FFP_MSG_SAR_CHANGED: 1, 1 2016-07-21 19:24:30.237 IJKMediaDemo[43783:9754184] FFP_MSG_PREPARED: ijkmp_get_meta_l ijkmp_get_meta_l()=void 2016-07-21 19:24:30.238 IJKMediaDemo[43783:9754184] fps in meta 25.000000 2016-07-21 19:24:30.241 IJKMediaDemo[43783:9754184] mediaIsPreparedToPlayDidChange 2016-07-21 19:24:30.244 IJKMediaDemo[43783:9754184] loadStateDidChange: IJKMPMovieLoadStatePlaythroughOK: 3 2016-07-21 19:24:30.245 IJKMediaDemo[43783:9754184] IJKMPMoviePlayBackStateDidChange 1: playing SDL_VoutFFmpeg_CreateOverlay(w=640, h=360, fmt=I420(0x30323449, dp=0x7fee4b44d600) Video: first frame decoded SDL_VoutFFmpeg_CreateOverlay(w=640, h=360, fmt=I420(0x30323449, dp=0x7fee4b44d600) 2016-07-21 19:24:30.248 IJKMediaDemo[43783:9754184] FFP_MSG_VIDEO_SIZE_CHANGED: 640, 360 SDL_VoutFFmpeg_CreateOverlay(w=640, h=360, fmt=I420(0x30323449, dp=0x7fee4b44d600) 2016-07-21 19:24:30.248 IJKMediaDemo[43783:9754184] FFP_MSG_VIDEO_SIZE_CHANGED: 640, 360 [GLES2] Version = OpenGL ES 2.0 APPLE-12.0.40 [GLES2] Vendor = Apple Inc. [GLES2] Renderer = Apple Software Renderer [GLES2] Extensions = GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_read_format GL_IMG_texture_compression_pvrtc create render yuv420p 2016-07-21 19:24:30.251 IJKMediaDemo[43783:9754184] FFP_MSG_VIDEO_SIZE_CHANGED: 640, 360 use render yuv420p 2016-07-21 19:24:30.255 IJKMediaDemo[43783:9754250] IJKSDLGLView: renderbufferStorage fromDrawable IJK_GLES2_Renderer_TexCoords_cropRight Using fltp internally between filters avcodec/Audio: first frame decoded 2016-07-21 19:24:30.309 IJKMediaDemo[43783:9754184] FFP_MSG_AUDIO_RENDERING_START: 2016-07-21 19:24:30.511 IJKMediaDemo[43783:9754184] FFP_MSG_VIDEO_RENDERING_START: Statistics: 1319948 bytes read, 0 seeks HLS request for url 'http://ssports.vod.smgbb.cn.cloudcdn.net/otv/vod/600k/72b5fd714451916e3f4c492cb8149b76_600k_001.ts', offset 0, playlist 0 Continuity check failed for pid 0 expected 2 got 0 Continuity check failed for pid 4096 expected 2 got 0 Continuity check failed for pid 256 expected 9 got 0 Statistics: 904280 bytes read, 0 seeks HLS request for url 'http://ssports.vod.smgbb.cn.cloudcdn.net/otv/vod/600k/72b5fd714451916e3f4c492cb8149b76_600k_002.ts', offset 0, playlist 0 Continuity check failed for pid 0 expected 1 got 0 Continuity check failed for pid 4096 expected 1 got 0 Continuity check failed for pid 257 expected 11 got 0 Continuity check failed for pid 256 expected 13 got 0 ffp_toggle_buffering_l: start aout_pause_audio(1) 2016-07-21 19:25:04.989 IJKMediaDemo[43783:9754184] FFP_MSG_BUFFERING_START: 2016-07-21 19:25:04.989 IJKMediaDemo[43783:9754184] loadStateDidChange: IJKMPMovieLoadStateStalled: 4

andyjmzheng commented 8 years ago

@bbcallen

andyjmzheng commented 8 years ago

出现了 FFP_MSG_BUFFERING_START 这个后就一直缓存卡在哪里。不来 FFP_MSG_BUFFERING_END。 @bbcallen @Android4MediaPlayer

andyjmzheng commented 8 years ago

把MAX_QUEUE_SIZE 修改小了。非常容易出现缓存卡住的问题

Android4MediaPlayer commented 8 years ago

It works well.

andyjmzheng commented 8 years ago

我现在测试用的是ijkplayer最新版本的demo测试的。以前的0.4.4.1版本在ios也有此类问题。 @Android4MediaPlayer

andyjmzheng commented 8 years ago

android的手机测试没有问题。

bbcallen commented 8 years ago

Can't reproduce here. You can run git grep "Continuity check failed for pid" in ffmpeg's directory to see where it happens.

albertcsg commented 8 years ago

您好,我也是遇到了这个问题,卡在FFP_MSG_BUFFERING_START:不返回END,请问您是怎么解决的呀。@andyjmzheng

Joe-xuzejia commented 8 years ago

我也是 啊 ,有解决的办法吗?

babyfish21 commented 8 years ago

同样的问题,有解决方案了吗?