24 changes: 12 additions & 12 deletions mythtv/libs/libmyth/audio/audiooutputbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ class AudioOutputBase : public AudioOutput, public MThread
int GetSWVolume(void) override; // VolumeBase

// timecode is in milliseconds.
bool AddFrames(void *buffer, int frames, int64_t timecode) override; // AudioOutput
bool AddData(void *buffer, int len, int64_t timecode, int frames) override; // AudioOutput
bool AddFrames(void *buffer, int frames, std::chrono::milliseconds timecode) override; // AudioOutput
bool AddData(void *buffer, int len, std::chrono::milliseconds timecode, int frames) override; // AudioOutput
bool NeedDecodingBeforePassthrough() const override { return false; }; // AudioOutput
int64_t LengthLastData(void) const override { return m_lengthLastData; } // AudioOutput
std::chrono::milliseconds LengthLastData(void) const override { return m_lengthLastData; } // AudioOutput

void SetTimecode(int64_t timecode) override; // AudioOutput
void SetTimecode(std::chrono::milliseconds timecode) override; // AudioOutput
bool IsPaused(void) const override { return m_actuallyPaused; } // AudioOutput
void Pause(bool paused) override; // AudioOutput
void PauseUntilBuffered(void) override; // AudioOutput

// Wait for all data to finish playing
void Drain(void) override; // AudioOutput

int64_t GetAudiotime(void) override; // AudioOutput
int64_t GetAudioBufferedTime(void) override; // AudioOutput
std::chrono::milliseconds GetAudiotime(void) override; // AudioOutput
std::chrono::milliseconds GetAudioBufferedTime(void) override; // AudioOutput

// Send output events showing current progress
virtual void Status(void);
Expand Down Expand Up @@ -162,7 +162,7 @@ class AudioOutputBase : public AudioOutput, public MThread
void SetStretchFactorLocked(float factor);

// For audiooutputca
int GetBaseAudBufTimeCode() const { return m_audbufTimecode; }
std::chrono::milliseconds GetBaseAudBufTimeCode() const { return m_audbufTimecode; }

bool usesSpdif() const { return m_usesSpdif; }

Expand Down Expand Up @@ -218,7 +218,7 @@ class AudioOutputBase : public AudioOutput, public MThread
int &samplerate_tmp, int &channels_tmp);
AudioOutputSettings* OutputSettings(bool digital = true);
int CopyWithUpmix(char *buffer, int frames, uint &org_waud);
void SetAudiotime(int frames, int64_t timecode);
void SetAudiotime(int frames, std::chrono::milliseconds timecode);
AudioOutputSettings *m_outputSettingsRaw {nullptr};
AudioOutputSettings *m_outputSettings {nullptr};
AudioOutputSettings *m_outputSettingsDigitalRaw {nullptr};
Expand Down Expand Up @@ -260,7 +260,7 @@ class AudioOutputBase : public AudioOutput, public MThread
/**
* timecode of audio leaving the soundcard (same units as timecodes)
*/
int64_t m_audioTime {0};
std::chrono::milliseconds m_audioTime {0ms};

/**
* Audio circular buffer
Expand All @@ -270,12 +270,12 @@ class AudioOutputBase : public AudioOutput, public MThread
/**
* timecode of audio most recently placed into buffer
*/
int64_t m_audbufTimecode {0};
std::chrono::milliseconds m_audbufTimecode {0ms};
AsyncLooseLock m_resetActive;

QMutex m_killAudioLock {QMutex::NonRecursive};

long m_currentSeconds {-1};
std::chrono::seconds m_currentSeconds {-1s};

float *m_srcIn;

Expand All @@ -293,7 +293,7 @@ class AudioOutputBase : public AudioOutput, public MThread
std::array<uchar,kAudioRingBufferSize> m_audioBuffer {0};
uint m_memoryCorruptionTest3 {0xdeadbeef};;
bool m_configureSucceeded {false};
int64_t m_lengthLastData {0};
std::chrono::milliseconds m_lengthLastData {0ms};

