[FFmpeg-devel] [PATCH] libavformat/keyframes: output keyframe indexes
Michael Niedermayer
michaelni at gmx.at
Mon May 4 13:01:13 CEST 2015
On Mon, May 04, 2015 at 02:35:45AM +1200, Jonathan Viney wrote:
> Hi,
>
> First patch here. I wrote this format to be able to get the keyframe
> indexes faster than seemed possible with ffprobe, and also to get more
> familiar with ffmpeg.
>
> ffmpeg -i input.mkv -c copy -f keyframes -keyframes_filename keyframes.txt
> /dev/null
>
> Could something like this be included in ffmpeg? Or is this already
> achievable with the current code?
iam a bit undecided if this is a good idea but
why is this faster than ffprobe ? or rather why is ffprobe slow ?
[...]
> +
> +#include "avformat.h"
> +#include "libavutil/opt.h"
> +
> +typedef struct {
> + const AVClass *class;
> + int frame_count;
> + char *filename;
> + FILE *file;
> +} KeyFramesContext;
> +
> +av_cold static int kf_init(AVFormatContext *s)
> +{
> + KeyFramesContext *kf = s->priv_data;
> +
> + kf->file = fopen(kf->filename, "w");
this should use the io context like any other muxer not bypass it
with fopen/f*...
> +
> + if (kf->file) {
> + av_log(s, AV_LOG_ERROR, "failed opening key frames file: %s\n",
> kf->filename);
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> +static int kf_write_packet(struct AVFormatContext *s, AVPacket *pkt)
> +{
> + KeyFramesContext *kf = s->priv_data;
> +
> + if (pkt->flags & AV_PKT_FLAG_KEY) {
> + av_log(s, AV_LOG_DEBUG, "key frame at index %d\n",
> kf->frame_count);
patch is corrupted by linebreaks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150504/1a254388/attachment.asc>
More information about the ffmpeg-devel
mailing list