FFmpeg mov_read_ftyp函数剖析
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FFmpeg mov_read_ftyp函数剖析相关的知识,希望对你有一定的参考价值。
函数说明 读取文件格式,最小版本以及兼容格式,然后存储到metadata,metadata作为AVFormatContext成员变量,可以通过t = av_dict_get(pAVFormatContext->metadata, "major_brand", NULL, AV_DICT_IGNORE_SUFFIX);
查看文件格式
/* read major brand, minor version and compatible brands and store them as metadata */
static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
uint32_t minor_ver;
int comp_brand_size;
char* comp_brands_str;
uint8_t type[5] = {0};
int ret = ffio_read_size(pb, type, 4);
if (ret < 0)
return ret;
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
//fc结构体是AVFormatContext
av_dict_set(&c->fc->metadata, "major_brand", type, 0);
minor_ver = avio_rb32(pb); /* minor version */
av_dict_set_int(&c->fc->metadata, "minor_version", minor_ver, 0);
comp_brand_size = atom.size - 8;
if (comp_brand_size < 0)
return AVERROR_INVALIDDATA;
comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
if (!comp_brands_str)
return AVERROR(ENOMEM);
ret = ffio_read_size(pb, comp_brands_str, comp_brand_size);
if (ret < 0) {
av_freep(&comp_brands_str);
return ret;
}
comp_brands_str[comp_brand_size] = 0;
av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
return 0;
}
Brand Extension Mime type
MP4 mp41,mp42 .mp4 video/mp4,audio/mp4,application/mp4
QuickTim qt .mov video/quicktime
参考
http://www.ftyps.com
以上是关于FFmpeg mov_read_ftyp函数剖析的主要内容,如果未能解决你的问题,请参考以下文章
FFmpeg源码剖析-通用:ffmpeg_parse_options()
FFmpeg源码剖析-通用:ffmpeg_parse_options()