FFmpeg  4.2.2
Functions | Variables
demuxing_decoding.c File Reference

Demuxing and decoding example. More...

#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>

Go to the source code of this file.

Functions

static int decode_packet (int *got_frame, int cached)
 
static int open_codec_context (int *stream_idx, AVCodecContext **dec_ctx, AVFormatContext *fmt_ctx, enum AVMediaType type)
 
static int get_format_from_sample_fmt (const char **fmt, enum AVSampleFormat sample_fmt)
 
int main (int argc, char **argv)
 

Variables

static AVFormatContextfmt_ctx = NULL
 
static AVCodecContextvideo_dec_ctx = NULL
 
static AVCodecContextaudio_dec_ctx
 
static int width
 
static int height
 
static enum AVPixelFormat pix_fmt
 
static AVStreamvideo_stream = NULL
 
static AVStreamaudio_stream = NULL
 
static const char * src_filename = NULL
 
static const char * video_dst_filename = NULL
 
static const char * audio_dst_filename = NULL
 
static FILE * video_dst_file = NULL
 
static FILE * audio_dst_file = NULL
 
static uint8_t * video_dst_data [4] = {NULL}
 
static int video_dst_linesize [4]
 
static int video_dst_bufsize
 
static int video_stream_idx = -1
 
static int audio_stream_idx = -1
 
static AVFrameframe = NULL
 
static AVPacket pkt
 
static int video_frame_count = 0
 
static int audio_frame_count = 0
 
static int refcount = 0
 

Detailed Description

Demuxing and decoding example.

Show how to use the libavformat and libavcodec API to demux and decode audio and video data.

Definition in file demuxing_decoding.c.

Function Documentation

◆ decode_packet()

static int decode_packet ( int *  got_frame,
int  cached 
)
static
Examples:
demuxing_decoding.c.

Definition at line 64 of file demuxing_decoding.c.

Referenced by main().

◆ open_codec_context()

static int open_codec_context ( int *  stream_idx,
AVCodecContext **  dec_ctx,
AVFormatContext fmt_ctx,
enum AVMediaType  type 
)
static
Examples:
demuxing_decoding.c.

Definition at line 149 of file demuxing_decoding.c.

Referenced by main().

◆ get_format_from_sample_fmt()

static int get_format_from_sample_fmt ( const char **  fmt,
enum AVSampleFormat  sample_fmt 
)
static
Examples:
demuxing_decoding.c.

Definition at line 202 of file demuxing_decoding.c.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)
Examples:
demuxing_decoding.c.

Definition at line 231 of file demuxing_decoding.c.

Variable Documentation

◆ fmt_ctx

AVFormatContext* fmt_ctx = NULL
static
Examples:
avio_reading.c, demuxing_decoding.c, metadata.c, muxing.c, and remuxing.c.

Definition at line 37 of file demuxing_decoding.c.

Referenced by main().

◆ video_dec_ctx

AVCodecContext* video_dec_ctx = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 38 of file demuxing_decoding.c.

◆ audio_dec_ctx

AVCodecContext * audio_dec_ctx
static
Examples:
demuxing_decoding.c.

Definition at line 38 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ width

int width
static
Examples:
demuxing_decoding.c, muxing.c, and scaling_video.c.

Definition at line 39 of file demuxing_decoding.c.

Referenced by alloc_picture(), decode_packet(), fill_yuv_image(), and main().

◆ height

int height
static
Examples:
demuxing_decoding.c, muxing.c, and scaling_video.c.

Definition at line 39 of file demuxing_decoding.c.

Referenced by alloc_picture(), decode_packet(), fill_yuv_image(), and main().

◆ pix_fmt

enum AVPixelFormat pix_fmt
static
Examples:
demuxing_decoding.c, and muxing.c.

Definition at line 40 of file demuxing_decoding.c.

Referenced by alloc_picture(), decode_packet(), and main().

◆ video_stream

AVStream* video_stream = NULL
static
Examples:
demuxing_decoding.c, and hw_decode.c.

Definition at line 41 of file demuxing_decoding.c.

Referenced by main().

◆ audio_stream

AVStream * audio_stream = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 41 of file demuxing_decoding.c.

Referenced by main().

◆ src_filename

const char* src_filename = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 42 of file demuxing_decoding.c.

Referenced by main(), and open_codec_context().

◆ video_dst_filename

const char* video_dst_filename = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 43 of file demuxing_decoding.c.

Referenced by main().

◆ audio_dst_filename

const char* audio_dst_filename = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 44 of file demuxing_decoding.c.

Referenced by main().

◆ video_dst_file

FILE* video_dst_file = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 45 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ audio_dst_file

FILE* audio_dst_file = NULL
static
Examples:
demuxing_decoding.c.

Definition at line 46 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ video_dst_data

uint8_t* video_dst_data[4] = {NULL}
static
Examples:
demuxing_decoding.c.

Definition at line 48 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ video_dst_linesize

int video_dst_linesize[4]
static
Examples:
demuxing_decoding.c.

Definition at line 49 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ video_dst_bufsize

int video_dst_bufsize
static
Examples:
demuxing_decoding.c.

Definition at line 50 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ video_stream_idx

int video_stream_idx = -1
static
Examples:
demuxing_decoding.c.

Definition at line 52 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ audio_stream_idx

int audio_stream_idx = -1
static
Examples:
demuxing_decoding.c.

Definition at line 52 of file demuxing_decoding.c.

Referenced by decode_packet(), and main().

◆ frame

AVFrame* frame = NULL
static

◆ pkt

AVPacket pkt
static

◆ video_frame_count

int video_frame_count = 0
static
Examples:
demuxing_decoding.c.

Definition at line 55 of file demuxing_decoding.c.

Referenced by decode_packet().

◆ audio_frame_count

int audio_frame_count = 0
static
Examples:
demuxing_decoding.c.

Definition at line 56 of file demuxing_decoding.c.

Referenced by decode_packet().

◆ refcount

int refcount = 0
static
Examples:
demuxing_decoding.c.

Definition at line 62 of file demuxing_decoding.c.

Referenced by decode_packet(), main(), and open_codec_context().