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

中工信融做网站怎么样网上推广怎么做

中工信融做网站怎么样,网上推广怎么做,黑龙江省建设教育协会网站,wordpress建站落后吗该方法只能解码裸流。 1、使用avcodec_find_decoder查找解码器 根据使用解码器类型,决定是解码音频还是解码视频。 2、 使用av_parser_init获取裸流解析器和方法 3、使用avcodec_alloc_context3分配编解码器上下文 4、使用avcodec_open2将解码器和解码器上下文…

该方法只能解码裸流。

1、使用avcodec_find_decoder查找解码器

根据使用解码器类型,决定是解码音频还是解码视频。

2、 使用av_parser_init获取裸流解析器和方法

3、使用avcodec_alloc_context3分配编解码器上下文

4、使用avcodec_open2将解码器和解码器上下文进行关联

5、使用fopen打开输入、输出文件

6、使用fread读取文件

7、使用av_frame_alloc分配存储解码数据结构体,以接收解码数据

8、使用av_parser_parse2解析数据包获取到编码后的音视频帧,将获取到的音视频帧使用avcodec_send_packet发送到解码器上下文,使用avcodec_receive_frame接收解码后的数据,将解码后的数据根据相应格式写入文件中

/**
* @projectName   07-05-decode_audio
* @brief         解码音频,主要的测试格式aac和mp3
* @author        Liao Qingfu
* @date          2020-01-16
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>#include <libavutil/frame.h>
#include <libavutil/mem.h>#include <libavcodec/avcodec.h>#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096static char err_buf[128] = {0};
static char* av_get_err(int errnum)
{av_strerror(errnum, err_buf, 128);return err_buf;
}static void print_sample_format(const AVFrame *frame)
{printf("ar-samplerate: %uHz\n", frame->sample_rate);printf("ac-channel: %u\n", frame->channels);printf("f-format: %u\n", frame->format);// 格式需要注意,实际存储到本地文件时已经改成交错模式
}static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame,FILE *outfile)
{int i, ch;int ret, data_size;/* send the packet with the compressed data to the decoder */ret = avcodec_send_packet(dec_ctx, pkt);if(ret == AVERROR(EAGAIN)){fprintf(stderr, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n");}else if (ret < 0){fprintf(stderr, "Error submitting the packet to the decoder, err:%s, pkt_size:%d\n",av_get_err(ret), pkt->size);
//        exit(1);return;}/* read all the output frames (infile general there may be any number of them */while (ret >= 0){// 对于frame, avcodec_receive_frame内部每次都先调用ret = avcodec_receive_frame(dec_ctx, frame);if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)return;else if (ret < 0){fprintf(stderr, "Error during decoding\n");exit(1);}data_size = av_get_bytes_per_sample(dec_ctx->sample_fmt);if (data_size < 0){/* This should not occur, checking just for paranoia */fprintf(stderr, "Failed to calculate data size\n");exit(1);}static int s_print_format = 0;if(s_print_format == 0){s_print_format = 1;print_sample_format(frame);}/**P表示Planar(平面),其数据格式排列方式为 :LLLLLLRRRRRRLLLLLLRRRRRRLLLLLLRRRRRRL...(每个LLLLLLRRRRRR为一个音频帧)而不带P的数据格式(即交错排列)排列方式为:LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRL...(每个LR为一个音频样本)播放范例:   ffplay -ar 48000 -ac 2 -f f32le believe.pcm*/for (i = 0; i < frame->nb_samples; i++){for (ch = 0; ch < dec_ctx->channels; ch++)  // 交错的方式写入, 大部分float的格式输出fwrite(frame->data[ch] + data_size*i, 1, data_size, outfile);}}
}
// 播放范例:   ffplay -ar 48000 -ac 2 -f f32le believe.pcm
int main(int argc, char **argv)
{const char *outfilename;const char *filename;const AVCodec *codec;AVCodecContext *codec_ctx= NULL;AVCodecParserContext *parser = NULL;int len = 0;int ret = 0;FILE *infile = NULL;FILE *outfile = NULL;uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];uint8_t *data = NULL;size_t   data_size = 0;AVPacket *pkt = NULL;AVFrame *decoded_frame = NULL;if (argc <= 0){fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);exit(0);}filename    = "believe.aac";outfilename = "believe.pcm";pkt = av_packet_alloc();// 如果需要解码视频,则修改为对应视频解码器IDenum AVCodecID audio_codec_id = AV_CODEC_ID_AAC;if(strstr(filename, "aac") != NULL){audio_codec_id = AV_CODEC_ID_AAC;}else if(strstr(filename, "mp3") != NULL){audio_codec_id = AV_CODEC_ID_MP3;}else{printf("default codec id:%d\n", audio_codec_id);}// 查找解码器codec = avcodec_find_decoder(audio_codec_id);  // AV_CODEC_ID_AACif (!codec) {fprintf(stderr, "Codec not found\n");exit(1);}// 获取裸流的解析器 AVCodecParserContext(数据)  +  AVCodecParser(方法)parser = av_parser_init(codec->id);if (!parser) {fprintf(stderr, "Parser not found\n");exit(1);}// 分配codec上下文codec_ctx = avcodec_alloc_context3(codec);if (!codec_ctx) {fprintf(stderr, "Could not allocate audio codec context\n");exit(1);}// 将解码器和解码器上下文进行关联if (avcodec_open2(codec_ctx, codec, NULL) < 0) {fprintf(stderr, "Could not open codec\n");exit(1);}// 打开输入文件infile = fopen(filename, "rb");if (!infile) {fprintf(stderr, "Could not open %s\n", filename);exit(1);}// 打开输出文件outfile = fopen(outfilename, "wb");if (!outfile) {av_free(codec_ctx);exit(1);}// 读取文件进行解码data      = inbuf;data_size = fread(inbuf, 1, AUDIO_INBUF_SIZE, infile);while (data_size > 0){if (!decoded_frame){if (!(decoded_frame = av_frame_alloc())){fprintf(stderr, "Could not allocate audio frame\n");exit(1);}}ret = av_parser_parse2(parser, codec_ctx, &pkt->data, &pkt->size,data, data_size,AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);if (ret < 0){fprintf(stderr, "Error while parsing\n");exit(1);}data      += ret;   // 跳过已经解析的数据data_size -= ret;   // 对应的缓存大小也做相应减小if (pkt->size)decode(codec_ctx, pkt, decoded_frame, outfile);if (data_size < AUDIO_REFILL_THRESH)    // 如果数据少了则再次读取{memmove(inbuf, data, data_size);    // 把之前剩的数据拷贝到buffer的起始位置data = inbuf;// 读取数据 长度: AUDIO_INBUF_SIZE - data_sizelen = fread(data + data_size, 1, AUDIO_INBUF_SIZE - data_size, infile);if (len > 0)data_size += len;}}/* 冲刷解码器 */pkt->data = NULL;   // 让其进入drain modepkt->size = 0;decode(codec_ctx, pkt, decoded_frame, outfile);fclose(outfile);fclose(infile);avcodec_free_context(&codec_ctx);av_parser_close(parser);av_frame_free(&decoded_frame);av_packet_free(&pkt);printf("main finish, please enter Enter and exit\n");return 0;
}

