register all media file container muxers in ffmpeg
2017-02-02 19:44
337 查看
register all media file container muxers in ffmpeg
1. muxers such mov and 3gp
libavformat/movenc.c:
2. so how to register these muxers such as mov and 3gp?
in libavformat/allformats.c:
also in libavformat/allformats.c
all the registered muxers are save in the below single linked list:
static AVOutputFormat *first_oformat = NULL;
linked by the below field of AVOutputFormat:
struct AVOutputFormat *next;
get the target AVOutputFormat(a muxer) according to muxer name, for example mov:
m_pFormatCtx->oformat = av_guess_format("mov", NULL, NULL);
in the above example, only short_name is not null. both filename and mime_type are null
1. muxers such mov and 3gp
libavformat/movenc.c:
#if CONFIG_MOV_MUXER MOV_CLASS(mov) AVOutputFormat ff_mov_muxer = { .name = "mov", .long_name = NULL_IF_CONFIG_SMALL("QuickTime / MOV"), .extensions = "mov", .priv_data_size = sizeof(MOVMuxContext), .audio_codec = AV_CODEC_ID_AAC, .video_codec = CONFIG_LIBX264_ENCODER ? AV_CODEC_ID_H264 : AV_CODEC_ID_MPEG4, .write_header = mov_write_header, .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, .codec_tag = (const AVCodecTag* const []){ ff_codec_movvideo_tags, ff_codec_movaudio_tags, 0 }, .priv_class = &mov_muxer_class, }; #endif #if CONFIG_TGP_MUXER MOV_CLASS(tgp) AVOutputFormat ff_tgp_muxer = { .name = "3gp", .long_name = NULL_IF_CONFIG_SMALL("3GP (3GPP file format)"), .extensions = "3gp", .priv_data_size = sizeof(MOVMuxContext), .audio_codec = AV_CODEC_ID_AMR_NB, .video_codec = AV_CODEC_ID_H263, .write_header = mov_write_header, .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, .codec_tag = (const AVCodecTag* const []){ codec_3gp_tags, 0 }, .priv_class = &tgp_muxer_class, }; #endif
2. so how to register these muxers such as mov and 3gp?
in libavformat/allformats.c:
#define REGISTER_MUXER(X, x) \ { \ extern AVOutputFormat ff_##x##_muxer; \ if (CONFIG_##X##_MUXER) \ av_register_output_format(&ff_##x##_muxer); \ } #define REGISTER_DEMUXER(X, x) \ { \ extern AVInputFormat ff_##x##_demuxer; \ if (CONFIG_##X##_DEMUXER) \ av_register_input_format(&ff_##x##_demuxer); \ } #define REGISTER_MUXDEMUX(X, x) REGISTER_MUXER(X, x); REGISTER_DEMUXER(X, x)
also in libavformat/allformats.c
void av_register_all(void) { static int initialized; if (initialized) return; initialized = 1; avcodec_register_all(); /* (de)muxers */ REGISTER_MUXER (A64, a64); REGISTER_DEMUXER (AAC, aac); REGISTER_MUXDEMUX(AC3, ac3); ...... REGISTER_MUXDEMUX(MOV, mov); REGISTER_MUXER (MP2, mp2); REGISTER_MUXDEMUX(MP3, mp3); REGISTER_MUXER (MP4, mp4);
all the registered muxers are save in the below single linked list:
static AVOutputFormat *first_oformat = NULL;
linked by the below field of AVOutputFormat:
struct AVOutputFormat *next;
get the target AVOutputFormat(a muxer) according to muxer name, for example mov:
m_pFormatCtx->oformat = av_guess_format("mov", NULL, NULL);
AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) /* Find the proper file type. */ fmt_found = NULL; score_max = 0; while ((fmt = av_oformat_next(fmt))) { score = 0; if (fmt->name && short_name && match_format(short_name, fmt->name)) score += 100; if (fmt->mime_type && mime_type && !strcmp(fmt->mime_type, mime_type)) score += 10; if (filename && fmt->extensions && av_match_ext(filename, fmt->extensions)) { score += 5; } if (score > score_max) { score_max = score; fmt_found = fmt; } } return fmt_found;
in the above example, only short_name is not null. both filename and mime_type are null
相关文章推荐
- 【Ant】How to print all the system properties in Ant build file
- win7 下ffmpeg release 版本av_register_all崩溃问题
- ffmpeg 源代码简单分析 : avcodec_register_all()
- All about control file in Oracle Database
- ffmpeg 源代码简单分析 : av_register_all()
- ffmpeg 函数简单分析 : av_register_all()
- ffmpeg 源代码简单分析 : avcodec_register_all()
- ffmpeg 源代码简单分析 : av_register_all()
- ffmpeg 函数简单分析 : avcodec_register_all()
- Shell: how to list all db links in oracle DB to generate a flat file (生成dblink列表文件)
- ffmpeg 源代码简单分析 : avcodec_register_all()
- ffmpeg开发之旅(3):AAC编码格式分析与MP4文件封装(MediaCodec+MediaMuxer)
- Recursion all file direction in a direction
- 关于APKsmail中加入代码报错All register args must fit in 4 bits
- ffmpeg开发之旅(3):AAC编码格式分析与MP4文件封装(MediaCodec+MediaMuxer)
- ffmpeg 源代码简单分析 : av_register_all()
- ffmpeg源码分析--2.av_register_all
- [置顶] All about control file in Oracle Database
- 【报错】项目启动,仅仅报错 One or more listeners failed to start. Full details will be found in the appropriate container log file
- ffmpeg 源代码简单分析 : avcodec_register_all() 加载 编解码器