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

libavformat API example. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.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.

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 */
 

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 AVStreamadd_stream (AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id)
 
static void open_audio (AVFormatContext *oc, AVCodec *codec, AVStream *st)
 
static void get_audio_frame (int16_t *samples, int frame_size, int nb_channels)
 
static void write_audio_frame (AVFormatContext *oc, AVStream *st, int flush)
 
static void close_audio (AVFormatContext *oc, AVStream *st)
 
static void open_video (AVFormatContext *oc, AVCodec *codec, AVStream *st)
 
static void fill_yuv_image (AVPicture *pict, int frame_index, int width, int height)
 
static void write_video_frame (AVFormatContext *oc, AVStream *st, int flush)
 
static void close_video (AVFormatContext *oc, AVStream *st)
 
int main (int argc, char **argv)
 

Variables

static int audio_is_eof
 
static int video_is_eof
 
static int sws_flags = SWS_BICUBIC
 
static float t
 
static float tincr
 
static float tincr2
 
AVFrameaudio_frame
 
static uint8_t ** src_samples_data
 
static int src_samples_linesize
 
static int src_nb_samples
 
static int max_dst_nb_samples
 
uint8_t ** dst_samples_data
 
int dst_samples_linesize
 
int dst_samples_size
 
int samples_count
 
struct SwrContextswr_ctx = NULL
 
static AVFrameframe
 
static AVPicture src_picture
 
static AVPicture dst_picture
 
static int frame_count
 

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 main().

#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().

Function Documentation

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

Definition at line 52 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 63 of file muxing.c.

Referenced by write_audio_frame(), and write_video_frame().

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

Definition at line 77 of file muxing.c.

Referenced by main().

static void open_audio ( AVFormatContext oc,
AVCodec codec,
AVStream st 
)
static
Examples:
muxing.c.

Definition at line 164 of file muxing.c.

Referenced by main().

static void get_audio_frame ( int16_t *  samples,
int  frame_size,
int  nb_channels 
)
static
Examples:
muxing.c.

Definition at line 243 of file muxing.c.

Referenced by write_audio_frame().

static void write_audio_frame ( AVFormatContext oc,
AVStream st,
int  flush 
)
static
Examples:
muxing.c.

Definition at line 258 of file muxing.c.

Referenced by main().

static void close_audio ( AVFormatContext oc,
AVStream st 
)
static
Examples:
muxing.c.

Definition at line 325 of file muxing.c.

Referenced by main().

static void open_video ( AVFormatContext oc,
AVCodec codec,
AVStream st 
)
static
Examples:
muxing.c.

Definition at line 344 of file muxing.c.

Referenced by main().

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

Definition at line 390 of file muxing.c.

Referenced by write_video_frame().

static void write_video_frame ( AVFormatContext oc,
AVStream st,
int  flush 
)
static
Examples:
muxing.c.

Definition at line 411 of file muxing.c.

Referenced by main().

static void close_video ( AVFormatContext oc,
AVStream st 
)
static
Examples:
muxing.c.

Definition at line 481 of file muxing.c.

Referenced by main().

int main ( int  argc,
char **  argv 
)

Definition at line 492 of file muxing.c.

Variable Documentation

int audio_is_eof
static
Examples:
muxing.c.

Definition at line 44 of file muxing.c.

Referenced by main(), and write_audio_frame().

int video_is_eof
static
Examples:
muxing.c.

Definition at line 44 of file muxing.c.

Referenced by main(), and write_video_frame().

int sws_flags = SWS_BICUBIC
static
Examples:
muxing.c.

Definition at line 50 of file muxing.c.

Referenced by write_video_frame().

float t
static
Examples:
avcodec.c, muxing.c, and resampling_audio.c.

Definition at line 149 of file muxing.c.

