1+ #include < strings.h>
2+
13#include " mythlogging.h"
24#include " packetqueue.h"
35#include " resultslist.h"
@@ -41,6 +43,12 @@ void AudioConsumer::ProcessPacket(Packet *packet)
4143 m_codec = avcodec_find_decoder (curstream->codec ->codec_id );
4244 if (avcodec_open (m_context, m_codec) < 0 )
4345 return ;
46+
47+ m_stream = curstream;
48+
49+ memcpy (&m_timebase, &curstream->time_base , sizeof (m_timebase));
50+ LOG (VB_GENERAL, LOG_NOTICE, QString (" Audio: num = %1, den = %2" )
51+ .arg (m_timebase.num ) .arg (m_timebase.den ));
4452 m_opened = true ;
4553 }
4654
@@ -109,7 +117,7 @@ void AudioConsumer::ProcessFrame(int16_t *samples, int size, int frames,
109117 LOG (VB_GENERAL, LOG_INFO, QString (" Audio Frame: %1 samples (%2 size)" )
110118 .arg (frames).arg (size));
111119
112- uint64_t duration = (uint64_t )((double )(frames * 1000 ) / rate);
120+ int duration = (int )((double )(frames * 1000000 ) / ( rate * 1.0 ) );
113121 AudioPacket *audioPacket = NULL ;
114122
115123 // Push PCM frame to GPU/CPU Processing memory
@@ -132,9 +140,12 @@ void AudioConsumer::ProcessFrame(int16_t *samples, int size, int frames,
132140 // Toss the results onto the results list
133141 if (result)
134142 {
143+ static AVRational realTimeBase = { 1 , 1000 };
135144 LOG (VB_GENERAL, LOG_INFO, " Audio Finding found" );
136- result->m_pts = pts;
145+ pts = av_rescale_q (pts, realTimeBase, m_timebase);
146+ result->m_timestamp = NormalizeTimecode (pts);;
137147 result->m_duration = duration;
148+ LOG (VB_GENERAL, LOG_INFO, result->toString ());
138149 m_outL->append (result);
139150 }
140151 }
@@ -146,6 +157,7 @@ void AudioConsumer::ProcessFrame(int16_t *samples, int size, int frames,
146157 }
147158}
148159
160+
149161/*
150162 * vim:ts=4:sw=4:ai:et:si:sts=4
151163 */
0 commit comments