Hi Robert, My fault! This line should be
# define swr_free avresample_free instead of # define swr_free(ctx) avresample_free Actually, I don't know why this code compiled in my box :) I probably missed something when packing the code. Anyway, nice to hear it is working now. I use this plug-in a lot, so I will probably send you further improvements. One feature that I want to add is the selection of audio tracks. The OSG API seems to be ready for that, but it is not implemented in the plug-in, it always take the default audio track, with no option to select other one, select several tracks or none at all. Regards, On Wed, Jan 7, 2015 at 3:17 PM, Robert Osfield <[email protected]> wrote: > Hi Javier, > > With these changes everything compiles fine on my system and audio now > works great on all the videos I have :-) > > The only small tweak I had to make was FFmpegHeaders.hpp where my compiler > picked up a missing parameter in the swr_free(ctx) macro. I've added this > and it compiled cleanly. > > Many thanks ;-) > Robert. > > On 7 January 2015 at 11:07, Javier Taibo <[email protected]> wrote: > >> Hi Robert, >> >> Try this one... I have tested it with my custom ffmpeg compilation >> (using libswresample) and the libav included in Ubuntu 10.04 (using >> libavresample). CMake scripts detect which library is installed in your >> system and some definitions in FFmpegHeaders.hpp do the trick to bridge >> between libavresample and libswresample. >> >> I am sending you the whole pack of modified files, but the only files >> that are different from my previous commit are >> CMakeModules/FindFFmpeg.cmake, CMakeLists.txt and FFmpegHeaders.hpp. >> >> Hope that works! >> >> >> Regards, >> >> >> On Tue, Jan 6, 2015 at 7:52 PM, Robert Osfield <[email protected]> >> wrote: >> >>> Hi Javier, >>> >>> I have just had a bash at using avresample headers in place of the >>> swresample ones in FFmpegHeaders.hpp : >>> >>> #if 1 >>> #include <libavresample/avresample.h> >>> #else >>> #include <libswresample/swresample.h> >>> #endif >>> >>> But now I get the error: >>> >>> >>> [ 93%] Building CXX object >>> src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.o >>> In file included from >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:1:0: >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.hpp:86:5: >>> error: ‘SwrContext’ does not name a type >>> SwrContext * m_swr_context; // Sw >>> resampling context >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:30:26: >>> error: ‘SwrContext’ has not been declared >>> SwrContext *swr_context, >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: >>> In function ‘int osgFFmpeg::decode_audio(AVCodecContext*, int16_t*, int*, >>> const uint8_t*, int, int*, int, int, AVSampleFormat)’: >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:80:82: >>> error: ‘swr_convert’ was not declared in this scope >>> (const uint8_t **)frame->extended_data, >>> frame->nb_samples); >>> >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: >>> In constructor >>> ‘osgFFmpeg::FFmpegDecoderAudio::FFmpegDecoderAudio(osgFFmpeg::FFmpegDecoderAudio::PacketQueue&, >>> osgFFmpeg::FFmpegClocks&)’: >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:128:5: >>> error: class ‘osgFFmpeg::FFmpegDecoderAudio’ does not have any field named >>> ‘m_swr_context’ >>> m_swr_context(NULL) >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: >>> In member function ‘void osgFFmpeg::FFmpegDecoderAudio::open(AVStream*, >>> osgFFmpeg::FFmpegParameters*)’: >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:188:13: >>> error: ‘m_swr_context’ was not declared in this scope >>> m_swr_context = swr_alloc_set_opts(NULL, >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:195:29: >>> error: ‘swr_alloc_set_opts’ was not declared in this scope >>> 0, NULL ); >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:197:45: >>> error: ‘swr_init’ was not declared in this scope >>> int err = swr_init(m_swr_context); >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:203:40: >>> error: ‘swr_free’ was not declared in this scope >>> swr_free(&m_swr_context); >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: >>> In member function ‘void osgFFmpeg::FFmpegDecoderAudio::close(bool)’: >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:259:15: >>> error: ‘m_swr_context’ was not declared in this scope >>> swr_free(&m_swr_context); >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:259:28: >>> error: ‘swr_free’ was not declared in this scope >>> swr_free(&m_swr_context); >>> ^ >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp: >>> In member function ‘size_t >>> osgFFmpeg::FFmpegDecoderAudio::decodeFrame(void*, size_t)’: >>> /home/robert/OpenSceneGraph/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:443:145: >>> error: ‘m_swr_context’ was not declared in this scope >>> const int bytes_decoded = decode_audio(m_context, >>> reinterpret_cast<int16_t*>(buffer), &data_size, m_packet_data, >>> m_bytes_remaining, m_swr_context, m_out_sample_rate, m_out_nb_channels, >>> m_out_sample_format); >>> >>> ^ >>> src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/build.make:80: recipe >>> for target >>> 'src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.o' >>> failed >>> make[2]: *** >>> [src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.o] >>> Error 1 >>> CMakeFiles/Makefile2:7070: recipe for target >>> 'src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/all' failed >>> make[1]: *** [src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/all] >>> Error 2 >>> Makefile:106: recipe for target 'all' failed >>> make: *** [all] Error 2 >>> >>> >>> It's end of day here in Scotland so I'm going to revert back to >>> svn/trunk without any of your submitted changes and wait for feedback from >>> yourself. FYI, I'm using Kubuntu 14.10. >>> >>> Robert. >>> >>> _______________________________________________ >>> osg-submissions mailing list >>> [email protected] >>> >>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >>> >>> >> >> >> -- >> Javier Taibo >> >> >> _______________________________________________ >> osg-submissions mailing list >> [email protected] >> >> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >> >> > > _______________________________________________ > osg-submissions mailing list > [email protected] > > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > -- Javier Taibo
_______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
