Hi, Thanks for the feedback. After having another look, this can actually already be done with ffprobe. I was incorrectly using -show_frames instead of -show_packets, causing a big performance hit.
This works well, with the same performance: ffprobe -show_packets -print_format compact input.mkv | grep -n flags=K | cut -f1 -d: Thanks, -Jonathan. On Mon, May 4, 2015 at 11:01 PM, Michael Niedermayer <michae...@gmx.at> wrote: > 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 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel