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

优惠券推广网站怎么做物流网站首页设计

优惠券推广网站怎么做,物流网站首页设计,凡科互动官网登陆,易订货小程序怎么收费最简单的基于 FFmpeg 的音频解码器 最简单的基于 FFmpeg 的音频解码器正文参考工程文件下载 参考雷霄骅博士的文章#xff0c;链接#xff1a;最简单的基于FFMPEGSDL的音频播放器#xff1a;拆分-解码器和播放器 最简单的基于 FFmpeg 的音频解码器 正文 FFmpeg 音频解码器… 最简单的基于 FFmpeg 的音频解码器 最简单的基于 FFmpeg 的音频解码器正文参考工程文件下载 参考雷霄骅博士的文章链接最简单的基于FFMPEGSDL的音频播放器拆分-解码器和播放器 最简单的基于 FFmpeg 的音频解码器 正文 FFmpeg 音频解码器实现了音频数据到 PCM 采样数据的解码。 如果你不会 Vusual Studio 下 FFmpeg 的项目配置可以看我写的教程Visual Studio 2015 中 FFmpeg 开发环境的搭建。 源代码 // Simplest FFmpeg Audio Decoder.cpp : 定义控制台应用程序的入口点。/** * 最简单的基于 FFmpeg 的音频解码器 * Simplest FFmpeg Audio Decoder * * 刘文晨 Liu Wenchen * 812288728qq.com * 电子科技大学/电子信息 * University of Electronic Science and Technology of China / Electronic and Information Science * https://blog.csdn.net/ProgramNovice * * 本程序可以将音频码流MP3AAC等解码为 PCM 采样数据。 * * This software decode audio streams (MP3, ACC...) to PCM data. * */#include stdafx.h#include stdio.h #include stdlib.h #include string.h#define __STDC_CONSTANT_MACROS #ifdef _WIN32 // Windows extern C { #include libavcodec/avcodec.h #include libavformat/avformat.h #include libswresample/swresample.h }; #else // Linux #endif// 1 second of 48kHz 32bit audio单位是字节 #define MAX_AUDIO_FRAME_SIZE 192000 int main(int argc, char* argv[]) {// 结构体及变量定义AVFormatContext* pFormatCtx;int i, audioStream;AVCodecContext* pCodecCtx;AVCodec* pCodec;AVPacket* packet;uint8_t* out_buffer;AVFrame* pFrame;int ret;uint32_t len 0;int got_picture;int index 0;int64_t in_channel_layout;struct SwrContext *au_convert_ctx;// 输出文件路径FILE *pFile fopen(output.pcm, wb);// 输入文件路径char url[] skycity.mp3;// 注册支持的所有的文件格式容器及其对应的 CODEC只需要调用一次av_register_all();// 对网络库进行全局初始化加载 socket 库以及网络加密协议相关的库为后续使用网络相关提供支持// 注意此函数仅用于解决旧 GnuTLS 或 OpenSSL 库的线程安全问题。// 如果 libavformat 链接到这些库的较新版本或者不使用它们则无需调用此函数。// 否则需要在使用它们的任何其他线程启动之前调用此函数。avformat_network_init();// 使用默认参数分配并初始化一个 AVFormatContext 对象pFormatCtx avformat_alloc_context();// 打开输入媒体流分配编解码器上下文、解复用上下文、I/O 上下文if (avformat_open_input(pFormatCtx, url, NULL, NULL) ! 0){printf(Cant open input stream.\n);return -1;}// 读取媒体文件的数据包以获取媒体流信息if (avformat_find_stream_info(pFormatCtx, NULL) 0){printf(Cant find stream information.\n);return -1;}printf(---------------- File Information ---------------\n);// 将 AVFormatContext 结构体中媒体文件的信息进行格式化输出av_dump_format(pFormatCtx, 0, url, false);printf(-------------------------------------------------\n);audioStream -1;for (i 0; i pFormatCtx-nb_streams; i){if (pFormatCtx-streams[i]-codec-codec_type AVMEDIA_TYPE_AUDIO){audioStream i;break;}}if (audioStream -1){printf(Cant find a audio stream.\n);return -1;}// pCodecCtx 是指向音频流的编解码器上下文的指针pCodecCtx pFormatCtx-streams[audioStream]-codec;// 查找 ID 为 pCodecCtx-codec_id 的已注册的音频流解码器pCodec avcodec_find_decoder(pCodecCtx-codec_id);if (pCodec NULL){printf(Codec not found.\n);return -1;}// 初始化指定的编解码器if (avcodec_open2(pCodecCtx, pCodec, NULL) 0){printf(Cant open codec.\n);return -1;}// 为 packet 分配空间packet (AVPacket *)av_malloc(sizeof(AVPacket));// 将 packet 中的可选字段初始化为默认值av_init_packet(packet);// 输出音频参数// 通道类型双声道uint64_t out_channel_layout AV_CH_LAYOUT_STEREO;int out_nb_samples pCodecCtx-frame_size;// 采样格式pcm_s16le整型 16bitAVSampleFormat out_sample_fmt AV_SAMPLE_FMT_S16;// 采样率44100int out_sample_rate 44100;int out_channels av_get_channel_layout_nb_channels(out_channel_layout);int out_buffer_size av_samples_get_buffer_size(NULL, out_channels, out_nb_samples, out_sample_fmt, 1);out_buffer (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE * 2);pFrame av_frame_alloc();// 根据声道数目获取声道布局in_channel_layout av_get_default_channel_layout(pCodecCtx-channels);// 创建重采样结构体 SwrContext 对象au_convert_ctx swr_alloc();// 设置重采样的转换参数au_convert_ctx swr_alloc_set_opts(au_convert_ctx, out_channel_layout, out_sample_fmt, out_sample_rate,in_channel_layout, pCodecCtx-sample_fmt, pCodecCtx-sample_rate, 0, NULL);// 初始化 SwrContext 对象swr_init(au_convert_ctx);// 读取码流中的音频若干帧或者视频一帧while (av_read_frame(pFormatCtx, packet) 0){if (packet-stream_index audioStream){// 解码 packet 中的音频数据pFrame 存储解码数据ret avcodec_decode_audio4(pCodecCtx, pFrame, got_picture, packet);if (ret 0){printf(Error in decoding audio frame.\n);return -1;}if (got_picture 0){// 进行格式转换返回值为实际转换的采样数swr_convert(au_convert_ctx, out_buffer, MAX_AUDIO_FRAME_SIZE, (const uint8_t **)pFrame-data, pFrame-nb_samples);// 打印每一帧的信息printf(index: %5d\t pts: %lld\t packet size: %d\n, index, packet-pts, packet-size);// 向输出文件中写入 PCM 数据fwrite(out_buffer, 1, out_buffer_size, pFile);index;}}// 清空 packet 里面的数据av_free_packet(packet);}// 释放 SwrContext 对象swr_free(au_convert_ctx);// 关闭文件指针fclose(pFile);// 释放内存av_free(out_buffer);// 关闭解码器avcodec_close(pCodecCtx);// 关闭输入音频文件avformat_close_input(pFormatCtx);return 0; }本程序可以直接在 Visual Studio 2015 上运行。 程序运行后会解码下面的音频文件。 解码后的 PCM 采样数据被保存成了一个文件名叫 output.pcm。使用 Adobe Audition 设置采样率等信息后可以查看 PCM 的内容。 参考 05 FFmpeg4.4源码分析–解码 error C4996: ‘fopen’: This function or variable may be unsafe 的解决方法 工程文件下载 GitHubUestcXiye / Simplest-FFmpeg-Audio-Decoder CSDNSimplest FFmpeg Audio Decoder.zip
http://www.zqtcl.cn/news/705381/

