From Javier Taibo, "I have found that since version 1.1, FFMPEG changed the way audio streams are retrieved, from packed to planar format. SDL interprets packed audio, as is used in the osgmovie example. To make the audio work when the OSGffmpeg plug-in is compiled against recent FFMPEG versions, FFmpegDecoderAudio must check for planar formats and in these cases request the samples as packed. This way all works as before. It can be checked with osgmovie example application.
$ osgmovie --audio movie.avi.ffmpeg FFmpegImageStream::open audio failed, audio stream will be disabled: unknown audio format With the attached FFmpegDecoderAudio.cpp, audio sounds correctly. I am also attaching a modified version of FindFFmpeg.cmake that allows to set as FFMPEG_DIR the ffmpeg compiled in the source directory structure. It should not break anything as it only adds some additional search paths. " git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14654 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -126,8 +126,15 @@ bool FFmpegDecoder::open(const std::string & filename, FFmpegParameters* paramet
|
||||
m_format_context.reset(p_format_context);
|
||||
|
||||
// Retrieve stream info
|
||||
// Only buffer up to one and a half seconds
|
||||
p_format_context->max_analyze_duration = AV_TIME_BASE * 1.5f;
|
||||
// Only buffer up to one and a half seconds by default
|
||||
float max_analyze_duration = 1.5;
|
||||
AVDictionaryEntry *mad = av_dict_get( *parameters->getOptions(), "mad", NULL, 0 );
|
||||
if ( mad ) {
|
||||
max_analyze_duration = atof(mad->value);
|
||||
}
|
||||
p_format_context->max_analyze_duration = AV_TIME_BASE * max_analyze_duration;
|
||||
// p_format_context->probesize = 100000;
|
||||
|
||||
if (avformat_find_stream_info(p_format_context, NULL) < 0)
|
||||
throw std::runtime_error("av_find_stream_info() failed");
|
||||
|
||||
@@ -160,9 +167,8 @@ bool FFmpegDecoder::open(const std::string & filename, FFmpegParameters* paramet
|
||||
|
||||
try
|
||||
{
|
||||
m_audio_decoder.open(m_audio_stream);
|
||||
m_audio_decoder.open(m_audio_stream, parameters);
|
||||
}
|
||||
|
||||
catch (const std::runtime_error & error)
|
||||
{
|
||||
OSG_WARN << "FFmpegImageStream::open audio failed, audio stream will be disabled: " << error.what() << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user