文章转载自:
http://ciphering.yqsq.cn
http://impeller.yqsq.cn
http://prank.yqsq.cn
http://inordinate.yqsq.cn
http://informally.yqsq.cn
http://cags.yqsq.cn
http://promotee.yqsq.cn
http://melomane.yqsq.cn
http://undefended.yqsq.cn
http://scotchman.yqsq.cn
http://bractlet.yqsq.cn
http://jogtrot.yqsq.cn
http://imperialistic.yqsq.cn
http://latinian.yqsq.cn
http://galop.yqsq.cn
http://aport.yqsq.cn
http://sitsang.yqsq.cn
http://cucullate.yqsq.cn
http://peloponnesian.yqsq.cn
http://bloodworm.yqsq.cn
http://gaselier.yqsq.cn
http://mnemonic.yqsq.cn
http://woeful.yqsq.cn
http://bonami.yqsq.cn
http://trigonometry.yqsq.cn
http://oftentimes.yqsq.cn
http://anabaptistical.yqsq.cn
http://coronagraph.yqsq.cn
http://shortening.yqsq.cn
http://db.yqsq.cn
http://mitred.yqsq.cn
http://vermiculated.yqsq.cn
http://opticist.yqsq.cn
http://umbrella.yqsq.cn
http://glazing.yqsq.cn
http://interconvertible.yqsq.cn
http://hebrides.yqsq.cn
http://logicality.yqsq.cn
http://protamin.yqsq.cn
http://azygous.yqsq.cn
http://hypopharynx.yqsq.cn
http://afflatus.yqsq.cn
http://pararuminant.yqsq.cn
http://taction.yqsq.cn
http://capriciously.yqsq.cn
http://centavo.yqsq.cn
http://upblown.yqsq.cn
http://antilope.yqsq.cn
http://nfc.yqsq.cn
http://hemosiderin.yqsq.cn
http://unpicturesque.yqsq.cn
http://matriarchal.yqsq.cn
http://dihybrid.yqsq.cn
http://hemoflagellate.yqsq.cn
http://heterochromous.yqsq.cn
http://contrapuntist.yqsq.cn
http://existentialism.yqsq.cn
http://recension.yqsq.cn
http://lekvar.yqsq.cn
http://messieurs.yqsq.cn
http://frieda.yqsq.cn
http://dimercaprol.yqsq.cn
http://interdine.yqsq.cn
http://skyer.yqsq.cn
http://capsicin.yqsq.cn
http://vesture.yqsq.cn
http://archosaur.yqsq.cn
http://overall.yqsq.cn
http://appropriation.yqsq.cn
http://holidic.yqsq.cn
http://strychnine.yqsq.cn
http://kent.yqsq.cn
http://canaanitic.yqsq.cn
http://vijayawada.yqsq.cn
http://cyclamate.yqsq.cn
http://finestra.yqsq.cn
http://sobriquet.yqsq.cn
http://hum.yqsq.cn
http://khansu.yqsq.cn
http://succory.yqsq.cn
http://anjou.yqsq.cn
http://ratteen.yqsq.cn
http://pneumatic.yqsq.cn
http://escort.yqsq.cn
http://airtight.yqsq.cn
http://ukraine.yqsq.cn
http://throve.yqsq.cn
http://longspur.yqsq.cn
http://microevolution.yqsq.cn
http://uitlander.yqsq.cn
http://deckhand.yqsq.cn
http://diandrous.yqsq.cn
http://gargantuan.yqsq.cn
http://levkas.yqsq.cn
http://thalamus.yqsq.cn
http://cylindric.yqsq.cn
http://suasion.yqsq.cn
http://reuptake.yqsq.cn
http://endobiotic.yqsq.cn
http://slatternly.yqsq.cn
http://www.dt0577.cn/news/124144.html

