参考https://blog.youkuaiyun.com/tigerxuchuanli/article/details/79832934
https://blog.youkuaiyun.com/eguid_1/article/details/83345489
感谢两位大神
问题:现在在研究视频截图,参考easycv,截图会有马赛克,或者大部分绿色覆盖。
通过修改打开视频流的方法(参考第一个博客的内容做修改),贴上代码:
/**
* 打开视频流
* @param url -url
* @return
* @throws FileNotOpenException
*/
protected AVFormatContext openInput(String url) throws FileNotOpenException{
AVFormatContext pFormatCtx = new AVFormatContext(null);
//加上参数rtsp_transport 设置值为tcp
BytePointer optionKey1 = new BytePointer("rtsp_transport");
BytePointer optionValue1 = new BytePointer("tcp");
av_dict_set(options,optionKey1,optionValue1,0);
BytePointer optionKey2 = new BytePointer("max_delay");
BytePointer optionValue2 = new BytePointer("5000000");
av_dict_set(options,optionKey2,optionValue2,0);
if(avformat_open_input(pFormatCtx, url, null, options)==0) {
return pFormatCtx;
}
throw new FileNotOpenException("Didn't open video file");
}
修改后,连续截了几张,不再出现马赛克和绿色。
以上如果做录像的话同样,也需要设置rtsp_transport 为tcp。