osg can use the ffmpeg plug-in to realize the function of playing video, but this plug-in can only be used when compiling osg to ensure successful completion. There are a few points that need special attention during the compilation process, otherwise it may lead to failure to compile successfully.
1. To correctly select the version of ffmpeg
First, go to https://ffmpeg.zeranoe.com/builds/win32/dev/ to download the development version of ffmpeg. The minimum version is 3.2. Special attention should be paid here, because the ffmpeg processing module in osg calls the related ffmpeg development library Interface, if the selected version does not correspond, it will cause reports such as: error C2065: “PIX_FMT_YUVA420P”: undeclared identifier, error C3861: “avcodec_alloc_frame”: identifier not found. . . Wait for the error. This problem will be reported when osg3.4.0 version uses ffmpeg3.2 and above, so try to use a newer version of osg to avoid such problems.
2. When configuring cmake, make appropriate modifications and path configurations
Modify the OpenSceneGraph-3.6.3\CMakeModules\FindFFmpeg.cmake file, add SET(STDINT_OK TRUE) after line 136 SET(FFMPEG_FOUND "NO"), and ensure that the FFMPEG_STDINT_INCLUDE_DIR of FFMPEG in the CMake interface is empty. Select Grouped in cmake, you will see a ffmpeg option, correctly select the corresponding path of ffmpeg, and the problem of backslashes.
3. Inttypes.h problem
In common.h, it may report that the include file cannot be opened: "inttypes.h": No such file or directory. The solution is as follows:
Comment out #include <inttypes.h>
Add the following code:
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
#define CONFIG_WIN32
#endif
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(EMULATE_INTTYPES)
#define EMULATE_INTTYPES
#endif
#ifndef EMULATE_INTTYPES
#include <inttypes.h>
#else
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifdef CONFIG_WIN32
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else /* other OS */
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#endif /* other OS */
#endif /* EMULATE_INTTYPES */