// SPDIF Encoder for digital passthrough
bool m_usesSpdif {true};
Expand Down
16 changes: 8 additions & 8 deletions mythtv/libs/libmythtv/AirPlay/mythraopconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void MythRAOPConnection::ProcessSync(const QByteArray &buf)
.arg(m_currentTimestamp).arg(m_nextTimestamp).arg(m_timeLastSync));

int64_t delay = framesToMs((uint64_t)m_audioQueue.size() * m_framesPerPacket);
int64_t audiots = m_audio->GetAudiotime();
int64_t audiots = m_audio->GetAudiotime().count();
int64_t currentLatency = 0LL;

if (m_audioStarted)
Expand All @@ -387,7 +387,7 @@ void MythRAOPConnection::ProcessSync(const QByteArray &buf)
.arg(audiots).arg(m_currentTimestamp)
.arg(currentLatency));

delay += m_audio->GetAudioBufferedTime();
delay += m_audio->GetAudioBufferedTime().count();
delay += currentLatency;

LOG(VB_PLAYBACK, LOG_DEBUG, LOC +
Expand Down Expand Up @@ -667,7 +667,7 @@ void MythRAOPConnection::ProcessAudio()
gettimeofday(&t, nullptr);
uint64_t dtime = (t.tv_sec * 1000 + t.tv_usec / 1000) - m_timeLastSync;
uint64_t rtp = dtime + m_currentTimestamp;
uint64_t buffered = m_audioStarted ? m_audio->GetAudioBufferedTime() : 0;
uint64_t buffered = m_audioStarted ? m_audio->GetAudioBufferedTime().count() : 0;

// Keep audio framework buffer as short as possible, keeping everything in
// m_audioQueue, so we can easily reset the least amount possible
Expand Down Expand Up @@ -733,8 +733,8 @@ void MythRAOPConnection::ProcessAudio()
}
m_audio->AddData((char *)data.data + offset,
data.length - offset,
timestamp, framecnt);
timestamp += m_audio->LengthLastData();
std::chrono::milliseconds(timestamp), framecnt);
timestamp += m_audio->LengthLastData().count();
}
i++;
m_audioStarted = true;
Expand Down Expand Up @@ -1311,7 +1311,7 @@ void MythRAOPConnection::ProcessRequest(const QStringList &header,
}
// determine RTP timestamp of last sample played
uint64_t timestamp = m_audioStarted && m_audio ?
m_audio->GetAudiotime() : m_lastTimestamp;
m_audio->GetAudiotime().count() : m_lastTimestamp;
*m_textStream << "RTP-Info: rtptime=" << QString::number(timestamp);
m_streamingStarted = false;
ResetAudio();
Expand Down Expand Up @@ -1713,11 +1713,11 @@ int64_t MythRAOPConnection::AudioCardLatency(void)
int frames = AUDIOCARD_BUFFER * m_frameRate / 1000;
m_audio->AddData((char *)samples,
frames * (m_sampleSize>>3) * m_channels,
0,
0ms,
frames);
av_free(samples);
usleep(AUDIOCARD_BUFFER * 1000);
uint64_t audiots = m_audio->GetAudiotime();
uint64_t audiots = m_audio->GetAudiotime().count();
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("AudioCardLatency: ts=%1ms")
.arg(audiots));
return AUDIOCARD_BUFFER - (int64_t)audiots;
Expand Down
19 changes: 10 additions & 9 deletions mythtv/libs/libmythtv/audioplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ uint AudioPlayer::SetVolume(int newvolume)
return GetVolume();
}

