Skip to content

Commit

Permalink
Fix playback of RAW files (no container)
Browse files Browse the repository at this point in the history
Rename m_currentPts to m_nextSamplePts to make it more descriptive.
Fix case when a sample has a Pts, would not increment the timestamp for the next sample
  • Loading branch information
Gilles Khouzam committed Sep 18, 2017
1 parent c2bcfe1 commit d08948c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions FFmpegInterop/Source/MediaSampleProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MediaSampleProvider::MediaSampleProvider(
, m_pAvCodecCtx(avCodecCtx)
, m_streamIndex(AVERROR_STREAM_NOT_FOUND)
, m_startOffset(AV_NOPTS_VALUE)
, m_currentPts(0)
, m_nextFramePts(0)
{
DebugMessage(L"MediaSampleProvider\n");
}
Expand All @@ -41,7 +41,7 @@ HRESULT MediaSampleProvider::AllocateResources()
{
DebugMessage(L"AllocateResources\n");
m_startOffset = AV_NOPTS_VALUE;
m_currentPts = 0;
m_nextFramePts = 0;
return S_OK;
}

Expand Down Expand Up @@ -104,12 +104,14 @@ HRESULT MediaSampleProvider::DecodeAVPacket(DataWriter^ dataWriter, AVPacket *av
if (avPacket->pts != AV_NOPTS_VALUE)
{
framePts = avPacket->pts;
m_currentPts = framePts;
// Set the PTS for the next sample if it doesn't one.
m_nextFramePts = framePts + frameDuration;
}
else
{
framePts = m_currentPts;
m_currentPts += frameDuration;
framePts = m_nextFramePts;
// Set the PTS for the next sample if it doesn't one.
m_nextFramePts += frameDuration;
}
}
return S_OK;
Expand Down
2 changes: 1 addition & 1 deletion FFmpegInterop/Source/MediaSampleProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace FFmpegInterop
std::vector<AVPacket> m_packetQueue;
int m_streamIndex;
int64 m_startOffset;
int64 m_currentPts;
int64 m_nextFramePts;

internal:
// The FFmpeg context. Because they are complex types
Expand Down

0 comments on commit d08948c

Please sign in to comment.