Hi all,

I've patched the audio part. But not completed. The video part needs more changes. But I don't have enough time now.

Just attach the partial patch I made so that when someone has time or I have time then we can continue it.

Yours,
Paul
Index: openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
===================================================================
--- openscenegraph-3.6.5+dfsg1.orig/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
+++ openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
@@ -45,12 +45,19 @@ static int decode_audio(AVCodecContext *
     if (!frame)
         return AVERROR(ENOMEM);
 
-    ret = avcodec_decode_audio4(avctx, frame, &got_frame, &avpkt);
+    ret = avcodec_send_packet(avctx, &avpkt);
+    if (ret >= 0) {
+      ret = avcodec_receive_frame(avctx, frame);
+      if (ret == 0) {
+	got_frame = 1;
+      }
+    }
+      
 
 #ifdef USE_AVRESAMPLE    // libav's AVFrame structure does not contain a 'channels' field
     if (ret >= 0 && got_frame) {
 #else
-    if (ret >= 0 && got_frame && av_frame_get_channels(frame)>0) {
+    if (ret >= 0 && got_frame && frame->ch_layout.nb_channels>0) {
 #endif
         int ch, plane_size;
         int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
@@ -151,11 +158,13 @@ void FFmpegDecoderAudio::open(AVStream *
             return;
 
         m_stream = stream;
-        m_context = stream->codec;
-
-        m_in_sample_rate = m_context->sample_rate;
-        m_in_nb_channels = m_context->channels;
-        m_in_sample_format = m_context->sample_fmt;
+	AVCodecParameters* avp = stream->codecpar;
+        const AVCodec * p_codec = avcodec_find_decoder(avp->codec_id);
+	m_context = avcodec_alloc_context3(p_codec);	  
+
+        m_in_sample_rate = avp->sample_rate;
+        m_in_nb_channels = avp->channels;
+        m_in_sample_format = ((AVSampleFormat)(avp->format));
 
         AVDictionaryEntry *opt_out_sample_rate = av_dict_get( *parameters->getOptions(), "out_sample_rate", NULL, 0 );
         if ( opt_out_sample_rate )
@@ -210,11 +219,10 @@ printf("### CONVERTING from sample forma
         }
 
         // Check stream sanity
-        if (m_context->codec_id == AV_CODEC_ID_NONE)
+        if (avp->codec_id == AV_CODEC_ID_NONE)
             throw std::runtime_error("invalid audio codec");;
 
         // Find the decoder for the audio stream
-        AVCodec * const p_codec = avcodec_find_decoder(m_context->codec_id);
 
         if (p_codec == 0)
             throw std::runtime_error("avcodec_find_decoder() failed");
Index: openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegPacket.hpp
===================================================================
--- openscenegraph-3.6.5+dfsg1.orig/src/osgPlugins/ffmpeg/FFmpegPacket.hpp
+++ openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegPacket.hpp
@@ -42,7 +42,7 @@ namespace osgFFmpeg
         void clear()
         {
             if (packet.data != 0)
-                av_free_packet(&packet);
+                av_packet_unref(&packet);
 
             release();
         }

Attachment: OpenPGP_0x44173FA13D058888.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to