From David Longest, "I have updated the FFmpeg plugin to support the 1.0 release version of FFmpeg. The files attached were modified in order to facilitate the update. Below are the details for all changes made.

Header update

FindFFmpeg.cmake has been changed in order to support the new header include format for FFmpeg. In the 1.0 release, a new file had been added with the name “time.h” in the avutil library. The previous method of adding includes caused conflicts with the ANSI C “time.h” file. Now the include directive will only use the main include folder. All files using the old include format have been updated to reflect the change.



Added __STDC_CONSTANT_MACROS define to CMakeLists.txt

Since there is no guarantee that FFmpegHeaders.hpp will be included before stdint.h is included, the define has been moved from FFmpegHeaders.hpp to be part of the CMakeLists.txt for the FFmpeg plugin. This will allow the define to work on all compilers regardless of include order.



Replaced AVFormatParameters with AVDictionary

AVFormatParameters is no longer supported in FFmpeg and has been replaced with a key/value map of strings for each setting. FFmpegParameters and FFmpegDecoder has been updated to reflect this.



Replaced av_open_input_file with avformat_open_input

FFmpeg now opens files using avformat_open_input. Since the av_open_input_file method is deprecated, the FFmpegDecoder class has been updated to reflect this change.



Added custom AVIOContext field to options

Since some formats and inputs may not be supported by FFmpeg, I have added a new parameter that allows a user to allocate their own AVIOContext. This class will allow for creating a read, seek, and write callback if they desire.



Checking for start_time validity

It is possible for some file formats to not provide a start_time to FFmpeg. This would cause stuttering in the video since the clocks class would be incorrect.



Removed findVideoStream and findAudioStream

The new FFmpeg release already has a function that will find the best audio and video stream. The code has been replaced with this function.



Updated error reporting

Some functions would not log an error when opening a file or modifying a file failed. New logs have been added as well as a function to convert error numbers to their string descriptions.



decode_video has been replaced

The old decode_video function would remove extra data that some decoders use in order to properly decode a packet. Now av_codec_decode_video2 has replaced that function.



Picture format changed from RGBA32 to RGB24

Since most video will not contain an alpha channel, using a 24 bit texture will use less memory."
This commit is contained in:
Robert Osfield
2013-02-06 12:46:03 +00:00
parent 19bfa92c91
commit 29eb65c77d
10 changed files with 202 additions and 188 deletions

View File

@@ -26,7 +26,46 @@
#define USE_AV_LOCK_MANAGER
#endif
extern "C" {
static void log_to_osg(void *ptr, int level, const char *fmt, va_list vl)
{
char logbuf[256];
vsnprintf(logbuf, sizeof(logbuf), fmt, vl);
logbuf[sizeof(logbuf) - 1] = '\0';
osg::NotifySeverity severity = osg::DEBUG_FP;
switch (level) {
case AV_LOG_PANIC:
severity = osg::ALWAYS;
break;
case AV_LOG_FATAL:
severity = osg::FATAL;
break;
case AV_LOG_ERROR:
severity = osg::WARN;
break;
case AV_LOG_WARNING:
severity = osg::NOTICE;
break;
case AV_LOG_INFO:
severity = osg::INFO;
break;
case AV_LOG_VERBOSE:
severity = osg::DEBUG_INFO;
break;
default:
case AV_LOG_DEBUG:
severity = osg::DEBUG_FP;
break;
}
// Most av_logs have a trailing newline already
osg::notify(severity) << logbuf;
}
} // extern "C"
/** Implementation heavily inspired by http://www.dranger.com/ffmpeg/ */
@@ -38,6 +77,8 @@ public:
{
supportsProtocol("http","Read video/audio from http using ffmpeg.");
supportsProtocol("rtsp","Read video/audio from rtsp using ffmpeg.");
supportsProtocol("rtp","Read video/audio from rtp using ffmpeg.");
supportsProtocol("tcp","Read video/audio from tcp using ffmpeg.");
supportsExtension("ffmpeg", "");
supportsExtension("avi", "");
@@ -61,6 +102,9 @@ public:
supportsOption("frame_size", "Set frame size (e.g. 320x240)");
supportsOption("frame_rate", "Set frame rate (e.g. 25)");
supportsOption("audio_sample_rate", "Set audio sampling rate (e.g. 44100)");
supportsOption("context", "AVIOContext* for custom IO");
av_log_set_callback(log_to_osg);
#ifdef USE_AV_LOCK_MANAGER
// enable thread locking
@@ -68,6 +112,8 @@ public:
#endif
// Register all FFmpeg formats/codecs
av_register_all();
avformat_network_init();
}
virtual ~ReaderWriterFFmpeg()
@@ -135,6 +181,14 @@ private:
parameters->parse(name, options->getPluginStringData(name));
}
}
if (options && options->getNumPluginData()>0)
{
AVIOContext* context = (AVIOContext*)options->getPluginData("context");
if (context != NULL)
{
parameters->setContext(context);
}
}
}
#ifdef USE_AV_LOCK_MANAGER