技术标签: 音视频
/**
* Allocate an AVFormatContext for an output format.
* avformat_free_context() can be used to free the context and
* everything allocated by the framework within it.
*
* @param *ctx is set to the created format context, or to NULL in
* case of failure
* @param oformat format to use for allocating the context, if NULL
* format_name and filename are used instead
* @param format_name the name of output format to use for allocating the
* context, if NULL filename is used instead
* @param filename the name of the filename to use for allocating the
* context, may be NULL
* @return >= 0 in case of success, a negative AVERROR code in case of
* failure
*/
int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat,
const char *format_name, const char *filename);
int avformat_alloc_output_context2(AVFormatContext **avctx, const AVOutputFormat *oformat,
const char *format, const char *filename)
{
AVFormatContext *s = avformat_alloc_context();
int ret = 0;
*avctx = NULL;
if (!s)
goto nomem;
if (!oformat) {
if (format) {
oformat = av_guess_format(format, NULL, NULL);
if (!oformat) {
av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
ret = AVERROR(EINVAL);
goto error;
}
} else {
oformat = av_guess_format(NULL, filename, NULL);
if (!oformat) {
ret = AVERROR(EINVAL);
av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
filename);
goto error;
}
}
}
s->oformat = oformat;
if (s->oformat->priv_data_size > 0) {
s->priv_data = av_mallocz(s->oformat->priv_data_size);
if (!s->priv_data)
goto nomem;
if (s->oformat->priv_class) {
*(const AVClass**)s->priv_data= s->oformat->priv_class;
av_opt_set_defaults(s->priv_data);
}
} else
s->priv_data = NULL;
if (filename) {
if (!(s->url = av_strdup(filename)))
goto nomem;
}
*avctx = s;
return 0;
nomem:
av_log(s, AV_LOG_ERROR, "Out of memory\n");
ret = AVERROR(ENOMEM);
error:
avformat_free_context(s);
return ret;
}
AVFormatContext *avformat_alloc_context(void)
{
FFFormatContext *const si = av_mallocz(sizeof(*si));
AVFormatContext *s;
if (!si)
return NULL;
s = &si->pub;
s->av_class = &av_format_context_class;
s->io_open = io_open_default;
s->io_close = ff_format_io_close_default;
s->io_close2= io_close2_default;
av_opt_set_defaults(s);
si->pkt = av_packet_alloc();
si->parse_pkt = av_packet_alloc();
if (!si->pkt || !si->parse_pkt) {
avformat_free_context(s);
return NULL;
}
si->shortest_end = AV_NOPTS_VALUE;
return s;
}
void av_opt_set_defaults(void *s)
{
av_opt_set_defaults2(s, 0, 0);
}
void av_opt_set_defaults2(void *s, int mask, int flags)
{
const AVOption *opt = NULL;
while ((opt = av_opt_next(s, opt))) {
void *dst = ((uint8_t*)s) + opt->offset;
if ((opt->flags & mask) != flags)
continue;
if (opt->flags & AV_OPT_FLAG_READONLY)
continue;
switch (opt->type) {
case AV_OPT_TYPE_CONST:
/* Nothing to be done here */
break;
case AV_OPT_TYPE_BOOL:
case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
case AV_OPT_TYPE_UINT64:
case AV_OPT_TYPE_DURATION:
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
case AV_OPT_TYPE_CHANNEL_LAYOUT:
FF_ENABLE_DEPRECATION_WARNINGS
#endif
case AV_OPT_TYPE_PIXEL_FMT:
case AV_OPT_TYPE_SAMPLE_FMT:
write_number(s, opt, dst, 1, 1, opt->default_val.i64);
break;
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_FLOAT: {
double val;
val = opt->default_val.dbl;
write_number(s, opt, dst, val, 1, 1);
}
break;
case AV_OPT_TYPE_RATIONAL: {
AVRational val;
val = av_d2q(opt->default_val.dbl, INT_MAX);
write_number(s, opt, dst, 1, val.den, val.num);
}
break;
case AV_OPT_TYPE_COLOR:
set_string_color(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_STRING:
set_string(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_IMAGE_SIZE:
set_string_image_size(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_VIDEO_RATE:
set_string_video_rate(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_BINARY:
set_string_binary(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_CHLAYOUT:
set_string_channel_layout(s, opt, opt->default_val.str, dst);
break;
case AV_OPT_TYPE_DICT:
set_string_dict(s, opt, opt->default_val.str, dst);
break;
default:
av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n",
opt->type, opt->name);
}
}
}
/**
* Return the output format in the list of registered output formats
* which best matches the provided parameters, or return NULL if
* there is no match.
*
* @param short_name if non-NULL checks if short_name matches with the
* names of the registered formats
* @param filename if non-NULL checks if filename terminates with the
* extensions of the registered formats
* @param mime_type if non-NULL checks if mime_type matches with the
* MIME type of the registered formats
*/
const AVOutputFormat *av_guess_format(const char *short_name,
const char *filename,
const char *mime_type);
const AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
const char *mime_type)
{
const AVOutputFormat *fmt = NULL;
const AVOutputFormat *fmt_found = NULL;
void *i = 0;
int score_max, score;
/* specific test for image sequences */
#if CONFIG_IMAGE2_MUXER
if (!short_name && filename &&
av_filename_number_test(filename) &&
ff_guess_image2_codec(filename) != AV_CODEC_ID_NONE) {
return av_guess_format("image2", NULL, NULL);
}
#endif
/* Find the proper file type. */
score_max = 0;
while ((fmt = av_muxer_iterate(&i))) {
score = 0;
if (fmt->name && short_name && av_match_name(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;
}
const AVOutputFormat ff_flv_muxer = {
.name = "flv",
.long_name = NULL_IF_CONFIG_SMALL("FLV (Flash Video)"),
.mime_type = "video/x-flv",
.extensions = "flv",
.priv_data_size = sizeof(FLVContext),
.audio_codec = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_ADPCM_SWF,
.video_codec = AV_CODEC_ID_FLV1,
.init = flv_init,
.write_header = flv_write_header,
.write_packet = flv_write_packet,
.write_trailer = flv_write_trailer,
.check_bitstream= flv_check_bitstream,
.codec_tag = (const AVCodecTag* const []) {
flv_video_codec_ids, flv_audio_codec_ids, 0
},
.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
AVFMT_TS_NONSTRICT,
.priv_class = &flv_muxer_class,
};
const AVOutputFormat *av_muxer_iterate(void **opaque)
{
static const uintptr_t size = sizeof(muxer_list)/sizeof(muxer_list[0]) - 1;
uintptr_t i = (uintptr_t)*opaque;
const AVOutputFormat *f = NULL;
uintptr_t tmp;
if (i < size) {
f = muxer_list[i];
} else if (tmp = atomic_load_explicit(&outdev_list_intptr, memory_order_relaxed)) {
const AVOutputFormat *const *outdev_list = (const AVOutputFormat *const *)tmp;
f = outdev_list[i - size];
}
if (f)
*opaque = (void*)(i + 1);
return f;
}
int av_match_name(const char *name, const char *names)
{
const char *p;
int len, namelen;
if (!name || !names)
return 0;
namelen = strlen(name);
while (*names) {
int negate = '-' == *names;
p = strchr(names, ',');
if (!p)
p = names + strlen(names);
names += negate;
len = FFMAX(p - names, namelen);
if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAX(3, p - names)))
return !negate;
names = p + (*p == ',');
}
return 0;
}
const AVInputFormat ff_matroska_demuxer = {
.name = "matroska,webm",
.long_name = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
.extensions = "mkv,mk3d,mka,mks,webm",
.priv_data_size = sizeof(MatroskaDemuxContext),
.flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = matroska_probe,
.read_header = matroska_read_header,
.read_packet = matroska_read_packet,
.read_close = matroska_read_close,
.read_seek = matroska_read_seek,
.mime_type = "audio/webm,audio/x-matroska,video/webm,video/x-matroska"
};
/**
* Return a positive value if the given filename has one of the given
* extensions, 0 otherwise.
*
* @param filename file name to check against the given extensions
* @param extensions a comma-separated list of filename extensions
*/
int av_match_ext(const char *filename, const char *extensions);
/**
* @file
* Format register and lookup
*/
int av_match_ext(const char *filename, const char *extensions)
{
const char *ext;
if (!filename)
return 0;
ext = strrchr(filename, '.');
if (ext)
return av_match_name(ext + 1, extensions);
return 0;
}
链接:https://pan.baidu.com/s/1jBlX2OoWALMaLuMkx21H7w 提取码:mzl4 复制这段内容后打开百度网盘手机App,操作更方便哦如果看的不舒服可以上百度网盘下载完整的第二本书一、Linux基本命令1.基础命令vi /etc/sysconfig/network-scripts/ifcfg-ens32DNBBOT=NO改成DNBBOT=YES//...
目录前言MEGAcmd的调试日志一、MEGAcmd的安装二、MEGAcmd简要使用流程三、调试过程前言放假了。。在家里呆了几天休息休息。看上去是跟紧张的学习生活告一段落了,但是实则是根本没有,甚至还要更加努力,不得不说,精神上还是有些许疲惫...不过也是,人类谋求发展的过程总是艰辛曲折,我还不至于到很折磨的地步(至少自己还没把自己逼的太死。好好学习,过几天去旅游去。MEGAcmd的调试日志周五开了个会,明确了一下项目源码分析的对象,然后分配到的任务是尝试用调试工具跟进
今天用Samba共享CentOS里面的文件夹给Windows使用,无奈在配置正确,关闭防火墙,且文件属性均为wrx的情况下,依然被拒绝访问。弄这个问题花了我不少时间,终于让我找到了答案:没有共享文件给Samba!!!在CentOS中,系统处于安全的考虑,即使拥有着或者权限合法的情况下,也会拒绝某些进程对文件的访问,这时就需要使用chcon这个命令了。于是在我指定了一个目录后,使用下面的语句即可:c...
创建项目项目的创建和之前一样,只是此次的源文件后缀为.cpp,因为MFC是由C++编写的,编写MFC程序需要包含**#include <afxwin.h>**头文件。编写代码mfc.h#pragma once#include <afxwin.h>class MyApp :public CWinApp//CWinApp应用程序类{public: //程序入口 virtual BOOL InitInstance();};class MyFrame :publ
css设置渐变色 [color=red] .anamorphism{ width:100%; height:200px; FILTER:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#7ECCE2,endColorStr=#D1EEF5);/*IE6*/ backg...
为什么80%的码农都做不了架构师?>>> ...
工作中会经常遇到这样的业务问题:如果找到每个类别下用户点击最多的5个商品是什么?这类问题其实就是常见的:每组最大的N条记录(topN)。【题目】现有“成绩表”,记录了每个学生各科的成绩。表内容如下:问题:查找每个学生成绩最高的2个科目【解题思路】1.看到问题中要查“每个”学生最高的成绩。还记得我们之前课程里讲过的吗?当有“每个”出现的时候,就要想到是要分组了。这里是“每个学生”,结合表的结构,是按...
手把手教你用NuGet 进行项目已经时间不短了,实践的流程、学习的东西也不少,这都应该及时的做总结,最近实践了一个Nuget过程,假如有一个早已封装好的dll,要让56个人使用,再修改后重新生成dll后,要传给这56个人,可不可以通过一个工具,让他来管理我的dll包,我在修改包后,其他人只需更新,摆脱粘贴复制的苦恼。NuGet就帮我解决了这个问题。
主流自动化测试工具–QTPQTP是一个侧重于功能的回归自动化测试工具;提供了很多插件。QTP支持的脚本语言是VBScript,这对于测试人员来说,感觉要“舒服”得多。VBScript毕竟是一种松散的、非严格的、普及面很广的语言。QTP的高可用性:1.支持录制与回放2.支持lower level模式3.QTP的编辑器支持两种视图: Keyword模式和Expert模式与Selenium(WebDriver)比较优劣价格:selenium是开源的自动化测试工具,但是QTP是商业版的,而且
您可以创建自己的折线实现.下面是一个基于现有MapPolygonImpl的示例.这很hacky,但JMapViewer中似乎没有添加行的方法.import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Point;import java.awt.geom.Path2D;import java.util.ArrayList;...
安装要求:CPU,1GMHz以上 内存,1G以上 硬盘,安装系统后建议10G空闲空间1、检查和安装必要的软件包: binutils-2.17.5...
• Transient Setup – This workshop discusses basic setup details of 2D Magnetic Transient solver –本研讨会讨论2D电磁瞬态求解器的基本设置细节 – The transient setup is described with two different excit...