Libav
Data Structures | Macros | Functions
output.c File Reference

libavformat API example. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "libavutil/channel_layout.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavformat/avformat.h"
#include "libavresample/avresample.h"
#include "libswscale/swscale.h"

Go to the source code of this file.

Data Structures

struct  OutputStream
 

Macros

#define STREAM_DURATION   5.0
 
#define STREAM_FRAME_RATE   25 /* 25 images/s */
 
#define STREAM_NB_FRAMES   ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
 
#define STREAM_PIX_FMT   AV_PIX_FMT_YUV420P /* default pix_fmt */
 
#define SCALE_FLAGS   SWS_BICUBIC
 

Functions

static void add_audio_stream (OutputStream *ost, AVFormatContext *oc, 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, OutputStream *ost)
 
static AVFrameget_audio_frame (OutputStream *ost)
 
static int encode_audio_frame (AVFormatContext *oc, OutputStream *ost, AVFrame *frame)
 
static int process_audio_stream (AVFormatContext *oc, OutputStream *ost)
 
static void add_video_stream (OutputStream *ost, AVFormatContext *oc, enum AVCodecID codec_id)
 
static AVFramealloc_picture (enum AVPixelFormat pix_fmt, int width, int height)
 
static void open_video (AVFormatContext *oc, OutputStream *ost)
 
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.

Definition in file output.c.

Macro Definition Documentation

◆ STREAM_DURATION

#define STREAM_DURATION   5.0

Definition at line 45 of file output.c.

Referenced by get_audio_frame(), and get_video_frame().

◆ STREAM_FRAME_RATE

#define STREAM_FRAME_RATE   25 /* 25 images/s */

Definition at line 46 of file output.c.

Referenced by add_video_stream().

◆ STREAM_NB_FRAMES

#define STREAM_NB_FRAMES   ((int)(STREAM_DURATION * STREAM_FRAME_RATE))

Definition at line 47 of file output.c.

◆ STREAM_PIX_FMT

#define STREAM_PIX_FMT   AV_PIX_FMT_YUV420P /* default pix_fmt */

Definition at line 48 of file output.c.

Referenced by add_video_stream().

◆ SCALE_FLAGS

#define SCALE_FLAGS   SWS_BICUBIC

Definition at line 50 of file output.c.

Referenced by get_video_frame().

Function Documentation

◆ add_audio_stream()

static void add_audio_stream ( OutputStream ost,
AVFormatContext oc,
enum AVCodecID  codec_id 
)
static

Definition at line 75 of file output.c.

Referenced by main().

◆ alloc_audio_frame()

static AVFrame* alloc_audio_frame ( enum AVSampleFormat  sample_fmt,
uint64_t  channel_layout,
int  sample_rate,
int  nb_samples 
)
static

Definition at line 140 of file output.c.

Referenced by open_audio().

◆ open_audio()

static void open_audio ( AVFormatContext oc,
OutputStream ost 
)
static

Definition at line 168 of file output.c.

Referenced by main().

◆ get_audio_frame()

static AVFrame* get_audio_frame ( OutputStream ost)
static

Definition at line 207 of file output.c.

Referenced by process_audio_stream().

◆ encode_audio_frame()

static int encode_audio_frame ( AVFormatContext oc,
OutputStream ost,
AVFrame frame 
)
static

Definition at line 233 of file output.c.

Referenced by process_audio_stream().

◆ process_audio_stream()

static int process_audio_stream ( AVFormatContext oc,
OutputStream ost 
)
static

Definition at line 261 of file output.c.

Referenced by main().

◆ add_video_stream()

static void add_video_stream ( OutputStream ost,
AVFormatContext oc,
enum AVCodecID  codec_id 
)
static

Definition at line 327 of file output.c.

Referenced by main().

◆ alloc_picture()

static AVFrame* alloc_picture ( enum AVPixelFormat  pix_fmt,
int  width,
int  height 
)
static

Definition at line 382 of file output.c.

Referenced by open_video().

◆ open_video()

static void open_video ( AVFormatContext oc,
OutputStream ost 
)
static

Definition at line 405 of file output.c.

Referenced by main().

◆ fill_yuv_image()

static void fill_yuv_image ( AVFrame pict,
int  frame_index,
int  width,
int  height 
)
static

Definition at line 446 of file output.c.

Referenced by get_video_frame().

◆ get_video_frame()

static AVFrame* get_video_frame ( OutputStream ost)
static

Definition at line 475 of file output.c.

Referenced by write_video_frame().

◆ write_video_frame()

static int write_video_frame ( AVFormatContext oc,
OutputStream ost 
)
static

Definition at line 515 of file output.c.

Referenced by main().

◆ close_stream()

static void close_stream ( AVFormatContext oc,
OutputStream ost 
)
static

Definition at line 552 of file output.c.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 564 of file output.c.