FFmpeg
showinfo.c
Go to the documentation of this file.
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;
32 
34 {
35  ShowinfoContext *priv = ctx->priv_data;
36  int ret;
37 
39  if (ret < 0)
40  return ret;
41 
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 
60  .p.name = "showinfo",
61  .filter = showinfo_filter,
62  .priv_data_size = sizeof(ShowinfoContext),
63 };
bsf_internal.h
AVBitStreamFilter::name
const char * name
Definition: bsf.h:112
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:542
showinfo_filter
static int showinfo_filter(AVBSFContext *ctx, AVPacket *pkt)
Definition: showinfo.c:33
AVBSFContext
The bitstream filter state.
Definition: bsf.h:68
bsf.h
pkt
AVPacket * pkt
Definition: movenc.c:60
ctx
AVFormatContext * ctx
Definition: movenc.c:49
FFBitStreamFilter
Definition: bsf_internal.h:27
FFBitStreamFilter::p
AVBitStreamFilter p
The public AVBitStreamFilter.
Definition: bsf_internal.h:31
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:83
AVPacket::size
int size
Definition: packet.h:525
ff_showinfo_bsf
const FFBitStreamFilter ff_showinfo_bsf
Definition: showinfo.c:59
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:523
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
log.h
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:517
ShowinfoContext
Definition: showinfo.c:29
ShowinfoContext::nb_packets
uint64_t nb_packets
Definition: showinfo.c:30
ret
ret
Definition: filter_design.txt:187
AVPacket
This structure stores compressed data.
Definition: packet.h:501
timestamp.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_bsf_get_packet_ref
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition: bsf.c:256
av_ts2str
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:54
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1283