美文网首页
ijkplayer播放rtsp视频

ijkplayer播放rtsp视频

作者: TroyZhang | 来源:发表于2016-12-16 16:07 被阅读2999次

支持rtsp

$ vim config/module-lite.sh
// 启用rtp
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-protocol=rtp"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-demuxer=rtsp"

iOS

ffmpeg播放rtsp

// 默认用udp播放,有时候播放不了
$ ffplay rtsp://xxxxxx
[h264 @ 0x7f87610a4c00] Ignoring NAL 4 in global header/extradata
[rtsp @ 0x7f876187e000] UDP timeout, retrying with TCP   0B f=0/0
[rtsp @ 0x7f876187e000] method PAUSE failed: 500 ServerInternal/0
[h264 @ 0x7f87610a4c00] Ignoring NAL 4 in global header/extradata
[rtsp @ 0x7f876187e000] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options

// 用tcp播放,可以成功
$ ffplay -rtsp_transport tcp rtsp://xxxxxx

iOS播放rtsp

// 强制使用tcp链接,默认的udp链接有可能播放不了,参考:https://github.com/Bilibili/ijkplayer/issues/1346
[self.player setOptionValue:@"tcp" 
                     forKey:@"rtsp_transport" 
                 ofCategory:kIJKFFOptionCategoryFormat];

Android

// tv.danmaku.ijk.media.example.widget.media.IjkVideoView.java
// 强制使用tcp
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 60);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-fps", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fps", 30);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "overlay-format", IjkMediaPlayer.SDL_FCC_YV12);

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer");
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "max-buffer-size", 1024);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 10);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1);
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probsize", "4096");
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", "2000000");

参考
http://www.jianshu.com/p/69b26da21fa5
https://github.com/Bilibili/ijkplayer/issues/1346
https://github.com/Bilibili/ijkplayer/issues/2259

相关文章

网友评论

      本文标题:ijkplayer播放rtsp视频

      本文链接:https://www.haomeiwen.com/subject/jxinmttx.html