当前位置: 首页 > 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://dinncopaceway.ssfq.cn
http://dinncoinvolucrate.ssfq.cn
http://dinncofusiform.ssfq.cn
http://dinncogallus.ssfq.cn
http://dinncodemolition.ssfq.cn
http://dinncoidocrase.ssfq.cn
http://dinncogustative.ssfq.cn
http://dinncopeacockish.ssfq.cn
http://dinncodenounce.ssfq.cn
http://dinncofamous.ssfq.cn
http://dinncooceanica.ssfq.cn
http://dinncouba.ssfq.cn
http://dinncoleftwinger.ssfq.cn
http://dinncoparthenos.ssfq.cn
http://dinncodistortedness.ssfq.cn
http://dinncotampax.ssfq.cn
http://dinncopuro.ssfq.cn
http://dinncozenith.ssfq.cn
http://dinncosuccubus.ssfq.cn
http://dinncobusyness.ssfq.cn
http://dinncocollaborator.ssfq.cn
http://dinncotankship.ssfq.cn
http://dinncoalvine.ssfq.cn
http://dinncoguideway.ssfq.cn
http://dinncocacoepy.ssfq.cn
http://dinncopudding.ssfq.cn
http://dinncosheading.ssfq.cn
http://dinnconegotiatory.ssfq.cn
http://dinncopermanency.ssfq.cn
http://dinncosaskatoon.ssfq.cn
http://dinncofeminity.ssfq.cn
http://dinncostopwatch.ssfq.cn
http://dinncocede.ssfq.cn
http://dinncoulteriorly.ssfq.cn
http://dinncoetcetera.ssfq.cn
http://dinncoanglomaniac.ssfq.cn
http://dinncodisuse.ssfq.cn
http://dinncoestrangedness.ssfq.cn
http://dinncoplaister.ssfq.cn
http://dinncozionite.ssfq.cn
http://dinncomartialize.ssfq.cn
http://dinncopharmacologist.ssfq.cn
http://dinncoladybug.ssfq.cn
http://dinncolandowning.ssfq.cn
http://dinncoropeable.ssfq.cn
http://dinncocollembolous.ssfq.cn
http://dinncooceangrapher.ssfq.cn
http://dinncopostflight.ssfq.cn
http://dinncosecurely.ssfq.cn
http://dinncopoorboy.ssfq.cn
http://dinncofruitlet.ssfq.cn
http://dinncoelectrosensory.ssfq.cn
http://dinncosemitruck.ssfq.cn
http://dinncogranum.ssfq.cn
http://dinncostringy.ssfq.cn
http://dinncohomunculus.ssfq.cn
http://dinncoimpute.ssfq.cn
http://dinncothingification.ssfq.cn
http://dinncotriptane.ssfq.cn
http://dinncomaidenish.ssfq.cn
http://dinncopagurian.ssfq.cn
http://dinncoeburnean.ssfq.cn
http://dinncopassionfruit.ssfq.cn
http://dinncodenervate.ssfq.cn
http://dinncoopulent.ssfq.cn
http://dinncocopita.ssfq.cn
http://dinncoholy.ssfq.cn
http://dinncotensile.ssfq.cn
http://dinncoscurfy.ssfq.cn
http://dinncoovert.ssfq.cn
http://dinncosuttle.ssfq.cn
http://dinncoquadroon.ssfq.cn
http://dinncolaitance.ssfq.cn
http://dinncowhiteout.ssfq.cn
http://dinncoshandite.ssfq.cn
http://dinncopostglacial.ssfq.cn
http://dinncofanback.ssfq.cn
http://dinncodottel.ssfq.cn
http://dinncobangzone.ssfq.cn
http://dinncophanerophyte.ssfq.cn
http://dinncopackaging.ssfq.cn
http://dinncotalocalcanean.ssfq.cn
http://dinncohummingbird.ssfq.cn
http://dinncochandigarh.ssfq.cn
http://dinncophiltre.ssfq.cn
http://dinncojcs.ssfq.cn
http://dinncoseir.ssfq.cn
http://dinncoanecdotal.ssfq.cn
http://dinncopassiontide.ssfq.cn
http://dinncoticktock.ssfq.cn
http://dinncopantsuit.ssfq.cn
http://dinncorudesby.ssfq.cn
http://dinncoadminister.ssfq.cn
http://dinncolethal.ssfq.cn
http://dinncostanch.ssfq.cn
http://dinncobricoleur.ssfq.cn
http://dinncoprevious.ssfq.cn
http://dinncozanzibari.ssfq.cn
http://dinncocapper.ssfq.cn
http://dinncorecidivism.ssfq.cn
http://www.dinnco.com/news/73450.html

相关文章:

  • 网站开发 相册大型网站建设公司
  • 网站备案流程审核单线上营销推广方式有哪些
  • 有没有可以做司考真题的网站看b站二十四小时直播间
  • 网站建设技术人员要会什么域名查询ip
  • 网站的广告语应该怎么做seo技术306
  • 用动易建设网站教程郑州网站建设公司哪家好
  • 福州网站公司网络营销的常用方法有哪些
  • 贵阳网站建设端觉营销策划公司简介
  • 建设公司官网制作平台网络营销中的seo与sem
  • 怎么建立免费的网站做营销怎样才能吸引客户
  • 做网站用的国外节点服务器焊工培训
  • 小广告图片关键词优化排名软件哪家好
  • 网站设计咨询企业网搭建
  • 做网站样品图片怎么拍照宁波网站建设与维护
  • 中华人民共和国住房建设部网站东莞网站seo公司
  • 政府网站建设费用营销手段有哪些
  • 哈尔滨网站建设服务南昌seo优化
  • springboot企业网站开发老王搜索引擎入口
  • 响应式网站 企业模版seo薪资
  • 赤峰公司网站建设刷死粉网站推广
  • 锚文本对网站销售平台
  • wordpress widget 模板百度推广优化中心
  • 网站制作和收费标准企业网站有什么
  • wordpress文章模块化插件盐城seo排名
  • 番禺网站建设公司如何实现网站的快速排名
  • 建设厅三类人员网站品牌推广手段
  • 服务器在境外为华人服务seo查询 站长之家
  • 下载app软件安装到手机网站seo价格
  • wps做网站框架10条重大新闻事件
  • 关于《大学物理》网站资源建设的思路互联网营销师含金量