History

lavc/bsf: add a showinfo filter

Analogous to the (a)showinfo lavfi filters, logs basic packet information. Mainly useful for debugging/testing/development.

Anton Khirnov committed 2 years ago

Commit aa3cfd41 parent 70ecb825 files · +70 −0Browse files

Unified · Split

5 files
  1. Changelog +1 −0
  2. doc/bitstream_filters.texi +4 −0
  3. libavcodec/bitstream_filters.c +1 −0
  4. libavcodec/bsf/Makefile +1 −0
  5. libavcodec/bsf/showinfo.c +63 −0
Changelog+1−0
@@ -23,6 +23,7 @@ version <next>: · 22 unmodified lines
2323 - ffmpeg CLI -bsf option may now be used for input as well as output
2424 - ffmpeg CLI options may now be used as -/opt <path>, which is equivalent
2525 to -opt <contents of file <path>>
26+- showinfo bitstream filter
2627
2728 version 6.1:
2829 - libaribcaption decoder
doc/bitstream_filters.texi+4−0
@@ -887,6 +887,10 @@ For example, to set PTS equal to DTS (not recommended if B-frames are involved): · 886 unmodified lines
887887 ffmpeg -i INPUT -c:a copy -bsf:a setts=pts=DTS out.mkv
888888 @end example
889889
890+@section showinfo
891+Log basic packet information. Mainly useful for testing, debugging,
892+and development.
893+
890894 @anchor{text2movsub}
891895 @section text2movsub
892896
libavcodec/bitstream_filters.c+1−0
@@ -58,6 +58,7 @@ extern const FFBitStreamFilter ff_pgs_frame_merge_bsf; · 57 unmodified lines
5858 extern const FFBitStreamFilter ff_prores_metadata_bsf;
5959 extern const FFBitStreamFilter ff_remove_extradata_bsf;
6060 extern const FFBitStreamFilter ff_setts_bsf;
61+extern const FFBitStreamFilter ff_showinfo_bsf;
6162 extern const FFBitStreamFilter ff_text2movsub_bsf;
6263 extern const FFBitStreamFilter ff_trace_headers_bsf;
6364 extern const FFBitStreamFilter ff_truehd_core_bsf;
libavcodec/bsf/Makefile+1−0
@@ -36,6 +36,7 @@ OBJS-$(CONFIG_PGS_FRAME_MERGE_BSF) += bsf/pgs_frame_merge.o · 35 unmodified lines
3636 OBJS-$(CONFIG_PRORES_METADATA_BSF) += bsf/prores_metadata.o
3737 OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += bsf/remove_extradata.o
3838 OBJS-$(CONFIG_SETTS_BSF) += bsf/setts.o
39+OBJS-$(CONFIG_SHOWINFO_BSF) += bsf/showinfo.o
3940 OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += bsf/movsub.o
4041 OBJS-$(CONFIG_TRACE_HEADERS_BSF) += bsf/trace_headers.o
4142 OBJS-$(CONFIG_TRUEHD_CORE_BSF) += bsf/truehd_core.o
libavcodec/bsf/showinfo.c+63−0
@@ -0,0 +1,63 @@
1+/*
2+ * Copyright (c) 2024 Anton Khirnov <anton@khirnov.net>
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include <inttypes.h>
22+
23+#include "bsf.h"
24+#include "bsf_internal.h"
25+
26+#include "libavutil/log.h"
27+#include "libavutil/timestamp.h"
28+
29+typedef struct ShowinfoContext {
30+ uint64_t nb_packets;
31+} ShowinfoContext;
32+
33+static int showinfo_filter(AVBSFContext *ctx, AVPacket *pkt)
34+{
35+ ShowinfoContext *priv = ctx->priv_data;
36+ int ret;
37+
38+ ret = ff_bsf_get_packet_ref(ctx, pkt);
39+ if (ret < 0)
40+ return ret;
41+
42+ av_log(ctx, AV_LOG_INFO,
43+ "n:%7"PRIu64" "
44+ "size:%7d "
45+ "pts:%s pt:%s "
46+ "dts:%s dt:%s "
47+ "ds:%"PRId64" d:%s "
48+ "\n",
49+ priv->nb_packets, pkt->size,
50+ av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ctx->time_base_in),
51+ av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ctx->time_base_in),
52+ pkt->duration, av_ts2timestr(pkt->duration, &ctx->time_base_in));
53+
54+ priv->nb_packets++;
55+
56+ return 0;
57+}
58+
59+const FFBitStreamFilter ff_showinfo_bsf = {
60+ .p.name = "showinfo",
61+ .filter = showinfo_filter,
62+ .priv_data_size = sizeof(ShowinfoContext),
63+};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t