FFmpeg
|
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.
Enumerations | |
enum | { API_MODE_OLD = 0, API_MODE_NEW_API_REF_COUNT = 1, API_MODE_NEW_API_NO_REF_COUNT = 2 } |
Functions | |
static int | decode_packet (int *got_frame, int cached) |
static int | open_codec_context (int *stream_idx, 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 AVFormatContext * | fmt_ctx = NULL |
static AVCodecContext * | video_dec_ctx = NULL |
static AVCodecContext * | audio_dec_ctx |
static int | width |
static int | height |
static enum AVPixelFormat | pix_fmt |
static AVStream * | video_stream = NULL |
static AVStream * | audio_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 AVFrame * | frame = NULL |
static AVPacket | pkt |
static int | video_frame_count = 0 |
static int | audio_frame_count = 0 |
static int | api_mode = API_MODE_OLD |
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.
anonymous enum |
Definition at line 62 of file demuxing_decoding.c.
|
static |
Definition at line 70 of file demuxing_decoding.c.
Referenced by main().
|
static |
Definition at line 154 of file demuxing_decoding.c.
Referenced by main().
|
static |
Definition at line 195 of file demuxing_decoding.c.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 224 of file demuxing_decoding.c.
|
static |
Definition at line 37 of file demuxing_decoding.c.
Referenced by close_input_file(), main(), open_input_file(), and probe_file().
|
static |
Definition at line 38 of file demuxing_decoding.c.
|
static |
Definition at line 38 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
|
static |
Definition at line 39 of file demuxing_decoding.c.
Referenced by abgrToA_c(), add_rect_clamped_c(), aic_decode_header(), alias_pix_read_probe(), alloc_picture(), apply_loop_filter(), av_parse_video_size(), avfilter_graph_dump_to_buf(), avfilter_transform(), avg_tpel_pixels_mc01_c(), avg_tpel_pixels_mc02_c(), avg_tpel_pixels_mc10_c(), avg_tpel_pixels_mc11_c(), avg_tpel_pixels_mc12_c(), avg_tpel_pixels_mc20_c(), avg_tpel_pixels_mc21_c(), avg_tpel_pixels_mc22_c(), bayer_to_rgb24_wrapper(), bayer_to_yv12_wrapper(), bgr24ToUV_c(), bgr24ToUV_half_c(), bgr24ToY_c(), bink_decode_plane(), bitplane_decoding(), bktr_init(), bmp_decode_frame(), bswap16UV_c(), bswap16Y_c(), build_abs_diff_mask(), build_feed_streams(), calc_combed_score(), calc_diffs(), calculate_display_rect(), calculate_visual_weight(), cdxl_read_packet(), chrRangeFromJpeg16_c(), chrRangeFromJpeg_c(), chrRangeToJpeg16_c(), chrRangeToJpeg_c(), codec_reinit(), codecctl_int(), compare_fields(), config_input(), config_output(), copy_block(), copy_CTB(), copy_frame(), count_usage(), dc1394_read_common(), decode_13(), decode_bdlt(), decode_block(), decode_clnpass(), decode_colskip(), decode_dds1(), decode_entropy_coded_image(), decode_entropy_image(), decode_fctl_chunk(), decode_frame(), decode_frame_header(), decode_frame_headers(), decode_header(), decode_i2_frame(), decode_i_frame(), decode_mvc1(), decode_p_frame(), decode_packet(), decode_ppc(), decode_refpass(), decode_region(), decode_region_masked(), decode_rowskip(), decode_seq_header(), decode_sigpass(), decode_slice(), decode_subband_internal(), decode_vol_header(), decode_wdlt(), DEFINE_BLEND(), deinterleaveBytes_c(), deshake_transform_c(), device_init(), dirac_hpel_filter(), draw_n_color(), dump_enc_cfg(), dump_paramchange(), duplicate_right_border_pixels(), dx2_decode_slice_410(), dx2_decode_slice_420(), dx2_decode_slice_444(), dx2_decode_slice_565(), dx2_decode_slice_rgb(), dxtory_decode_v1_410(), dxtory_decode_v1_420(), dxtory_decode_v1_444(), dxtory_decode_v1_rgb(), encode_15_7_sl(), encode_cblk(), encode_clnpass(), encode_frame(), encode_picture_ls(), encode_refpass(), encode_sigpass(), encode_slice(), execute_code(), extract_from_packed(), fade(), ff_copy_rectangle(), ff_draw_rectangle(), ff_flac_parse_picture(), ff_flv_decode_picture_header(), ff_gmc_c(), ff_gradfun_blur_line_c(), ff_gradfun_filter_line_c(), ff_h263_decode_frame(), ff_h263_decode_picture_header(), ff_h264_decode_seq_parameter_set(), ff_hevc_put_qpel_bi_neon_wrapper(), ff_hevc_put_qpel_neon_wrapper(), ff_hevc_put_qpel_uni_neon_wrapper(), ff_jpegls_decode_picture(), ff_mjpeg_decode_sof(), ff_opencl_apply_unsharp(), ff_print_debug_info2(), ff_rtjpeg_decode_init(), ff_set_dimensions(), ff_shrink88(), ff_snow_vertical_compose97i(), ff_spatial_idwt_init2(), ff_vc1_mc_4mv_luma(), ff_vda_create_decoder(), ff_vda_default_init(), ff_vdpau_common_init(), fill_yuv_image(), filter(), filter_slice(), filter_slice_chroma(), gbr16ptopacked16(), gbr24ptopacked24(), gbr24ptopacked32(), gbr24pToUV_half_c(), gif_image_write_image(), gif_read_header(), gif_read_image(), hqx_filter(), idcin_read_header(), init_dimensions(), init_sizes(), inter_predict(), interleaveBytes_c(), interleaveBytes_TMPL(), INTERPOLATE_METHOD(), jpeg_parse_packet(), kempf_decode_tile(), kempf_restore_buf(), lag_decode_arith_plane(), lag_pred_line_yuy2(), left_predict(), libopenjpeg_copy_unpacked16(), libopenjpeg_copy_unpacked8(), libopenjpeg_decode_frame(), ljpeg_encode_bgr(), ljpeg_encode_frame(), loco_decode_plane(), lowpass_line_c(), luma_abs_diff(), lumRangeFromJpeg16_c(), lumRangeFromJpeg_c(), lumRangeToJpeg16_c(), lumRangeToJpeg_c(), main(), mangle_rgb_planes(), mca(), median_predict(), mimic_decode_frame(), monoblack2Y_c(), monowhite2Y_c(), mov_create_dvd_sub_decoder_specific_info(), mov_read_tkhd(), mov_write_tapt_tag(), mpeg1_decode_sequence(), mpeg1_encode_sequence_header(), msnwc_tcp_probe(), msrle_decode_8_16_24_32(), mss4_decode_frame(), mvc_decode_init(), noise(), nuv_header(), nvXXtoUV_c(), old_codec37(), old_codec47(), op(), opengl_resize(), optimum_block_width(), output_mpd(), packed16togbra16(), packedtogbr24p(), paint_mouse_pointer(), palToA_c(), palToUV_c(), palToY_c(), parse_object_segment(), pic_arrays_init(), planar_rgb16_to_uv(), planar_rgb16_to_y(), planar_rgb_to_a(), planar_rgb_to_uv(), planar_rgb_to_y(), png_get_interlaced_row(), png_put_interlaced_row(), postProcess_TMPL(), pp_postprocess(), process_frame_uyvy422(), process_frame_yuv420p(), process_frame_yuv422p(), process_ipmovie_chunk(), put_hevc_epel_bi_h(), put_hevc_epel_bi_hv(), put_hevc_epel_bi_v(), put_hevc_epel_bi_w_h(), put_hevc_epel_bi_w_hv(), put_hevc_epel_bi_w_v(), put_hevc_epel_h(), put_hevc_epel_hv(), put_hevc_epel_uni_h(), put_hevc_epel_uni_hv(), put_hevc_epel_uni_v(), put_hevc_epel_uni_w_h(), put_hevc_epel_uni_w_hv(), put_hevc_epel_uni_w_v(), put_hevc_epel_v(), put_hevc_pel_bi_pixels(), put_hevc_pel_bi_w_pixels(), put_hevc_pel_pixels(), put_hevc_pel_uni_w_pixels(), put_hevc_qpel_bi_h(), put_hevc_qpel_bi_hv(), put_hevc_qpel_bi_v(), put_hevc_qpel_bi_w_h(), put_hevc_qpel_bi_w_hv(), put_hevc_qpel_bi_w_v(), put_hevc_qpel_h(), put_hevc_qpel_hv(), put_hevc_qpel_uni_h(), put_hevc_qpel_uni_hv(), put_hevc_qpel_uni_v(), put_hevc_qpel_uni_w_h(), put_hevc_qpel_uni_w_hv(), put_hevc_qpel_uni_w_v(), put_hevc_qpel_v(), put_line(), put_pcm(), put_signed_rect_clamped_c(), put_tpel_pixels_mc01_c(), put_tpel_pixels_mc02_c(), put_tpel_pixels_mc10_c(), put_tpel_pixels_mc11_c(), put_tpel_pixels_mc12_c(), put_tpel_pixels_mc20_c(), put_tpel_pixels_mc21_c(), put_tpel_pixels_mc22_c(), qpeg_decode_inter(), qtrle_encode_line(), rawvideo_read_packet(), read4x4block(), read_header(), read_sm_data(), read_ya16be_alpha_c(), read_ya16be_gray_c(), read_ya16le_alpha_c(), read_ya16le_gray_c(), restore_tqb_pixels(), rgb16_32ToUV_c_template(), rgb16_32ToUV_half_c_template(), rgb24_copy(), rgb24_interpolate(), rgb24ToUV_c(), rgb24ToUV_half_c(), rgb24ToY_c(), rgb48funcs(), rgb48ToUV_c_template(), rgb48ToUV_half_c_template(), rgb64funcs(), rgb64ToUV_c_template(), rgb64ToUV_half_c_template(), rgb64ToY_c_template(), rgba64beToA_c(), rgba64leToA_c(), rgbaToA_c(), rpza_decode_stream(), rv34_mc(), sao_band_filter_0(), sao_edge_filter(), sao_edge_restore_0(), sao_edge_restore_1(), sao_filter_CTB(), set_processing_window(), siff_parse_vbv1(), smc_decode_stream(), smush_read_header(), snow_interleave_line_header(), spatial_compose53i_dy_buffered(), ssim_end4(), ssim_plane(), store_slice16_c(), store_slice2_c(), store_slice_c(), super2xsai(), svq1_decode_block_intra(), svq1_decode_block_non_intra(), svq1_decode_frame(), svq1_decode_frame_header(), svq1_encode_plane(), swf_read_packet(), swf_write_header(), theora_header(), tiff_unpack_strip(), to_meta_with_crop(), utvideo_encode_frame(), uyvyToUV_c(), uyvyToY_c(), uyvytoyuv420_TMPL(), uyvytoyuv422_TMPL(), vb_decode_framedata(), vble_restore_plane(), vdpau_get_buffer(), verify_md5(), vertical_compose53iH0(), vertical_compose53iL0(), vertical_compose97iH0(), vertical_compose97iH1(), vertical_compose97iL0(), vertical_compose97iL1(), vertical_compose_daub97iH0(), vertical_compose_daub97iH1(), vertical_compose_daub97iL0(), vertical_compose_daub97iL1(), vertical_compose_dd137iL0(), vertical_compose_dd97iH0(), vertical_compose_dirac53iH0(), vertical_compose_fidelityiH0(), vertical_compose_fidelityiL0(), vertical_compose_haar(), vertical_decompose53iH0(), vertical_decompose53iL0(), vertical_decompose97iH0(), vertical_decompose97iH1(), vertical_decompose97iL0(), vertical_decompose97iL1(), decklink_input_callback::VideoInputFrameArrived(), vmd_read_header(), vp7_decode_frame_header(), vp7_fade_frame(), vp8_decode_frame_header(), write_huff_codes(), xan_wc3_copy_pixel_run(), xan_wc3_decode_frame(), xan_wc3_output_pixel_run(), xbm_decode_frame(), xsub_encode(), yuv422ptouyvy_TMPL(), yuv422ptoyuy2_TMPL(), yuv4_generate_header(), yuv4_read_header(), yuv4_read_packet(), yuv4_write_packet(), yuvPlanartouyvy_TMPL(), yuvPlanartoyuy2_TMPL(), yuy2ToUV_c(), yuy2ToY_c(), yuy2toyv12_TMPL(), yuyvtoyuv420_TMPL(), yuyvtoyuv422_TMPL(), yv12_copy(), yv12_interpolate(), yv12touyvy_TMPL(), yv12toyuy2_TMPL(), yvy2ToUV_c(), and zero12v_decode_frame().
|
static |
Definition at line 39 of file demuxing_decoding.c.
|
static |
Definition at line 40 of file demuxing_decoding.c.
Referenced by alloc_picture(), av_get_pix_fmt(), av_get_pix_fmt_name(), av_get_pix_fmt_string(), av_pix_fmt_desc_get(), avi_write_header(), dc1394_read_common(), decode_packet(), dshow_cycle_formats(), fbdev_read_header(), fbdev_write_header(), ff_img_read_header(), ff_parse_pixel_format(), ff_vda_default_init(), ffserver_parse_config_stream(), get_pix_fmt_internal(), init(), list_formats(), load_mask(), main(), mov_get_rawvideo_codec_tag(), opengl_draw(), opengl_fill_color_map(), query_formats(), rawvideo_read_header(), sdl_write_header(), show_pix_fmts(), swf_read_packet(), sws_isSupportedEndiannessConversion(), sws_isSupportedInput(), sws_isSupportedOutput(), v4l2_read_header(), xwd_encode_frame(), and yuv4_read_header().
Definition at line 41 of file demuxing_decoding.c.
Referenced by event_loop(), and yop_read_header().
Definition at line 41 of file demuxing_decoding.c.
Referenced by event_loop(), main(), and yop_read_header().
|
static |
Definition at line 42 of file demuxing_decoding.c.
Referenced by main(), and open_codec_context().
|
static |
Definition at line 43 of file demuxing_decoding.c.
Referenced by main().
|
static |
Definition at line 44 of file demuxing_decoding.c.
Referenced by main().
|
static |
Definition at line 45 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
|
static |
Definition at line 46 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
Definition at line 48 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
|
static |
Definition at line 49 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
|
static |
Definition at line 50 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
|
static |
Definition at line 52 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
|
static |
Definition at line 52 of file demuxing_decoding.c.
Referenced by decode_packet(), and main().
Definition at line 53 of file demuxing_decoding.c.
Referenced by a64multi_encode_frame(), ac3_decode_frame(), add_frame(), add_timecode_metadata(), add_to_queue(), adpcm_decode_frame(), adx_decode_frame(), alac_decode_frame(), alloc_audio_frame(), alloc_frame(), amrnb_decode_frame(), amrwb_decode_frame(), ape_decode_frame(), aqt_probe(), aqt_read_header(), atrac1_decode_frame(), atrac3_decode_frame(), atrac3p_decode_frame(), audio_encode_example(), aura_decode_frame(), av_frame_alloc(), avcodec_encode_audio(), avisynth_read_packet_video(), bfi_decode_frame(), bmv_aud_decode_frame(), cdg_decode_frame(), celt_decode_coarse_energy(), celt_decode_fine_energy(), channel_decorrelation(), cinaudio_decode_frame(), cmv_decode_frame(), cng_decode_frame(), compand_drain(), compand_nodelay(), cook_decode_frame(), copy_samples(), cpia_decode_frame(), cyuv_decode_frame(), dca_decode_frame(), decklink_write_video_packet(), decode_bdlt(), decode_bmv_frame(), decode_dds1(), decode_dsw1(), decode_entropy_coded_image(), decode_frame(), decode_tag(), decode_thread(), decode_tsw1(), decode_wdlt(), dfa_decode_frame(), dirac_decode_frame_internal(), dnxhd_decode_frame(), dpcm_decode_frame(), dss_sp_decode_frame(), dv_write_packet(), dvvideo_encode_frame(), eightsvx_decode_frame(), encode_frame(), encode_residual_ch(), escape124_decode_frame(), evrc_decode_frame(), fdk_aac_decode_frame(), ff_celt_decode_frame(), ff_celt_flush(), ff_decklink_read_packet(), ff_default_get_audio_buffer(), ff_default_get_video_buffer(), ff_filter_frame_framed(), ff_framesync_get_frame(), ff_h264_fill_mbaff_ref_list(), ff_hevc_bump_frame(), ff_hevc_frame_rps(), ff_hevc_output_frame(), ff_init_buffer_info(), ff_ivi_decode_frame(), ff_load_image(), ff_mjpeg_decode_frame(), ff_twinvq_decode_frame(), fill_picture_parameters(), filter_frame(), filter_frame_left(), filter_frame_right(), filter_slice_alpha(), filter_slice_chroma(), filter_slice_luma(), filter_slice_rgb(), flac_decode_frame(), framesync_inject_frame(), g722_decode_frame(), g723_1_decode_frame(), generate_missing_ref(), get_audio_frame(), get_buffer_internal(), get_pts(), get_surface(), get_video_buffer(), gsm_decode_frame(), hnm_decode_frame(), idcin_decode_frame(), ilbc_decode_frame(), imc_decode_frame(), init_frame(), init_slice_rpl(), ipvideo_decode_frame(), ipvideo_decode_opcodes(), join_request_frame(), jpeg2000_decode_frame(), lag_decode_frame(), lavfi_read_packet(), libcelt_dec_decode(), libgsm_decode_frame(), libopenjpeg_decode_frame(), libopus_decode(), libschroedinger_decode_frame(), libspeex_decode_frame(), mace_decode_frame(), main(), microdvd_read_header(), movie_push_frame(), mpc7_decode_frame(), mpc8_decode_frame(), mss2_decode_frame(), mv_read_packet(), mv_read_seek(), mxf_write_system_item(), oggvorbis_decode_frame(), on2avc_decode_frame(), opus_decode_packet(), output_frame_end(), pad_last_frame(), paf_audio_decode(), paf_video_decode(), parse_postfilter(), pcm_bluray_decode_frame(), pcm_decode_frame(), pcm_dvd_decode_frame(), pix_decode_frame(), push_frame(), qcelp_decode_frame(), qdm2_decode_frame(), qsv_decode_frame(), ra144_decode_frame(), ra288_decode_frame(), raw_decode(), CustomSource::read(), read_interval_packets(), release_buffer(), request_frame(), rl2_decode_frame(), roq_encode_frame(), s302m_decode_frame(), decklink_output_callback::ScheduledFrameCompleted(), shorten_decode_frame(), silk_decode_frame(), sipr_decode_frame(), smka_decode_frame(), source_request_frame(), Stagefright_close(), Stagefright_decode_frame(), sub2video_get_blank_frame(), sub2video_push_ref(), sub2video_update(), swf_read_packet(), tak_decode_frame(), tgq_decode_frame(), tgv_decode_frame(), tmv_decode_frame(), truespeech_decode_frame(), try_decode_frame(), tta_decode_frame(), uninit(), unpack_frame(), v4l2_read_packet(), vda_h264_end_frame(), vda_old_h264_end_frame(), video_decode_example(), video_encode_example(), vmd_read_packet(), vmdaudio_decode_frame(), vmdvideo_decode_frame(), vorbis_decode_frame(), vp8_find_free_buffer(), vqa_decode_frame(), wavesynth_decode(), wavpack_decode_frame(), wma_decode_superframe(), worker(), write_audio_frame(), write_frame_header(), write_packet(), write_video_frame(), ws_snd_decode_frame(), xan_decode_frame(), xface_decode_frame(), and yop_decode_frame().
|
static |
Definition at line 54 of file demuxing_decoding.c.
Referenced by add_to_pktbuf(), ape_tag_read_field(), asf_read_header(), asf_read_picture(), asf_read_pts(), audio_encode_example(), audio_write_frame(), av_dup_packet(), av_packet_merge_side_data(), av_write_trailer(), av_write_uncoded_frame_internal(), avcodec_encode_audio(), avcodec_encode_video(), avformat_find_stream_info(), avpacket_queue_flush(), avpacket_queue_put(), avpriv_mpegts_parse_packet(), decoder_decode_frame(), do_audio_out(), do_subtitle_out(), do_video_out(), encode_callback(), encode_frame(), estimate_timings_from_pts(), extract_mpeg4_header(), ff_init_buffer_info(), ff_interleave_add_packet(), ff_ivi_decode_frame(), ff_load_image(), ff_write_chained(), filter(), filter_frame(), filter_packet(), find_missing_packets(), flac_read_timestamp(), flush_encoders(), flush_packet(), free_pkt_fifo(), gen_buffer_time(), gen_bytes_read(), gen_check_bw(), gen_connect(), gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcsubscribe_stream(), gen_fcunpublish_stream(), gen_get_stream_length(), gen_pause(), gen_play(), gen_pong(), gen_publish(), gen_release_stream(), gen_seek(), gen_server_bw(), gen_swf_verification(), gxf_compare_field_nb(), http_prepare_data(), ipmovie_read_header(), mace_decode_frame(), main(), matroska_parse_frame(), matroska_parse_rm_audio(), matroska_parse_webvtt(), mkv_write_packet(), mov_read_covr(), movie_push_frame(), mpc_read_seek(), mpegts_get_dts(), mpegts_read_packet(), nsv_read_chunk(), opus_decode_packet(), packet_queue_flush(), packet_queue_put_nullpacket(), packet_queue_put_private(), parse_file(), process_callback(), process_input(), process_input_packet(), pulse_write_frame(), qsv_clear_buffers(), queue_frames(), read_connect(), read_interval_packets(), read_thread(), seek_frame_generic(), Stagefright_decode_frame(), str_read_packet(), supply_new_packets(), try_decode_frame(), video_encode_example(), decklink_input_callback::VideoInputFrameArrived(), vp8_lossy_decode_frame(), wavpack_encode_frame(), webm_clusters_start_with_keyframe(), worker(), write_audio_frame(), write_frame(), write_video_frame(), and wv_read_seek().
|
static |
Definition at line 55 of file demuxing_decoding.c.
Referenced by decode_packet().
|
static |
Definition at line 56 of file demuxing_decoding.c.
Referenced by decode_packet(), and fourxm_read_packet().
|
static |
Definition at line 68 of file demuxing_decoding.c.
Referenced by decode_packet(), main(), and open_codec_context().