相关疑难解决方法(0)

使用libav(ffmpeg)使用时间戳/时基进行帧搜索/读取有什么问题?

因此,我想使用libav 在特定时间从视频抓取一个帧作为缩略图使用.

我正在使用的是以下代码.它编译和工作正常(关于检索图片),但我很难找到它来检索正确的图片.

我根本无法理解libav明显使用每个视频的多个时基背后的明确逻辑.具体说明哪些函数期望/返回哪种类型的时基.

不幸的是,文档基本上没有任何帮助.那么救援?

#define ABORT(x) do {fprintf(stderr, x); exit(1);} while(0)

av_register_all();

AVFormatContext *format_context = ...;
AVCodec *codec = ...;
AVStream *stream = ...;
AVCodecContext *codec_context = ...;
int stream_index = ...;

// open codec_context, etc.

AVRational stream_time_base = stream->time_base;
AVRational codec_time_base = codec_context->time_base;

printf("stream_time_base: %d / %d = %.5f\n", stream_time_base.num, stream_time_base.den, av_q2d(stream_time_base));
printf("codec_time_base: %d / %d = %.5f\n\n", codec_time_base.num, codec_time_base.den, av_q2d(codec_time_base));

AVFrame *frame = avcodec_alloc_frame();

printf("duration: %lld @ %d/sec (%.2f sec)\n", …
Run Code Online (Sandbox Code Playgroud)

video ffmpeg libav

10
推荐指数
2
解决办法
8002
查看次数

标签 统计

ffmpeg ×1

libav ×1

video ×1