Skip to content

Commit

Permalink
Initialize lastPTS and only set lastAudioPTS if the stream is audio.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Connor committed Sep 25, 2024
1 parent 564e521 commit e7d4fa3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/zm_ffmpeg_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
start_read_time = std::chrono::steady_clock::now();
int ret;
AVFormatContext *formatContextPtr;
int64_t lastPTS;
int64_t lastPTS = -1;

if ( mSecondFormatContext and
(
Expand Down Expand Up @@ -242,7 +242,7 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
}
return -1;
}
if ( packet->stream_index == mAudioStreamId) {
if (packet->stream_index == mAudioStreamId) {
lastPTS = mLastAudioPTS;
} else if ( packet->stream_index == mVideoStreamId) {
lastPTS = mLastVideoPTS;
Expand Down Expand Up @@ -287,7 +287,7 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
mFirstVideoPTS = packet->pts;

mLastVideoPTS = packet->pts - mFirstVideoPTS;
} else {
} else if (stream == mAudioStream) {
if (mFirstAudioPTS == AV_NOPTS_VALUE)
mFirstAudioPTS = packet->pts;

Expand Down

0 comments on commit e7d4fa3

Please sign in to comment.