相关文章:

  • 怎么通过数据库做网站的登录wordpress 注册登录插件
  • 读书网站排名大的网站建设公司好
  • 电商网站建设系统公司 网站建
  • 西安建站费用优化系统是什么意思
  • 做网站认证对网站有什么好处中信建设有限责任公司四川分公司电话
  • 王者做网站福州seo外包公司
  • 网站建设教程百度网盘网站报价明细
  • 网站建设杭州哪家好ui设计学校
  • 门户网站做等级保护测评成都企业建站系统
  • 网站建设需求确认表网站建设需求材料
  • 定制型网站制作价格北京网站建设费用
  • 与女鬼做的网站上海有限公司
  • ytwzjs烟台网站建设c 做的网站又哪些
  • 做网站就是做app中国包装创意设计网
  • 淄博做网站宿迁房产网丫丫找房
  • 苏州专业做网站比较好的公司杭州好的公司网站设计
  • 做百度网站要多少钱帮做网站一般多少钱
  • 云南网站备案查询山西做网站费用
  • 北京建站管理系统开发网站高转化页面
  • 南充网站制作不会做网站能做网络销售吗
  • 这2个代码 找做网站的 安装一下搜索引擎排行榜
  • 百度收录收费 重大网站网络空间设计说明怎么写
  • 网站开发 php模板图书馆网站建设的项目报告
  • 保定模板建站定制网站wordpress 收集
  • 万网 网站模板软件开发三个主要阶段
  • 网站首页psd格式怎么做seo关键词有哪些类型
  • 做部队网站技术vue做购物网站
  • 品牌网站建设服务机构wordpress英文改中文
  • 系统开发费外链优化方法
  • 网站建设公司起名网站构建的友情链接怎么做