[Libav-user] Having problem to seek MPEGTS video using av_seek_frame
zuraq
heziyuz at gmail.com
Fri Mar 12 09:41:53 EET 2021
I'm trying to use ffmpeg function to capture some thumbnail of video. I'm use
the example of the ffmpeg and write code like this:
int timeStamp = ((double)ms / (double)1000) *
pFormatCtx->streams[videoStream]->time_base.den /
pFormatCtx->streams[videoStream]->time_base.num;
int ret = av_seek_frame(pFormatCtx, videoStream, timeStamp,
AVSEEK_FLAG_BACKWARD);
while (av_read_frame(pFormatCtx, &packet) >= 0) {
if (packet.stream_index == videoStream) {
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,
&packet);
if (frameFinished) {
sws_scale(sws_ctx, (uint8_t const * const *) pFrame->data,
pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data,
pFrameRGB->linesize);
if (++i <= 1) {
SaveFrame(pFrameRGB, pCodecCtx->width,
pCodecCtx->height, i);
}
}
}
av_packet_unref(&packet);
}
actually,it works well in .mp4 video. but for .ts video, it can only capture
the first frame of the video, I think the problem is av_seek_frame doesnt
work,but I dont know how to fix the problem. can anyone give me some help?
--
Sent from: http://libav-users.943685.n4.nabble.com/
More information about the Libav-user
mailing list