FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
muxing.c File Reference

libavformat API example. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <libavutil/avassert.h>
#include <libavutil/channel_layout.h>
#include <libavutil/opt.h>
#include <libavutil/mathematics.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>

Go to the source code of this file.

Data Structures

struct  OutputStream
 

Macros

#define STREAM_DURATION   10.0
 
#define STREAM_FRAME_RATE   25 /* 25 images/s */
 
#define STREAM_PIX_FMT   AV_PIX_FMT_YUV420P /* default pix_fmt */
 
#define SCALE_FLAGS   SWS_BICUBIC
 

Functions

static void log_packet (const AVFormatContext *fmt_ctx, const AVPacket *pkt)
 
static int write_frame (AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
 
static void add_stream (OutputStream *ost, AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id)
 
static AVFramealloc_audio_frame (enum AVSampleFormat sample_fmt, uint64_t channel_layout, int sample_rate, int nb_samples)
 
static void open_audio (AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
 
static AVFrameget_audio_frame (OutputStream *ost)
 
static int write_audio_frame (AVFormatContext *oc, OutputStream *ost)
 
static AVFramealloc_picture (enum AVPixelFormat pix_fmt, int width, int height)
 
static void open_video (AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
 
static void fill_yuv_image (AVFrame *pict, int frame_index, int width, int height)
 
static AVFrameget_video_frame (OutputStream *ost)
 
static int write_video_frame (AVFormatContext *oc, OutputStream *ost)
 
static void close_stream (AVFormatContext *oc, OutputStream *ost)
 
int main (int argc, char **argv)
 

Detailed Description

libavformat API example.

Output a media file in any supported libavformat format. The default codecs are used.

Definition in file muxing.c.

Macro Definition Documentation

#define STREAM_DURATION   10.0
Examples:
muxing.c.

Definition at line 46 of file muxing.c.

Referenced by get_audio_frame(), and get_video_frame().

#define STREAM_FRAME_RATE   25 /* 25 images/s */
Examples:
muxing.c.

Definition at line 47 of file muxing.c.

Referenced by add_stream().

#define STREAM_PIX_FMT   AV_PIX_FMT_YUV420P /* default pix_fmt */
Examples:
muxing.c.

Definition at line 48 of file muxing.c.

Referenced by add_stream().

#define SCALE_FLAGS   SWS_BICUBIC
Examples:
muxing.c.

Definition at line 50 of file muxing.c.

Function Documentation

static void log_packet ( const AVFormatContext fmt_ctx,
const AVPacket pkt 
)
static
Examples:
muxing.c.

Definition at line 69 of file muxing.c.

Referenced by write_frame().

static int write_frame ( AVFormatContext fmt_ctx,
const AVRational time_base,
AVStream st,
AVPacket pkt 
)
static
Examples:
muxing.c.

Definition at line 80 of file muxing.c.

Referenced by write_video_frame().

static void add_stream ( OutputStream ost,
AVFormatContext oc,
AVCodec **  codec,
enum AVCodecID  codec_id 
)
static
Examples:
muxing.c.

Definition at line 92 of file muxing.c.

Referenced by main().

static AVFrame* alloc_audio_frame ( enum AVSampleFormat  sample_fmt,
uint64_t  channel_layout,
int  sample_rate,
int  nb_samples 
)
static
Examples:
muxing.c.

Definition at line 181 of file muxing.c.

Referenced by open_audio().

static void open_audio ( AVFormatContext oc,
AVCodec codec,
OutputStream ost,
AVDictionary opt_arg 
)
static
Examples:
muxing.c.

Definition at line 209 of file muxing.c.

Referenced by main().

static AVFrame* get_audio_frame ( OutputStream ost)
static
Examples:
muxing.c.

Definition at line 267 of file muxing.c.

Referenced by write_audio_frame().

static int write_audio_frame ( AVFormatContext oc,
OutputStream ost 
)
static
Examples:
muxing.c.

Definition at line 296 of file muxing.c.

Referenced by main().

static AVFrame* alloc_picture ( enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)
static
Examples:
muxing.c.

Definition at line 360 of file muxing.c.

Referenced by open_video().

static void open_video ( AVFormatContext oc,
AVCodec codec,
OutputStream ost,
AVDictionary opt_arg 
)
static
Examples:
muxing.c.

Definition at line 383 of file muxing.c.

Referenced by main().

static void fill_yuv_image ( AVFrame pict,
int  frame_index,
int  width,
int  height 
)
static
Examples:
muxing.c.

Definition at line 420 of file muxing.c.

static AVFrame* get_video_frame ( OutputStream ost)
static
Examples:
muxing.c.

Definition at line 449 of file muxing.c.

Referenced by write_video_frame().

static int write_video_frame ( AVFormatContext oc,
OutputStream ost 
)
static
Examples:
muxing.c.

Definition at line 490 of file muxing.c.

Referenced by main().

static void close_stream ( AVFormatContext oc,
OutputStream ost 
)
static
Examples:
muxing.c.

Definition at line 544 of file muxing.c.

Referenced by main().

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

Definition at line 556 of file muxing.c.