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

Showing the changes to libavcodec (3 of 5 files). Show all

Unified · Split

3 files
  1. libavcodec/bitstream_filters.c +1 −0
  2. libavcodec/bsf/Makefile +1 −0
  3. libavcodec/bsf/showinfo.c +63 −0
libavcodec/bitstream_filters.c+1−0
@@ -58,6 +58,7 @@ extern const FFBitStreamFilter ff_pgs_frame_merge_bsf; · 57 unmodified lines
58extern const FFBitStreamFilter ff_prores_metadata_bsf;58extern const FFBitStreamFilter ff_prores_metadata_bsf;
59extern const FFBitStreamFilter ff_remove_extradata_bsf;59extern const FFBitStreamFilter ff_remove_extradata_bsf;
60extern const FFBitStreamFilter ff_setts_bsf;60extern const FFBitStreamFilter ff_setts_bsf;
61extern const FFBitStreamFilter ff_showinfo_bsf;
61extern const FFBitStreamFilter ff_text2movsub_bsf;62extern const FFBitStreamFilter ff_text2movsub_bsf;
62extern const FFBitStreamFilter ff_trace_headers_bsf;63extern const FFBitStreamFilter ff_trace_headers_bsf;
63extern const FFBitStreamFilter ff_truehd_core_bsf;64extern 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
36OBJS-$(CONFIG_PRORES_METADATA_BSF) += bsf/prores_metadata.o36OBJS-$(CONFIG_PRORES_METADATA_BSF) += bsf/prores_metadata.o
37OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += bsf/remove_extradata.o37OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += bsf/remove_extradata.o
38OBJS-$(CONFIG_SETTS_BSF) += bsf/setts.o38OBJS-$(CONFIG_SETTS_BSF) += bsf/setts.o
39OBJS-$(CONFIG_SHOWINFO_BSF) += bsf/showinfo.o
39OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += bsf/movsub.o40OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += bsf/movsub.o
40OBJS-$(CONFIG_TRACE_HEADERS_BSF) += bsf/trace_headers.o41OBJS-$(CONFIG_TRACE_HEADERS_BSF) += bsf/trace_headers.o
41OBJS-$(CONFIG_TRUEHD_CORE_BSF) += bsf/truehd_core.o42OBJS-$(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
29typedef struct ShowinfoContext {
30 uint64_t nb_packets;
31} ShowinfoContext;
32
33static 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
59const 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