Referenced by adpcm_compress_trellis(), alaw2linear(), amf_tag_contents(), analyze_plane(), asf_write_markers(), assert_avoptions(), audio_encode_example(), av_add_sf(), av_aes_init(), av_cmp_sf(), av_dict_copy(), av_gettime(), av_normalize1_sf(), av_opt_set_dict(), av_packet_pack_dictionary(), av_parse_time(), av_size_mult(), av_timegm(), av_tree_insert(), avformat_find_stream_info(), avi_write_header(), avs_set_fps(), bessel(), bl_intrp(), blend_pixel(), block_cmp(), bmp_decode_frame(), body(), butterflies_float_c(), caf_write_header(), config_props(), crazytime_to_iso8601(), dca_downmix(), decode_555(), decode_band(), decode_block(), decode_cce(), decode_channel(), decode_dct(), decode_end(), decode_frame(), decode_group3_1d_line(), decode_group3_2d_line(), decode_run_2bit(), decode_subband_slice_buffered(), dering_TMPL(), diff_planes(), draw_mandelbrot(), dv_init_mux(), dwt_decode97_float(), dwt_decode97_int(), encode_block(), encode_frame(), encode_picture_ls(), encode_subband_c0run(), estimate_sid_gain(), eval_expr(), ff_amf_tag_size(), ff_atrac3p_ipqf(), ff_h264_decode_seq_parameter_set(), ff_jpeg2000_tag_tree_init(), ff_jpegls_decode_picture(), ff_mjpeg_find_marker(), ff_pca(), ff_riff_write_info(), ff_vorbis_comment(), ff_vp6_filter_diag4_c(), ff_yuv2rgb_get_func_ptr(), ffm_write_header(), fft(), filetime_to_iso8601(), filter(), filter_codec_opts(), filter_frame(), flv_read_packet(), generate_noise(), get_audio_frame(), get_chroma_qp(), get_date_tag(), get_dimension(), get_generic_seed(), get_scale_idx(), gxf_write_umf_material_description(), handle_invoke_status(), handle_ping(), hpel_motion_search(), idct32(), idct_row(), idx_to_quant(), ir2_decode_plane(), ir2_decode_plane_inter(), ivi_free_buffers(), lcg_seek(), main(), mask_edges(), merge_date(), mid_pred(), mix6to2_TMPL(), mix8to2_TMPL(), mkv_check_tag(), mkv_write_attachments(), mkv_write_chapters(), mkv_write_tag(), mov_create_chapter_track(), mov_read_mac_string(), mov_write_3gp_udta_tag(), mov_write_chpl_tag(), mov_write_header(), mov_write_int8_metadata(), mov_write_string_metadata(), mov_write_tmpo_tag(), mov_write_trkn_tag(), mpc7_decode_frame(), mpc8_decode_frame(), mpc8_parse_seektable(), mss4_decode_dct(), mxf_compute_index_tables(), mxf_read_packet(), mxf_read_packet_old(), mxf_read_seek(), mxf_set_current_edit_unit(), mxf_write_header(), nsv_parse_NSVs_header(), ogm_dshow_header(), old_codec37(), oledate_to_iso8601(), open_audio(), open_input_file(), paf_aud_decode(), parse_forced_key_frames(), parse_times(), pcm_dvd_decode_samples(), pix_abs16x16_y2_mvi(), postProcess_TMPL(), pow_m1_4(), predictor(), print_report(), process_block(), qpel_motion_search(), quantize_and_encode_band_cost_template(), read_block_types(), read_colors(), read_dct_coeffs(), read_motion_values(), read_patterns(), read_runs(), read_thread(), read_time(), read_tree(), request_frame(), revert_channel_correlation(), ripemd128_transform(), ripemd160_transform(), rv34_decode_cbp(), rv34_decode_inter_mb_header(), rv34_decode_intra_mb_header(), rv40_strong_loop_filter(), rv40_weak_loop_filter(), sad_hpel_motion_search(), scalarproduct_int16_altivec(), search_for_quantizers_anmr(), search_for_quantizers_faac(), sha1_transform(), sipr_decode_lp(), smacker_decode_bigtree(), smacker_read_packet(), smjpeg_write_header(), stream_component_open(), tak_parse(), tedcaptions_read_probe(), teletext_init_decoder(), tm2_low_chroma(), tqi_decode_init(), truespeech_apply_twopoint_filter(), truespeech_place_pulses(), truespeech_synth(), udp_read(), ulaw2linear(), ulti_grad(), unix_to_file_time(), unpack_coeffs(), update_benchmark(), vb_decode_framedata(), vorbis_parse_setup_hdr_codebooks(), vp56_deblock_filter(), vp5_adjust(), wavpack_decode_block(), write_chapter(), write_chunk_header(), write_frame(), write_globalinfo(), write_index(), write_metadata(), write_streaminfo(), write_tags(), ws_snd_decode_frame(), wv_get_value(), wv_unpack_mono(), wv_unpack_stereo(), x8_ac_compensation(), x8_get_ac_rlf(), x8_loop_filter(), xa_decode(), yae_reset(), and zero12v_decode_frame().

float tincr
static
Examples:
avcodec.c, muxing.c, and resampling_audio.c.

Definition at line 149 of file muxing.c.

Referenced by audio_encode_example(), fill_samples(), get_audio_frame(), and open_audio().

float tincr2
static
Examples:
muxing.c.

Definition at line 149 of file muxing.c.

Referenced by get_audio_frame(), and open_audio().

AVFrame* audio_frame
Examples:
muxing.c.

Definition at line 151 of file muxing.c.

uint8_t** src_samples_data
static
Examples:
muxing.c.

Definition at line 152 of file muxing.c.

Referenced by close_audio(), open_audio(), and write_audio_frame().

int src_samples_linesize
static
Examples:
muxing.c.

Definition at line 153 of file muxing.c.

Referenced by open_audio().

int src_nb_samples
static
Examples:
muxing.c, and resampling_audio.c.

Definition at line 154 of file muxing.c.

Referenced by main(), open_audio(), and write_audio_frame().

int max_dst_nb_samples
static
Examples:
muxing.c, and resampling_audio.c.

Definition at line 156 of file muxing.c.

Referenced by main(), open_audio(), and write_audio_frame().

uint8_t** dst_samples_data
Examples:
muxing.c.

Definition at line 157 of file muxing.c.

Referenced by close_audio(), open_audio(), and write_audio_frame().

int dst_samples_linesize
Examples:
muxing.c.

Definition at line 158 of file muxing.c.

Referenced by open_audio(), and write_audio_frame().

int dst_samples_size
Examples:
muxing.c.

Definition at line 159 of file muxing.c.

Referenced by open_audio(), and write_audio_frame().

int samples_count
Examples:
muxing.c.

Definition at line 160 of file muxing.c.

Referenced by write_audio_frame().

struct SwrContext* swr_ctx = NULL
Examples:
muxing.c, and resampling_audio.c.

Definition at line 162 of file muxing.c.

Referenced by main().

AVFrame* frame
static

Definition at line 340 of file muxing.c.

AVPicture src_picture
static
Examples:
muxing.c.

Definition at line 341 of file muxing.c.

AVPicture dst_picture
static
Examples:
muxing.c.

Definition at line 341 of file muxing.c.

Referenced by open_video().

int frame_count
static