FFmpeg
Loading...
Searching...
No Matches
api-dv-rate-test.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include <inttypes.h>
20#include <stdio.h>
21
23
24int main(int argc, char **argv)
25{
26 AVFormatContext *fmt = NULL;
28 AVPacket *pkt = NULL;
29 AVStream *st;
30 AVRational rate;
31 int ret = 1;
32
33 if (argc != 2)
34 return 1;
35
37 /* Verify that stream probing retains the rate without a DV decoder. */
38 if (av_dict_set(&opts, "codec_whitelist", "rawvideo", 0) < 0 ||
39 avformat_open_input(&fmt, argv[1], NULL, &opts) < 0 ||
40 !fmt->nb_streams)
41 goto end;
42 st = fmt->streams[0];
43 rate = st->codecpar->framerate;
44 printf("coded_rate_at_open=%d/%d\n", rate.num, rate.den);
45 if (avformat_find_stream_info(fmt, NULL) < 0)
46 goto end;
47 rate = st->codecpar->framerate;
48 printf("coded_rate_after_probe=%d/%d\n", rate.num, rate.den);
49
51 if (!pkt || av_read_frame(fmt, pkt) < 0)
52 goto end;
53 printf("duration=%" PRId64 "\n", pkt->duration);
54 printf("avg_frame_rate=%d/%d|time_base=%d/%d\n",
56 st->time_base.num, st->time_base.den);
57 ret = 0;
58
59end:
63 return ret;
64}
static AVDictionary * opts
Main libavformat public API header.
#define NULL
Definition coverity.c:32
__device__ int printf(const char *,...)
static AVPacket * pkt
int main
Definition dovi_rpuenc.c:38
int ret
Definition ffplay.c:391
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition demux.c:1662
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition demux.c:231
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition demux.c:2690
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition demux.c:400
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition dict.c:236
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition dict.c:87
#define AV_LOG_QUIET
Print no output.
Definition log.h:192
void av_log_set_level(int level)
Set the log level.
Definition log.c:482
AVRational framerate
Number of frames per second, for streams with constant frame durations.
Definition codec_par.h:175
Format I/O context.
Definition avformat.h:1401
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition avformat.h:1457
AVStream ** streams
A list of all streams in the file.
Definition avformat.h:1469
This structure stores compressed data.
Definition packet.h:587
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
AVRational avg_frame_rate
Average framerate.
Definition avformat.h:857
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition avformat.h:807