FFmpeg input: Check for seeking errors and stop decoding when they happen

CQTexperiment
Christopher Snowhill 2022-01-09 03:37:45 -08:00
parent 87ebca5e03
commit a1a85c502e
1 changed files with 8 additions and 1 deletions

View File

@ -540,8 +540,15 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
}
AVRational tb = {.num = 1, .den = codecCtx->sample_rate};
int64_t ts = av_rescale_q(frame, tb, formatCtx->streams[streamIndex]->time_base);
avformat_seek_file(formatCtx, streamIndex, ts - 1000, ts, ts, 0);
int ret = avformat_seek_file(formatCtx, streamIndex, ts - 1000, ts, ts, 0);
avcodec_flush_buffers(codecCtx);
if (ret < 0)
{
framesRead = totalFrames;
endOfStream = YES;
endOfAudio = YES;
return -1;
}
readNextPacket = YES; // so we immediately read next packet
bytesConsumedFromDecodedFrame = INT_MAX; // so we immediately begin decoding next frame
framesRead = frame;