Skip to content

Commit

Permalink
fftools/ffprobe: add only_first_vframe option to show first video frame
Browse files Browse the repository at this point in the history
Currently, ffprobe can only read frames at a specific interval,
and users have no options to select only video frames without
explicitly selecting a stream. This option instructs show_frames
to pick the first video frame and prints its information.
This will be useful for extracting tricky metadata, such as the
HDR10plus ST2094 metadata.
  • Loading branch information
gnattu committed Dec 22, 2024
1 parent 2f3b874 commit 31d75a3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions debian/patches/0084-add-first-vframe-only-to-ffprobe.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Index: FFmpeg/fftools/ffprobe.c
===================================================================
--- FFmpeg.orig/fftools/ffprobe.c
+++ FFmpeg/fftools/ffprobe.c
@@ -146,6 +146,8 @@ static int show_private_data
#define SHOW_OPTIONAL_FIELDS_ALWAYS 1
static int show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;

+static int only_show_first_video_frame = 0;
+
static char *output_format;
static char *stream_specifier;
static char *show_data_hash;
@@ -3159,6 +3161,14 @@ static int read_interval_packets(WriterC
}

frame_count++;
+
+ if (only_show_first_video_frame) {
+ AVCodecParameters *par = ifile->streams[pkt->stream_index].st->codecpar;
+ if (par->codec_type != AVMEDIA_TYPE_VIDEO) {
+ continue;
+ }
+ }
+
if (do_read_packets) {
if (do_show_packets)
show_packet(w, ifile, pkt, i++);
@@ -3179,6 +3189,7 @@ static int read_interval_packets(WriterC

while (process_frame(w, ifile, frame, pkt, &packet_new) > 0);
}
+ if (only_show_first_video_frame) break;
}
av_packet_unref(pkt);
}
@@ -4587,6 +4598,7 @@ static const OptionDef real_options[] =
{ "print_filename", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
{ "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
"read and decode the streams to fill missing information with heuristics" },
+ { "only_first_vframe", OPT_TYPE_BOOL, 0, { &only_show_first_video_frame }, "only show first video frame when show_frames is used" },
{ NULL, },
};

1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@
0081-backport-av1-videotoolbox.patch
0082-fix-ass-incorrect-null-copy.patch
0083-default-to-input-timebase-for-streamcopy.patch
0084-add-first-vframe-only-to-ffprobe.patch

0 comments on commit 31d75a3

Please sign in to comment.