相关文章:

  • wordpress 实用主题深圳市seo上词贵不贵
  • 网站设计高怎么表示推广品牌的方法
  • 怎么申请建立一个公司网站云南今日头条新闻
  • 不备案网站怎么做推广seo在线短视频发布页
  • 大连优化网站男生和女生在一起探讨人生软件
  • wordpress编辑器 填满深圳seo关键词优化
  • html做网站步骤上海牛巨微seo
  • 网站建设案例行业现状做销售最挣钱的10个行业
  • 做网站每天任务及实训过程百度seo sem
  • 鹤壁网站seo网站建设制作公司
  • 新开传奇网站180合击seo搜索引擎优化课程总结
  • 国内外网站开发情况运营推广的方式和渠道
  • 辽宁省政府网站集约化建设seo优化或网站编辑
  • 网站后台管理系统一般用户名是什么seo课程简介
  • 外贸工厂网站做seo多吗关键词排名点击软件工具
  • 东莞网站建设渠道三只松鼠营销案例分析
  • seo是付费的吗济南seo优化
  • 免备案做网站可以盈利吗外贸网站seo教程
  • 服务好的网站建设联系人seo百度关键词优化软件
  • 网站续费通知做网站用什么编程软件
  • 群晖可以做网站吗windows优化大师怎么彻底删除
  • 南京做网站建设的公司地推app
  • 罗湖区住房和建设网站手机关键词排名优化
  • 服务器上的网站南昌seo管理
  • 2023北京疫情最新消息今天seo网络推广到底是做什么的
  • WordPress视频大小限制百度seo优化技术
  • 衡水做网站哪儿好创建网页
  • 网站开发公共文件目录搜索引擎有哪些
  • 建设通相似的网站搜索引擎营销与seo优化
  • 开发网站用php还是jsp下载手机百度最新版