int64_t AudioPlayer::GetAudioTime(void)
std::chrono::milliseconds AudioPlayer::GetAudioTime(void)
{
if (!m_audioOutput || m_noAudioOut)
return 0LL;
return 0ms;
QMutexLocker lock(&m_lock);
return m_audioOutput->GetAudiotime();
}
Expand Down Expand Up @@ -447,12 +447,13 @@ bool AudioPlayer::CanDownmix(void)
* if frames = 0 && len > 0: will calculate according to len
*/
void AudioPlayer::AddAudioData(char *buffer, int len,
int64_t timecode, int frames)
std::chrono::milliseconds timecode, int frames)
{
if (!m_audioOutput || m_noAudioOut)
return;

if (m_parent->PrepareAudioSample(timecode) && !m_noAudioOut)
int64_t tc_tmp = timecode.count();
if (m_parent->PrepareAudioSample(tc_tmp) && !m_noAudioOut)
m_audioOutput->Drain();
int samplesize = m_audioOutput->GetBytesPerFrame();

Expand All @@ -474,10 +475,10 @@ bool AudioPlayer::NeedDecodingBeforePassthrough(void)
return m_audioOutput->NeedDecodingBeforePassthrough();
}

int64_t AudioPlayer::LengthLastData(void)
std::chrono::milliseconds AudioPlayer::LengthLastData(void)
{
if (!m_audioOutput)
return 0;
return 0ms;
return m_audioOutput->LengthLastData();
}

Expand All @@ -499,14 +500,14 @@ bool AudioPlayer::IsBufferAlmostFull(void)
uint othresh = ((ototal>>1) + (ototal>>2));
if (ofill > othresh)
return true;
return GetAudioBufferedTime() > 8000;
return GetAudioBufferedTime() > 8s;
}
return false;
}

int64_t AudioPlayer::GetAudioBufferedTime(void)
std::chrono::milliseconds AudioPlayer::GetAudioBufferedTime(void)
{
return m_audioOutput ? m_audioOutput->GetAudioBufferedTime() : 0;
return m_audioOutput ? m_audioOutput->GetAudioBufferedTime() : 0ms;
}


Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/audioplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MTV_PUBLIC AudioPlayer : public QObject
bool CanDTSHD(void);
uint GetMaxChannels(void);
int GetMaxHDRate(void);
int64_t GetAudioTime(void);
std::chrono::milliseconds GetAudioTime(void);
AudioFormat GetFormat(void) const { return m_state.m_format; }
bool CanProcess(AudioFormat fmt);
uint32_t CanProcess(void);
Expand All @@ -91,12 +91,12 @@ class MTV_PUBLIC AudioPlayer : public QObject
MuteState SetMuteState(MuteState mstate);
MuteState IncrMuteState(void);

void AddAudioData(char *buffer, int len, int64_t timecode, int frames);
void AddAudioData(char *buffer, int len, std::chrono::milliseconds timecode, int frames);
bool NeedDecodingBeforePassthrough(void);
int64_t LengthLastData(void);
std::chrono::milliseconds LengthLastData(void);
bool GetBufferStatus(uint &fill, uint &total);
bool IsBufferAlmostFull(void);
int64_t GetAudioBufferedTime(void);
std::chrono::milliseconds GetAudioBufferedTime(void);

