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:
@@ -8,14 +8,13 @@
|
||||
|
||||
#include "FFmpegClocks.hpp"
|
||||
#include "FFmpegPacket.hpp"
|
||||
#include "FFmpegParameters.hpp"
|
||||
|
||||
#include <osg/AudioStream>
|
||||
|
||||
#include "BoundedMessageQueue.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace osgFFmpeg {
|
||||
|
||||
|
||||
@@ -30,10 +29,10 @@ public:
|
||||
FFmpegDecoderAudio(PacketQueue & packets, FFmpegClocks & clocks);
|
||||
~FFmpegDecoderAudio();
|
||||
|
||||
void open(AVStream * stream);
|
||||
void open(AVStream * stream, FFmpegParameters* parameters);
|
||||
void pause(bool pause);
|
||||
void close(bool waitForThreadToExit);
|
||||
|
||||
|
||||
void setVolume(float volume);
|
||||
float getVolume() const;
|
||||
|
||||
@@ -53,7 +52,7 @@ private:
|
||||
typedef std::vector<uint8_t> Buffer;
|
||||
|
||||
void decodeLoop();
|
||||
void adjustBufferEndTps(size_t buffer_size);
|
||||
void adjustBufferEndPts(size_t buffer_size);
|
||||
size_t decodeFrame(void * buffer, size_t size);
|
||||
|
||||
|
||||
@@ -69,9 +68,12 @@ private:
|
||||
size_t m_audio_buf_size;
|
||||
size_t m_audio_buf_index;
|
||||
|
||||
int m_frequency;
|
||||
int m_nb_channels;
|
||||
osg::AudioStream::SampleFormat m_sample_format;
|
||||
int m_in_sample_rate;
|
||||
int m_in_nb_channels;
|
||||
AVSampleFormat m_in_sample_format;
|
||||
int m_out_sample_rate;
|
||||
int m_out_nb_channels;
|
||||
AVSampleFormat m_out_sample_format;
|
||||
|
||||
SinkPtr m_audio_sink;
|
||||
|
||||
@@ -80,6 +82,8 @@ private:
|
||||
bool m_end_of_stream;
|
||||
bool m_paused;
|
||||
volatile bool m_exit;
|
||||
|
||||
SwrContext * m_swr_context; // Sw resampling context
|
||||
};
|
||||
|
||||
|
||||
@@ -94,23 +98,15 @@ inline bool FFmpegDecoderAudio::validContext() const
|
||||
|
||||
inline int FFmpegDecoderAudio::frequency() const
|
||||
{
|
||||
return m_frequency;
|
||||
return m_out_sample_rate;
|
||||
}
|
||||
|
||||
|
||||
inline int FFmpegDecoderAudio::nbChannels() const
|
||||
{
|
||||
return m_nb_channels;
|
||||
return m_out_nb_channels;
|
||||
}
|
||||
|
||||
|
||||
inline osg::AudioStream::SampleFormat FFmpegDecoderAudio::sampleFormat() const
|
||||
{
|
||||
return m_sample_format;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace osgFFmpeg
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user