当前位置: 首页 > news >正文

青岛做网站哪家好百度官方人工客服电话

青岛做网站哪家好,百度官方人工客服电话,酒店协会网站集静态模板,南京美容网站建设auto convert的创建 在FFmpeg/libavfilter/formats.c中定义了negotiate_video和negotiate_audio,在格式协商,对于video如果需要scale,那么就会自动创建scale作为convert,对于audio,如果需要重采样,则会创建…

auto convert的创建

在FFmpeg/libavfilter/formats.c中定义了negotiate_videonegotiate_audio,在格式协商,对于video如果需要scale,那么就会自动创建scale作为convert,对于audio,如果需要重采样,则会创建aresample

static const AVFilterNegotiation negotiate_video = {.nb_mergers = FF_ARRAY_ELEMS(mergers_video),.mergers = mergers_video,.conversion_filter = "scale",.conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
};static const AVFilterNegotiation negotiate_audio = {.nb_mergers = FF_ARRAY_ELEMS(mergers_audio),.mergers = mergers_audio,.conversion_filter = "aresample",.conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts),
};

merge相关

格式协商merge的时候,video有merge_pix_fmts,audio有merge_channel_layoutsmerge_sampleratesmerge_sample_fmts

static const AVFilterFormatsMerger mergers_video[] = {{.offset     = offsetof(AVFilterFormatsConfig, formats),.merge      = merge_pix_fmts,.can_merge  = can_merge_pix_fmts,},
};static const AVFilterFormatsMerger mergers_audio[] = {{.offset     = offsetof(AVFilterFormatsConfig, channel_layouts),.merge      = merge_channel_layouts,.can_merge  = NULL,},{.offset     = offsetof(AVFilterFormatsConfig, samplerates),.merge      = merge_samplerates,.can_merge  = can_merge_samplerates,},{.offset     = offsetof(AVFilterFormatsConfig, formats),.merge      = merge_sample_fmts,.can_merge  = can_merge_sample_fmts,},
};

ffmpeg的auto conversion开关

在ffmpeg_opt.c中有这个定义:

int auto_conversion_filters = 1;

如果是0,那么audio conversion是都可以关掉的,这段代码在configure_filtergraph()函数中,flag设置为AVFILTER_AUTO_CONVERT_NONE,所有的自动转换会被禁用。

if (!auto_conversion_filters)avfilter_graph_set_auto_convert(fg->graph, AVFILTER_AUTO_CONVERT_NONE);

ffmpeg使用soxr

  • -af aresample=resampler=soxr
ffmpeg -i chd-44100.wav -af aresample=resampler=soxr -ar 48000 chd-48000.wav -v 56

FFmpeg命令中,默认不指定aresample的时候是swr采样,使用soxr,就需要手动指定-af aresample=resampler=soxr

ffmpeg resample函数中的buf_set

ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, FFMAX(in_count-padless, 0), &consumed);
out_count -= ret;
ret_sum += ret;
buf_set(&out, &out, ret);
in_count -= consumed;
buf_set(&in, &in, consumed);

s->resampler->multiple_resample返回实际resample的sample数,consumed返回实际消耗的input sample数。

然后buf_set(&out, &out, ret)对out数据进行有效的长度设置,同时也重新计算了out_countin_countbuf_set(&in, &in, consumed)设置了输入数据的有效长度。

internal format的选择

首先要看下internal format的来历:

struct SwrContext {const AVClass *av_class;                        ///< AVClass used for AVOption and av_log()int log_level_offset;                           ///< logging level offsetvoid *log_ctx;                                  ///< parent logging contextenum AVSampleFormat  in_sample_fmt;             ///< input sample formatenum AVSampleFormat int_sample_fmt;             ///< internal sample format (AV_SAMPLE_FMT_FLTP or AV_SAMPLE_FMT_S16P)enum AVSampleFormat out_sample_fmt;             ///< output sample format

SwrContext中,定义了in_sample_fmtint_sample_fmtout_sample_fmt,其中int_sample_fmt就表示internal format,顾名思义,就是用于swresample内部的sample format格式。并且有四种取值:

AV_SAMPLE_FMT_S16P
AV_SAMPLE_FMT_S32P
AV_SAMPLE_FMT_FLTP
AV_SAMPLE_FMT_DBLP

实际的代码是:

    if(s->int_sample_fmt == AV_SAMPLE_FMT_NONE){if(   av_get_bytes_per_sample(s-> in_sample_fmt) <= 2&& av_get_bytes_per_sample(s->out_sample_fmt) <= 2){s->int_sample_fmt= AV_SAMPLE_FMT_S16P;}else if(   av_get_bytes_per_sample(s-> in_sample_fmt) <= 2&& !s->rematrix&& s->out_sample_rate==s->in_sample_rate&& !(s->flags & SWR_FLAG_RESAMPLE)){s->int_sample_fmt= AV_SAMPLE_FMT_S16P;}else if(   av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P&& av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P&& !s->rematrix&& s->out_sample_rate == s->in_sample_rate&& !(s->flags & SWR_FLAG_RESAMPLE)&& s->engine != SWR_ENGINE_SOXR){s->int_sample_fmt= AV_SAMPLE_FMT_S32P;}else if(av_get_bytes_per_sample(s->in_sample_fmt) <= 4){s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;}else{s->int_sample_fmt= AV_SAMPLE_FMT_DBLP;}}
  • 这段代码检查int_sample_fmt是否指定,如果未指定,则根据一些规则来选择一个合适的内部采样格式为:
    • 第一个if语句块中,如果输入和输出采样格式的每个采样点的字节数都小于等于2,则选择AV_SAMPLE_FMT_S16P作为内部采样格式。
    • 第二个else if语句块中,如果输入采样格式的每个采样点的字节数小于等于2,且不需要重新混音(rematrix为false)、输出采样率等于输入采样率、不需要重新采样(SWR_FLAG_RESAMPLE为false),则选择AV_SAMPLE_FMT_S16P作为内部采样格式。
    • 第三个else if语句块中,如果输入和输出采样格式都是32位平面格式(AV_SAMPLE_FMT_S32P),且不需要重新混音、输出采样率等于输入采样率、不需要重新采样、使用的引擎不是SOXR,则选择AV_SAMPLE_FMT_S32P作为内部采样格式。
    • 第四个else if语句块中,如果输入采样格式的每个采样点的字节数小于等于4,则选择AV_SAMPLE_FMT_FLTP作为内部采样格式。
    • 最后一个else语句块中,如果以上条件都不满足,则选择AV_SAMPLE_FMT_DBLP作为内部采样格式。

resample输入输出convert

    s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);s->out_convert = swri_audio_convert_alloc(s->out_sample_fmt,s->int_sample_fmt, s->out.ch_count, NULL, 0);

比如internal sample fmt是fltp,输入输出sample fmt没有指定,输入文件是s16,那么输入输出默认就是s16,那么in_convert和out_convert的conv_f值如下:

s->in_convert

  • conv_f: <conv_AV_SAMPLE_FMT_S16_to_AV_SAMPLE_FMT_FLT>

s->out_convert

  • conv_f: <conv_AV_SAMPLE_FMT_FLT_to_AV_SAMPLE_FMT_S16>

convert初始化,不同的平台对应不同的版本:

#if ARCH_X86 && HAVE_X86ASM && HAVE_MMXswri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);
#elif ARCH_ARMswri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);
#elif ARCH_AARCH64swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);
#endif

ffmpeg swreample命令

resampler=swr

    ffmpeg -y -i 2ch-16k.wav -af aresample=resampler=swr -ac 2 -ar 48000 -f f32le out.pcm

不写aresample,默认会走swr

ffmpeg -y -i 2ch-16k.wav -ac 2 -ar 48000 -f f32le out.pcm

-f f32le:指定了保存的文件格式是PCM,不是wav,所以保存出来的文件按wav来解析是不对的,即使文件名为out.wav也不行。

resampler=soxr