/**
* Return internal AudioOutput object
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4758,10 +4758,10 @@ bool AvFormatDecoder::ProcessAudioPacket(AVStream *curstream, AVPacket *pkt,
int samplesize = AudioOutputSettings::SampleSize(m_audio->GetFormat());
int frames = (ctx->channels <= 0 || decoded_size < 0 || !samplesize) ? -1 :
decoded_size / (ctx->channels * samplesize);
m_audio->AddAudioData((char *)m_audioSamples, data_size, temppts, frames);
m_audio->AddAudioData((char *)m_audioSamples, data_size, std::chrono::milliseconds(temppts), frames);
if (m_audioOut.m_doPassthru && !m_audio->NeedDecodingBeforePassthrough())
{
m_lastAPts += m_audio->LengthLastData();
m_lastAPts += m_audio->LengthLastData().count();
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/mythplayeravsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int64_t MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
{
// cater for DVB radio
if (videotimecode == 0)
videotimecode = Audio->GetAudioTime();;
videotimecode = Audio->GetAudioTime().count();

// cater for data only streams (i.e. MHEG)
bool dataonly = !Audio->HasAudioIn() && !HaveVideo;
Expand Down Expand Up @@ -211,7 +211,7 @@ int64_t MythPlayerAVSync::AVSync(AudioPlayer *Audio, MythVideoFrame *Frame,
}

// get time codes for calculating difference next time
m_priorAudioTimecode = Audio->GetAudioTime();
m_priorAudioTimecode = Audio->GetAudioTime().count();

if (dropframe)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayerui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void MythPlayerUI::EventLoop()
bool audioDrained =
!m_audio.GetAudioOutput() ||
m_audio.IsPaused() ||
m_audio.GetAudioOutput()->GetAudioBufferedTime() < 100;
m_audio.GetAudioOutput()->GetAudioBufferedTime() < 100ms;
if (eof != kEofStateDelayed || (videoDrained && audioDrained))
{
if (eof == kEofStateDelayed)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/visualisations/videovisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void VideoVisual::prepare()
// caller holds lock
VisualNode* VideoVisual::GetNode(void)
{
int64_t timestamp = m_audio->GetAudioTime();
int64_t timestamp = m_audio->GetAudioTime().count();
while (m_nodes.size() > 1)
{
if (m_nodes.front()->m_offset > timestamp)
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/mythfrontend/audiogeneralsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,12 @@ void AudioTestThread::run()
AudioOutputUtil::GeneratePinkFrames(frames, m_channels,
current, 1000,
m_hd ? 32 : 16);
if (!m_audioOutput->AddFrames(frames, 1000 , -1))
if (!m_audioOutput->AddFrames(frames, 1000 , -1ms))
{
LOG(VB_AUDIO, LOG_ERR, "AddData() Audio buffer "
"overflow, audio data lost!");
}
std::this_thread::sleep_for(std::chrono::milliseconds(m_audioOutput->LengthLastData()));
std::this_thread::sleep_for(m_audioOutput->LengthLastData());
}
m_audioOutput->Drain();
m_audioOutput->Pause(true);
Expand Down
16 changes: 8 additions & 8 deletions mythtv/programs/mythtranscode/audioreencodebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ AudioBuffer::~AudioBuffer()
}

void AudioBuffer::appendData(unsigned char *buffer, int len, int frames,
long long time)
std::chrono::milliseconds time)
{
if ((m_size + len) > m_realsize)
{
Expand Down Expand Up @@ -118,7 +118,7 @@ void AudioReencodeBuffer::Reset(void)
* \return false if there wasn't enough space in audio buffer to
* process all the data
*/
bool AudioReencodeBuffer::AddFrames(void *buffer, int frames, int64_t timecode)
bool AudioReencodeBuffer::AddFrames(void *buffer, int frames, std::chrono::milliseconds timecode)
{
return AddData(buffer, frames * m_bytes_per_frame, timecode, frames);
}
Expand All @@ -134,7 +134,7 @@ bool AudioReencodeBuffer::AddFrames(void *buffer, int frames, int64_t timecode)
* \return false if there wasn't enough space in audio buffer to
* process all the data
*/
bool AudioReencodeBuffer::AddData(void *buffer, int len, int64_t timecode,
bool AudioReencodeBuffer::AddData(void *buffer, int len, std::chrono::milliseconds timecode,
int frames)
{
auto *buf = (unsigned char *)buffer;
Expand All @@ -158,7 +158,7 @@ bool AudioReencodeBuffer::AddData(void *buffer, int len, int64_t timecode,
int bufsize = m_saveBuffer->size();
int part = std::min(len - index, m_audioFrameSize - bufsize);
int out_frames = part / m_bytes_per_frame;
timecode += out_frames * 1000 / m_eff_audiorate;
timecode += std::chrono::milliseconds(out_frames * 1000 / m_eff_audiorate);

// Store frames in buffer, basing frame count on number of
// bytes, which works only for uncompressed data.
Expand Down Expand Up @@ -187,7 +187,7 @@ bool AudioReencodeBuffer::AddData(void *buffer, int len, int64_t timecode,
// and use 'frames' directly rather than 'len / m_bytes_per_frame',
// thus also covering the passthrough case.
m_saveBuffer = new AudioBuffer();
timecode += frames * 1000 / m_eff_audiorate;
timecode += std::chrono::milliseconds(frames * 1000 / m_eff_audiorate);
m_saveBuffer->appendData(buf, len, frames, timecode);

QMutexLocker locker(&m_bufferMutex);
Expand All @@ -199,7 +199,7 @@ bool AudioReencodeBuffer::AddData(void *buffer, int len, int64_t timecode,
return true;
}

AudioBuffer *AudioReencodeBuffer::GetData(long long time)
AudioBuffer *AudioReencodeBuffer::GetData(std::chrono::milliseconds time)
{
QMutexLocker locker(&m_bufferMutex);

Expand All @@ -217,7 +217,7 @@ AudioBuffer *AudioReencodeBuffer::GetData(long long time)
return nullptr;
}

long long AudioReencodeBuffer::GetSamples(long long time)
long long AudioReencodeBuffer::GetSamples(std::chrono::milliseconds time)
{
QMutexLocker locker(&m_bufferMutex);

Expand All @@ -235,7 +235,7 @@ long long AudioReencodeBuffer::GetSamples(long long time)
return samples;
}

void AudioReencodeBuffer::SetTimecode(int64_t timecode)
void AudioReencodeBuffer::SetTimecode(std::chrono::milliseconds timecode)
{
m_last_audiotime = timecode;
}
Expand Down
18 changes: 9 additions & 9 deletions mythtv/programs/mythtranscode/audioreencodebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class AudioBuffer
AudioBuffer(const AudioBuffer &old);
~AudioBuffer();

void appendData(unsigned char *buffer, int len, int frames, long long time);
void appendData(unsigned char *buffer, int len, int frames, std::chrono::milliseconds time);
char *data(void) const { return (char *)m_buffer; }
int size(void) const { return m_size; }

uint8_t *m_buffer {nullptr};
int m_size {0};
int m_realsize {ABLOCK_SIZE};
int m_frames {0};
long long m_time {-1};
std::chrono::milliseconds m_time {-1ms};
};

/**
Expand All @@ -38,17 +38,17 @@ class AudioReencodeBuffer : public AudioOutput
void Reconfigure(const AudioSettings &settings) override; // AudioOutput
void SetEffDsp(int dsprate) override; // AudioOutput
void Reset(void) override; // AudioOutput
bool AddFrames(void *buffer, int frames, int64_t timecode) override; // AudioOutput
bool AddData(void *buffer, int len, int64_t timecode,
bool AddFrames(void *buffer, int frames, std::chrono::milliseconds timecode) override; // AudioOutput
bool AddData(void *buffer, int len, std::chrono::milliseconds timecode,
int frames) override; // AudioOutput
AudioBuffer *GetData(long long time);
long long GetSamples(long long time);
void SetTimecode(int64_t timecode) override; // AudioOutput
AudioBuffer *GetData(std::chrono::milliseconds time);
long long GetSamples(std::chrono::milliseconds time);
void SetTimecode(std::chrono::milliseconds timecode) override; // AudioOutput
bool IsPaused(void) const override { return false; } // AudioOutput
void Pause(bool paused) override { (void)paused; } // AudioOutput
void PauseUntilBuffered(void) override { } // AudioOutput
void Drain(void) override { } // AudioOutput
int64_t GetAudiotime(void) override { return m_last_audiotime; } // AudioOutput
std::chrono::milliseconds GetAudiotime(void) override { return m_last_audiotime; } // AudioOutput
int GetVolumeChannel(int /*channel*/) const override { return 100; } // VolumeBase
void SetVolumeChannel(int /*channel*/, int /*volume*/) override { } // VolumeBase
uint GetCurrentVolume(void) const override { return 100; } // VolumeBase
Expand All @@ -71,7 +71,7 @@ class AudioReencodeBuffer : public AudioOutput
int m_channels {-1};
int m_bytes_per_frame {-1};
int m_eff_audiorate {-1};
long long m_last_audiotime {0};
std::chrono::milliseconds m_last_audiotime {0ms};
bool m_passthru {false};
int m_audioFrameSize {0};

Expand Down
49 changes: 26 additions & 23 deletions mythtv/programs/mythtranscode/transcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,11 @@ int Transcode::TranscodeFile(const QString &inputname,
long totalAudio = 0;
int dropvideo = 0;
// timecode of the last read video frame in input time
long long lasttimecode = 0;
std::chrono::milliseconds lasttimecode = 0ms;
// timecode of the last write video frame in input or output time
long long lastWrittenTime = 0;
std::chrono::milliseconds lastWrittenTime = 0ms;
// delta between the same video frame in input and output due to applying the cut list
long long timecodeOffset = 0;
std::chrono::milliseconds timecodeOffset = 0ms;

float rateTimeConv = arb->m_eff_audiorate / 1000.0F;
float vidFrameTime = 1000.0F / video_frame_rate;
Expand Down Expand Up @@ -1059,8 +1059,8 @@ int Transcode::TranscodeFile(const QString &inputname,
frame.m_timecode = lastDecode->m_timecode;

// if the timecode jumps backwards just use the last frame's timecode plus the duration of a frame
if (frame.m_timecode < lasttimecode)
frame.m_timecode = (long long)(lasttimecode + vidFrameTime);
if (frame.m_timecode < lasttimecode.count())
frame.m_timecode = (long long)(lasttimecode.count() + vidFrameTime);

if (m_fifow)
{
Expand All @@ -1076,7 +1076,7 @@ int Transcode::TranscodeFile(const QString &inputname,
sws_scale(scontext, imageIn.data, imageIn.linesize, 0,
lastDecode->m_height, imageOut.data, imageOut.linesize);

totalAudio += arb->GetSamples(frame.m_timecode);
totalAudio += arb->GetSamples(std::chrono::milliseconds(frame.m_timecode));
int audbufTime = (int)(totalAudio / rateTimeConv);
int auddelta = frame.m_timecode - audbufTime;
int vidTime = lroundf(curFrameNum * vidFrameTime);
Expand Down Expand Up @@ -1141,7 +1141,7 @@ int Transcode::TranscodeFile(const QString &inputname,
.arg(delta));
#endif
AudioBuffer *ab = nullptr;
while ((ab = arb->GetData(frame.m_timecode)) != nullptr)
while ((ab = arb->GetData(std::chrono::milliseconds(frame.m_timecode))) != nullptr)
{
if (!cutter ||
!cutter->InhibitUseAudioFrames(ab->m_frames, &totalAudio))
Expand Down Expand Up @@ -1175,7 +1175,7 @@ int Transcode::TranscodeFile(const QString &inputname,
}
videoOutput->DoneDisplayingFrame(lastDecode);
player->GetCC608Reader()->FlushTxtBuffers();
lasttimecode = frame.m_timecode;
lasttimecode = std::chrono::milliseconds(frame.m_timecode);
}
else if (copyaudio)
{
Expand Down Expand Up @@ -1228,14 +1228,15 @@ int Transcode::TranscodeFile(const QString &inputname,

if (did_ff == 1)
{
timecodeOffset +=
(frame.m_timecode - lasttimecode - (int)vidFrameTime);
timecodeOffset += (std::chrono::milliseconds(frame.m_timecode) -
lasttimecode -
std::chrono::milliseconds((int)vidFrameTime));
}
lasttimecode = frame.m_timecode;
lasttimecode = std::chrono::milliseconds(frame.m_timecode);
// from here on the timecode is on the output time base
frame.m_timecode -= timecodeOffset;
frame.m_timecode -= timecodeOffset.count();

if (!player->WriteStoredData(m_outBuffer, (did_ff == 0), timecodeOffset))
if (!player->WriteStoredData(m_outBuffer, (did_ff == 0), timecodeOffset.count()))
{
if (video_aspect != new_aspect)
{
Expand Down Expand Up @@ -1295,8 +1296,9 @@ int Transcode::TranscodeFile(const QString &inputname,
if (did_ff == 1)
{
did_ff = 2;
timecodeOffset +=
(frame.m_timecode - lasttimecode - (int)vidFrameTime);
timecodeOffset += (std::chrono::milliseconds(frame.m_timecode) -
lasttimecode -
std::chrono::milliseconds((int)vidFrameTime));
}

if (video_aspect != new_aspect)
Expand Down Expand Up @@ -1348,8 +1350,9 @@ int Transcode::TranscodeFile(const QString &inputname,
{
if (did_ff != 1)
{
long long tc = ab->m_time - timecodeOffset;
avfw->WriteAudioFrame(buf, audioFrame, tc);
std::chrono::milliseconds tc = ab->m_time - timecodeOffset;
long long tc_tmp = tc.count();
avfw->WriteAudioFrame(buf, audioFrame, tc_tmp);

if (avfw2)
{
Expand All @@ -1361,7 +1364,7 @@ int Transcode::TranscodeFile(const QString &inputname,
}

tc = ab->m_time - timecodeOffset;
avfw2->WriteAudioFrame(buf, audioFrame, tc);
avfw2->WriteAudioFrame(buf, audioFrame, tc_tmp);
}

++audioFrame;
Expand All @@ -1372,7 +1375,7 @@ int Transcode::TranscodeFile(const QString &inputname,
{
m_nvr->SetOption("audioframesize", ab->size());
m_nvr->WriteAudio(buf, audioFrame++,
ab->m_time - timecodeOffset);
(ab->m_time - timecodeOffset).count());
if (m_nvr->IsErrored())
{
LOG(VB_GENERAL, LOG_ERR,
Expand Down Expand Up @@ -1400,8 +1403,8 @@ int Transcode::TranscodeFile(const QString &inputname,
return REENCODE_ERROR;
#endif
}
lasttimecode = frame.m_timecode;
frame.m_timecode -= timecodeOffset;
lasttimecode = std::chrono::milliseconds(frame.m_timecode);
frame.m_timecode -= timecodeOffset.count();

if (m_avfMode)
{
Expand Down Expand Up @@ -1429,7 +1432,7 @@ int Transcode::TranscodeFile(const QString &inputname,

if (avfw->WriteVideoFrame(rescale ? &frame : lastDecode) > 0)
{
lastWrittenTime = frame.m_timecode + timecodeOffset;
lastWrittenTime = std::chrono::milliseconds(frame.m_timecode) + timecodeOffset;
if (hls)
++hlsSegmentFrames;
}
Expand All @@ -1443,7 +1446,7 @@ int Transcode::TranscodeFile(const QString &inputname,
m_nvr->WriteVideo(rescale ? &frame : lastDecode, true, true);
else
m_nvr->WriteVideo(rescale ? &frame : lastDecode);
lastWrittenTime = frame.m_timecode + timecodeOffset;
lastWrittenTime = std::chrono::milliseconds(frame.m_timecode) + timecodeOffset;
}
#endif
}
Expand Down