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.

"

Note from Robert Osfield, I have found in testing that audio quality is not good for planar floating point formats, even with adding support for SDL2 to the osgmovie example. I haven't yet tracked down the cause of these audio problems or a solution.


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14609 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-12-17 19:20:48 +00:00
parent 4513709a1b
commit 69abe094ab
2 changed files with 27 additions and 2 deletions

View File

@@ -32,6 +32,8 @@ MACRO(FFMPEG_FIND varname shortname headername)
PATHS
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
${FFMPEG_ROOT}
$ENV{FFMPEG_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
@@ -49,6 +51,8 @@ MACRO(FFMPEG_FIND varname shortname headername)
PATHS
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
${FFMPEG_ROOT}
$ENV{FFMPEG_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
@@ -67,6 +71,8 @@ MACRO(FFMPEG_FIND varname shortname headername)
PATHS
${FFMPEG_ROOT}/lib
$ENV{FFMPEG_DIR}/lib
${FFMPEG_ROOT}/lib${shortname}
$ENV{FFMPEG_DIR}/lib${shortname}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib

View File

@@ -128,8 +128,7 @@ void FFmpegDecoderAudio::open(AVStream * const stream)
m_frequency = m_context->sample_rate;
m_nb_channels = m_context->channels;
OSG_NOTICE<<"FFmpegDecoderAudio::open(..), m_nb_channels="<<m_nb_channels<<", m_context->sample_fmt="<<m_context->sample_fmt<<std::endl;
OSG_INFO<<"FFmpegDecoderAudio::open(..), m_nb_channels="<<m_nb_channels<<", m_context->sample_fmt="<<m_context->sample_fmt<<std::endl;
switch (m_context->sample_fmt)
{
@@ -149,6 +148,26 @@ void FFmpegDecoderAudio::open(AVStream * const stream)
break;
case AV_SAMPLE_FMT_DBL:
throw std::runtime_error("unhandled audio format AV_SAMPLE_FMT_DBL");
case AV_SAMPLE_FMT_U8P:
m_sample_format = osg::AudioStream::SAMPLE_FORMAT_U8;
m_context->request_sample_fmt = av_get_packed_sample_fmt( m_context->sample_fmt );
break;
case AV_SAMPLE_FMT_S16P:
m_sample_format = osg::AudioStream::SAMPLE_FORMAT_S16;
m_context->request_sample_fmt = av_get_packed_sample_fmt( m_context->sample_fmt );
break;
case AV_SAMPLE_FMT_S32P:
m_sample_format = osg::AudioStream::SAMPLE_FORMAT_S32;
m_context->request_sample_fmt = av_get_packed_sample_fmt( m_context->sample_fmt );
break;
case AV_SAMPLE_FMT_FLTP:
m_sample_format = osg::AudioStream::SAMPLE_FORMAT_F32;
m_context->request_sample_fmt = av_get_packed_sample_fmt( m_context->sample_fmt );
break;
case AV_SAMPLE_FMT_DBLP:
throw std::runtime_error("unhandled audio format AV_SAMPLE_FMT_DBLP");
default:
throw std::runtime_error("unknown audio format");
}