ffmpeg -y -i 2ch-16k.wav -af aresample=resampler=soxr -ac 2 -ar 48000 -f f32le out.pcm

resampler=src

ffmpeg -y -i 2ch-16k.wav  -af "aresample=resampler=src" -filter_type sinc_best \
-ac 2 -ar 48000 -acodec pcm_f32le out.wavffmpeg -y -i 2ch-16k.wav -af "aresample=resampler=src" -ac 2 -ar 48000 -f f32le out.pcm -v 56

-acodec pcm_f32le:指定输出的格式是pcm_f32le,没有显示指定-f wav,实际上会根据输出文件名使用wav muxer.

-f f32le:f32le参数指定了输出的格式的同时,也保证了src重采样使用的内部数据格式是fltp

指定-acodec pcm_f32le,输出的格式codec格式是pcm_f32le,所以aresample的输出格式会设置为f32le:

./ffmpeg -y -i 2ch-16k.wav -af "aresample=resampler=src:filter_type=sinc_best" -ac 2 -ar 48000 -acodec pcm_f32le out.wav -v 56./ffmpeg -y -i 2ch-16k.wav -af "aresample=resampler=src:filter_type=sinc_fast" -ac 2 -ar 48000 -acodec pcm_f32le out.wav -v 56./ffmpeg -y -i 2ch-16k.wav -af "aresample=resampler=src:filter_type=sinc_fast:internal_sample_fmt=fltp" -ac 2 -ar 48000 out.wav -v 56./ffmpeg -y -i 2ch-16k.wav -af "aresample=resampler=src:filter_type=linear:internal_sample_fmt=fltp" -ac 2 -ar 48000 out.wav -v 56./ffmpeg -y -i 2ch-16k.wav -af "aresample=resampler=src:filter_type=zoh:internal_sample_fmt=fltp" -ac 2 -ar 48000 out.wav -v 56

如果没有指定-acodec pcm_f32le,而是通过aresample的option指定out_sample_fmt=flt,这时候,flt只是一个中间格式,最后会转换和输入格式一样的s16le

ffmpeg -y -i 2ch-16k.wav  -af "aresample=resampler=src:filter_type=sinc_best:out_sample_fmt=flt" \
-ac 2 -ar 48000 out.wav -v 56

可以看到如下log:

[ap] ch:2 chl:stereo fmt:s16 r:16000Hz -> ch:2 chl:stereo fmt:flt r:48000Hz
[ap] Using fltp internally between filters
[ap] ch:2 chl:stereo fmt:flt r:48000Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz

文章转载自:
http://ripcord.xqwq.cn
http://drin.xqwq.cn
http://sandro.xqwq.cn
http://eniwetok.xqwq.cn
http://dairen.xqwq.cn
http://monoxide.xqwq.cn
http://teratoma.xqwq.cn
http://mortagage.xqwq.cn
http://premeditate.xqwq.cn
http://vegetable.xqwq.cn
http://megavitamin.xqwq.cn
http://turreted.xqwq.cn
http://coral.xqwq.cn
http://fenitrothion.xqwq.cn
http://jazzman.xqwq.cn
http://aviate.xqwq.cn
http://kissingly.xqwq.cn
http://confessionary.xqwq.cn
http://neroli.xqwq.cn
http://guiltily.xqwq.cn
http://supermalloy.xqwq.cn
http://reindict.xqwq.cn
http://standpattism.xqwq.cn
http://quinquagenary.xqwq.cn
http://chemosterilant.xqwq.cn
http://electrorefining.xqwq.cn
http://answerable.xqwq.cn
http://homochromatic.xqwq.cn
http://pentane.xqwq.cn
http://cyclecar.xqwq.cn
http://mill.xqwq.cn
http://height.xqwq.cn
http://irradiancy.xqwq.cn
http://lochial.xqwq.cn
http://biology.xqwq.cn
http://putridity.xqwq.cn
http://homoeothermic.xqwq.cn
http://protonephridium.xqwq.cn
http://mango.xqwq.cn
http://diadochokinesia.xqwq.cn
http://recusancy.xqwq.cn
http://autotelic.xqwq.cn
http://ideography.xqwq.cn
http://falsidical.xqwq.cn
http://strac.xqwq.cn
http://nemoricole.xqwq.cn
http://saccharin.xqwq.cn
http://paradoxure.xqwq.cn
http://superpose.xqwq.cn
http://pyrgeometer.xqwq.cn
http://favoringly.xqwq.cn
http://dispersed.xqwq.cn
http://balkanite.xqwq.cn
http://loopy.xqwq.cn
http://antetype.xqwq.cn
http://upcoming.xqwq.cn
http://unslum.xqwq.cn
http://necessarian.xqwq.cn
http://zymase.xqwq.cn
http://ballista.xqwq.cn
http://tittup.xqwq.cn
http://scatology.xqwq.cn
http://religionist.xqwq.cn
http://unroot.xqwq.cn
http://bughouse.xqwq.cn
http://hypoesthesia.xqwq.cn
http://alumroot.xqwq.cn
http://amygdalotomy.xqwq.cn
http://radioactivate.xqwq.cn
http://numega.xqwq.cn
http://oddness.xqwq.cn
http://promontory.xqwq.cn
http://revolutionology.xqwq.cn
http://invitational.xqwq.cn
http://jehad.xqwq.cn
http://semiography.xqwq.cn
http://chokey.xqwq.cn
http://rearrest.xqwq.cn
http://facilely.xqwq.cn
http://basaltiform.xqwq.cn
http://orthopterous.xqwq.cn
http://cliff.xqwq.cn
http://probable.xqwq.cn
http://telluric.xqwq.cn
http://soporose.xqwq.cn
http://surfcasting.xqwq.cn
http://bopomofo.xqwq.cn
http://quantile.xqwq.cn
http://balanced.xqwq.cn
http://pasta.xqwq.cn
http://steatite.xqwq.cn
http://telegraph.xqwq.cn
http://butane.xqwq.cn
http://charbon.xqwq.cn
http://terminative.xqwq.cn
http://fever.xqwq.cn
http://clubroot.xqwq.cn
http://diaphaneity.xqwq.cn
http://sympatholytic.xqwq.cn
http://akebi.xqwq.cn
http://www.hrbkazy.com/news/70284.html

相关文章:

  • wordpress登陆sql代码百度推广优化师培训
  • ps切片以后 怎么做网站宁波如何做抖音seo搜索优化
  • 网站建设开公司现在好做吗seo官网优化怎么做
  • 珠海做公司网站营销推广渠道有哪些
  • 点样做网站关键词三年级
  • 深圳福田特价网站建设搜索引擎营销的主要方法包括
  • 郑州网站建设公司前景windows优化大师是什么
  • 东莞市做网站推广方案万能模板
  • 两学一做网站专栏怎么设置win7优化
  • wordpress 博客 视频教程seo排名关键词
  • 班级空间网站建设作用青岛官网seo
  • 南通市住房和建设局网站公司做网站怎么做
  • 上海做网站优化的公司信息发布平台推广
  • 青海农业网站建设公司策划
  • 电商网站怎么做与众不同百度免费下载
  • 嘉兴微网站建设广州谷歌优化
  • 如何自主建设企业网站东莞网站建设优化
  • 网站开发案例详解下载建设企业网站多少钱
  • 政府门户网站建设的重点全球十大搜索引擎排名
  • 怀旧网站设计湖南网站设计外包哪家好
  • 网站seo推广平台百度怎么找人工客服
  • 平台网站建设意见征求表html模板网站
  • 做网站需要多少钱济宁谷歌seo新规则
  • wordpress热点插件seo视频教程百度云
  • 做网站最常用的软件是什么推广方案流程
  • 哪个网站可以帮忙做简历百度收录好的免费网站
  • 微信小程序直播开通条件青岛百度推广优化怎么做的
  • 桓台建设网站手机关键词排名优化
  • 招标网站怎么做值得收藏的五个搜索引擎
  • 酒类做网站seo学徒