debugly / ijkplayer

【持续更新】macOS/iOS video player based on ijkplayer, using FFmpeg 5.1, support Metal、hw accel、HDR、ass subtitle effect...
GNU General Public License v2.0
69 stars 14 forks source link

播放rtsp视频失败 #26

Closed climlove closed 1 day ago

climlove commented 3 days ago

[IJKMEDIA]stream_close will close [IJKMEDIA]IJKMetalView: videiPicture is nil [IJKMEDIA]stream_close did close [IJKMEDIA]remove 'timeout' option for rtmp. [IJKMEDIA]===== options ===== [IJKMEDIA]player-opts : video-pictq-size = 3 [IJKMEDIA]player-opts : overlay-format = fcc-_es2 [IJKMEDIA]player-opts : max-fps = 30 [IJKMEDIA]player-opts : framedrop = 0 [IJKMEDIA]player-opts : videotoolbox-max-frame-width = 3840 [IJKMEDIA]player-opts : videotoolbox_hwaccel = 1 [IJKMEDIA]player-opts : start-on-prepared = 1 [IJKMEDIA]format-opts : ijkapplication = 0x301b412c0 [IJKMEDIA]format-opts : ijkiomanager = 4996631056 [IJKMEDIA]format-opts : protocol_whitelist = ijkio,ijkhttphook,concat,http,tcp,https,tls,file,bluray,dvd,rtmp,rtsp,rtp,srtp,udp [IJKMEDIA]format-opts : auto_convert = 0 [IJKMEDIA]format-opts : user_agent = ijkplayer [IJKMEDIA]format-opts : safe = 0 [IJKMEDIA]format-opts : reconnect = 1 [IJKMEDIA]=================== [IJKMEDIA]remove 'timeout' option for rtmp. [IJKMEDIA]dns getaddrinfo uri = 192.168.1.254 [IJKMEDIA]tcp did open uri = tcp://192.168.1.254:554?timeout=0, ip = send failed: 22 send failed: 22 [IJKMEDIA]Option ijkapplication not found. [IJKMEDIA]max_frame_duration: 10.000 [IJKMEDIA]Input #0, rtsp, from 'rtsp://192.168.1.254:554/xxx.mov': [IJKMEDIA] Metadata: title : Nvt RTSP, streamed by the LIVE555 Media Server comment : 00000001 Duration: N/A, start: 0.160711, bitrate: N/A Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 640x360, 30 fps, 12.50 tbr, 90k tbn [IJKMEDIA]videotoolbox hwaccel switch:on [IJKMEDIA]try use videotoolbox accel [IJKMEDIA]VideoCodec: avcodec, h264 [IJKMEDIA]fps: 30.000000 (normal) [IJKMEDIA]fps: 12.500000 (normal) [IJKMEDIA]auto decision max buffer size:27MB [IJKMEDIA]Playback rate: 1.000000 [IJKMEDIA]ff avcc maybe wrong:01640033FFE1001967640033AC1514A0A02FF966 use origin avcc:0000000167640033AC1514A0A02FF966E020 mediaIsPreparedToPlayDidChange loadStateDidChange: IJKMPMovieLoadStatePlaythroughOK: 3 IJKMPMoviePlayBackStateDidChange 1: playing [IJKMEDIA]Failed setup for format videotoolbox_vld: hwaccel initialisation returned error. [IJKMEDIA]decode_slice_header error [IJKMEDIA]no frame! [IJKMEDIA]ff avcc maybe wrong:01640033FFE1001967640033AC1514A0A02FF966 use origin avcc:0000000167640033AC1514A0A02FF966E020 [IJKMEDIA]Failed setup for format videotoolbox_vld: hwaccel initialisation returned error. [IJKMEDIA]decode_slice_header error [IJKMEDIA]no frame! [IJKMEDIA]ff avcc maybe wrong:01640033FFE1001967640033AC1514A0A02FF966 use origin avcc:0000000167640033AC1514A0A02FF966E020 [IJKMEDIA]Failed setup for format videotoolbox_vld: hwaccel initialisation returned error. [IJKMEDIA]decode_slice_header error [IJKMEDIA]no frame! [IJKMEDIA]ff avcc maybe wrong:01640033FFE1001967640033AC1514A0A02FF966 use origin avcc:0000000167640033AC1514A0A02FF966E020 [IJKMEDIA]Failed setup for format videotoolbox_vld: hwaccel initialisation returned error. [IJKMEDIA]decode_slice_header error [IJKMEDIA]no frame! [IJKMEDIA]ff avcc maybe wrong:01640033FFE1001967640033AC1514A0A02FF966 use origin avcc:0000000167640033AC1514A0A02FF966E020 [IJKMEDIA]Failed setup for format videotoolbox_vld: hwaccel initialisation returned error.

debugly commented 1 day ago

设置下不使用硬解试试:

[options setPlayerOptionIntValue:0 forKey:@"videotoolbox_hwaccel"];
climlove commented 1 day ago

[options setPlayerOptionIntValue:0 forKey:@"videotoolbox"]; 我之前用的这句不行, 用你那句就可以了, 谢谢

debugly commented 1 day ago

不要直接写死成 0 ,除非你明确知道要播放的流都不可能支持 videotoolbox 硬件解码。建议默认开启并监听解码失败的通知:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ijkPlayerVideoDecoderFatal:) name:IJKMPMoviePlayerVideoDecoderFatalNotification object:self.player];

当收到通知后,再将 videotoolbox_hwaccel 设置成 0,重新播放, 这样能够最大程度的利用硬件加速,在播放4K H265 等视频时比较有用。