osg播放视频需要依赖ffmpeg库,ffmpeg现在已经到5.X,最新版本的ffmpeg无法编译出osgdb_ffmpeg插件,建议使用3.4.2以前版本。
std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension("ffmpeg");
osgDB::Registry::LoadStatus status = osgDB::Registry::instance()->loadLibrary(libName);
osgDB::Registry::instance()->addFileExtensionAlias("mp4", "ffmpeg");
osg::ref_ptr<osg::Image> image = osgDB::readRefImageFile("23.mp4");
osg::ref_ptr<osgDB::ReaderWriter> rwter = osgDB::Registry::instance()->getReaderWriterForExtension("ffmpeg");
osgDB::ReaderWriter::ReadResult rr = rwter->readImage("rtsp://192.168.0.1:8080/h264/ch1/main/av_stream");
osg::ref_ptr<osg::Image> image = rr.getImage();
文章指出在使用osg播放视频时,需要依赖ffmpeg库,但最新版本的ffmpeg(5.x)与osg的osgdb_ffmpeg插件存在编译问题。建议使用3.4.2以前的ffmpeg版本以确保兼容性。示例代码展示了如何加载库并读取mp4及rtsp流视频。
4万+

被折叠的 条评论
为什么被折叠?



