Fix using wrong stream to set codec_type

pull/3187/head
Isaac Connor 2021-03-03 15:24:11 -05:00
parent 8a33fb6665
commit 253ed928ec
1 changed files with 4 additions and 5 deletions

View File

@ -192,7 +192,6 @@ int FfmpegCamera::Capture(ZMPacket &zm_packet) {
int ret;
AVStream *stream;
if ( mSecondFormatContext and
(
av_rescale_q(mLastAudioPTS, mAudioStream->time_base, AV_TIME_BASE_Q)
@ -201,17 +200,14 @@ int FfmpegCamera::Capture(ZMPacket &zm_packet) {
) ) {
// if audio stream is behind video stream, then read from audio, otherwise video
mFormatContextPtr = mSecondFormatContext;
stream = mAudioStream;
Debug(1, "Using audio input");
} else {
mFormatContextPtr = mFormatContext;
stream = mVideoStream;
Debug(1, "Using video input beacuse %" PRId64 " >= %" PRId64,
av_rescale_q(mLastAudioPTS, mAudioStream->time_base, AV_TIME_BASE_Q),
av_rescale_q(mLastVideoPTS, mVideoStream->time_base, AV_TIME_BASE_Q)
);
}
}
if ( (ret = av_read_frame(mFormatContextPtr, &packet)) < 0 ) {
if (
@ -228,6 +224,9 @@ int FfmpegCamera::Capture(ZMPacket &zm_packet) {
}
return -1;
}
AVStream *stream = mFormatContextPtr->streams[packet.stream_index];
ZM_DUMP_STREAM_PACKET(stream, packet, "ffmpeg_camera in");
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)