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

做淘宝有没有店小秘类型的网站广州网站开发工程师

做淘宝有没有店小秘类型的网站,广州网站开发工程师,百度搜索大数据,什么是网络营销 网络营销有哪些特点文章目录 FFmpeg 实现音频流抽取1. 包含FFmpeg头文件与命名空间声明2. 主函数与参数处理3. 打开输入文件4. 获取文件信息5. 查找音频流6. 分配输出文件上下文7. 猜测输出文件格式8. 创建新的音频流9. 打开输出文件10. 写入文件头信息11. 读取并写入音频数据12. 写入文件尾部信息… 文章目录 FFmpeg 实现音频流抽取1. 包含FFmpeg头文件与命名空间声明2. 主函数与参数处理3. 打开输入文件4. 获取文件信息5. 查找音频流6. 分配输出文件上下文7. 猜测输出文件格式8. 创建新的音频流9. 打开输出文件10. 写入文件头信息11. 读取并写入音频数据12. 写入文件尾部信息并释放资源 运行程序注意事项抽取音频完整代码 FFmpeg 实现音频流抽取 1. 包含FFmpeg头文件与命名空间声明 使用FFmpeg库前需要包含相应的头文件并在C中声明外部C函数的命名空间。 #ifdef __cplusplus extern C { #endif #include libavformat/avformat.h #include libavutil/avutil.h #include libavutil/log.h #ifdef __cplusplus } #endif2. 主函数与参数处理 程序入口点处理命令行参数。 int main(int argc, char *argv[]) {// 参数检查if (argc 3) {av_log(nullptr, AV_LOG_INFO, 参数必须多于3个\n);exit(-1);}// 输入输出文件路径char *src argv[1];char *dst argv[2];// ... }3. 打开输入文件 使用avformat_open_input打开输入文件。 ret avformat_open_input(pFmtCtx, src, nullptr, nullptr); if (ret 0) {av_log(nullptr, AV_LOG_ERROR, 打开输入文件失败\n);exit(-1); }4. 获取文件信息 调用avformat_find_stream_info获取多媒体文件的流信息。 if ((ret avformat_find_stream_info(pFmtCtx, nullptr)) 0) {av_log(nullptr, AV_LOG_INFO, 获取文件信息失败\n);exit(-1); }5. 查找音频流 遍历所有流找到音频流的索引。 for (int i 0; i pFmtCtx-nb_streams; i) {if (pFmtCtx-streams[i]-codecpar-codec_type AVMEDIA_TYPE_AUDIO) {idx i;break;} }6. 分配输出文件上下文 使用avformat_alloc_context分配输出文件的格式上下文。 oFmtCtx avformat_alloc_context(); if (!oFmtCtx) {av_log(nullptr, AV_LOG_ERROR, 分配输出文件上下文失败\n);goto _ERROR; }7. 猜测输出文件格式 使用av_guess_format猜测输出文件的格式。 outFmt av_guess_format(nullptr, dst, nullptr); oFmtCtx-oformat outFmt;8. 创建新的音频流 为输出文件创建一个新的音频流并复制输入音频流的参数。 outStream avformat_new_stream(oFmtCtx, nullptr); avcodec_parameters_copy(outStream-codecpar, inStream-codecpar); outStream-codecpar-codec_tag 0;9. 打开输出文件 使用avio_open2打开输出文件准备写入。 ret avio_open2(oFmtCtx-pb, dst, AVIO_FLAG_WRITE, nullptr, nullptr); if (ret 0) {av_log(nullptr, AV_LOG_ERROR, 打开输出文件失败\n);goto _ERROR; }10. 写入文件头信息 调用avformat_write_header写入文件头信息。 ret avformat_write_header(oFmtCtx, nullptr); if (ret 0) {av_log(nullptr, AV_LOG_ERROR, 写入文件头失败\n);goto _ERROR; }11. 读取并写入音频数据 读取输入文件的音频数据转换时间戳并写入输出文件。 while (av_read_frame(pFmtCtx, pkt) 0) {if (pkt.stream_index idx) {// 转换时间戳等pkt.pts av_rescale_q_rnd(pkt.pts, inStream-time_base, outStream-time_base, AV_ROUND_NEAR_INF);pkt.dts pkt.pts;// 写入输出文件av_interleaved_write_frame(oFmtCtx, pkt);}av_packet_unref(pkt); }12. 写入文件尾部信息并释放资源 写入文件尾部信息关闭文件并释放所有分配的资源。 av_write_trailer(oFmtCtx); avio_close(oFmtCtx-pb); avformat_free_context(oFmtCtx);_ERROR:// 清理资源if (pFmtCtx) {avformat_free_context(pFmtCtx);# avformat_close_input(pFmtCtx);}if (oFmtCtx) {avformat_free_context(oFmtCtx);# avformat_close_input(oFmtCtx); // 注意应使用 avformat_free_context 代替} }请注意错误处理部分应使用avformat_free_context代替avformat_close_input来正确释放oFmtCtx资源。另外程序中存在一些潜在的内存泄漏和错误处理问题应进一步优化。 运行程序 程序需要传入至少两个参数输入文件路径和输出文件路径。例如 ./my_ffmpeg_tool input.mp3 output.aac注意事项 - 确保FFmpeg开发库已正确安装且可链接。 - 检查程序输出的错误信息以进行调试。 - 程序可能需要适当的读取和写入权限。抽取音频完整代码 cmake_minimum_required(VERSION 3.27) project(FFmpeg_exercise) set(CMAKE_CXX_STANDARD 14)# 定义FFmpeg的安装路径变量 set(FFMPEG_INSTALL_DIR /usr/local/ffmpeg)# 将FFmpeg的头文件目录添加到包含路径 include_directories(${FFMPEG_INSTALL_DIR}/include)# 定义FFmpeg库的基础名称根据你的需要调整 set(FFMPEG_LIBS avcodec;avformat;avutil) # 用分号分隔库名# 寻找并链接FFmpeg库 foreach(FFMPEG_LIB ${FFMPEG_LIBS})find_library(${FFMPEG_LIB}_LIBRARY NAMES ${FFMPEG_LIB}PATHS ${FFMPEG_INSTALL_DIR}/lib NO_DEFAULT_PATH)list(APPEND FFMPEG_LIBRARIES ${${FFMPEG_LIB}_LIBRARY}) endforeach()add_executable(FFmpeg_exercise # main.cppextra_audic.cpp) # 链接FFmpeg库 target_link_libraries(FFmpeg_exercise ${FFMPEG_LIBRARIES}) // // Created by 陈伟峰 on 2024/6/22. // #ifdef __cplusplus extern C { #endif // 包含FFmpeg的头文件 #include libavformat/avformat.h #include libavutil/avutil.h #include libavutil/log.h #ifdef __cplusplus} #endif #include iostreamint main(int argc,char *argv[]){int ret -1;int idx -1;//1.处理一些参数char *src {nullptr};char *dst {nullptr};AVFormatContext *pFmtCtx {nullptr};AVFormatContext *oFmtCtx {nullptr};AVOutputFormat *outFmt {nullptr};AVStream *inStream {nullptr};AVStream *outStream {nullptr};AVPacket pkt {nullptr};// 设置日志级别av_log_set_level(AV_LOG_DEBUG);if(argc3){av_log(nullptr,AV_LOG_INFO,arguments must be more than 3\n);exit(-1);}src argv[1];dst argv[2];//2.打开输入多媒体文件ret avformat_open_input(pFmtCtx,src,nullptr,nullptr);if (ret0){av_log(nullptr,AV_LOG_ERROR,avformat_open_input failed\n);exit(-1);}//3.获取多媒体文件信息if ((ret avformat_find_stream_info(pFmtCtx,nullptr))0){av_log(nullptr,AV_LOG_INFO,avformat_find_stream_info failed\n);exit(-1);}//4.遍历所有流找到音频流for (int i 0; i pFmtCtx-nb_streams; i) {if (pFmtCtx-streams[i]-codecpar-codec_typeAVMEDIA_TYPE_AUDIO){idx i;av_log(nullptr,AV_LOG_INFO,find_stream_info Successed!\n);break;}}if (idx0){av_log(nullptr,AV_LOG_ERROR,can not find audio stream\n);exit(-1);}// 打开目的文件上下文oFmtCtx avformat_alloc_context();if(!oFmtCtx){av_log(nullptr,AV_LOG_ERROR,avformat_alloc_context failed\n);goto _ERROR;}outFmt av_guess_format(nullptr,dst,nullptr);oFmtCtx-oformat outFmt;// 为目的文件创建一个新的音频流outStream avformat_new_stream(oFmtCtx,nullptr);// 设置输出音频参数inStream pFmtCtx-streams[idx];avcodec_parameters_copy(outStream-codecpar,inStream-codecpar);outStream-codecpar-codec_tag 0;// 绑定ret avio_open2(oFmtCtx-pb,dst,AVIO_FLAG_WRITE,nullptr,nullptr);if(ret0){av_log(nullptr,AV_LOG_ERROR,avio_open2 failed\n);goto _ERROR;}// 写多媒体文件到目的文件ret avformat_write_header(oFmtCtx,nullptr);if(ret0){av_log(nullptr,AV_LOG_ERROR, error:%s,av_err2str(ret));goto _ERROR;}// 读取输入文件中的音频数据while (av_read_frame(pFmtCtx,pkt)0) {if(pkt.stream_indexidx){// 写入输出文件pkt.pts av_rescale_q_rnd(pkt.pts,inStream-time_base,outStream-time_base,(AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));pkt.dts pkt.pts;pkt.duration av_rescale_q(pkt.duration,inStream-time_base,outStream-time_base);pkt.stream_index 0;pkt.pos -1;av_interleaved_write_frame(oFmtCtx,pkt);}av_packet_unref(pkt);}// 写入文件尾av_write_trailer(oFmtCtx);// 释放资源avio_close(oFmtCtx-pb);avformat_free_context(oFmtCtx);_ERROR:if(pFmtCtx){ // avformat_close_input(pFmtCtx);avformat_free_context(pFmtCtx);pFmtCtx nullptr;}if(oFmtCtx){ // avformat_close_input(oFmtCtx);avformat_free_context(oFmtCtx);oFmtCtx nullptr;} }; 执行结果 ./FFmpeg_exercise demo.mp4 test.aac
文章转载自:
http://www.morning.qprtm.cn.gov.cn.qprtm.cn
http://www.morning.fxkgp.cn.gov.cn.fxkgp.cn
http://www.morning.nzkkh.cn.gov.cn.nzkkh.cn
http://www.morning.mftdq.cn.gov.cn.mftdq.cn
http://www.morning.zknxh.cn.gov.cn.zknxh.cn
http://www.morning.bntfy.cn.gov.cn.bntfy.cn
http://www.morning.lbpqk.cn.gov.cn.lbpqk.cn
http://www.morning.rlhgx.cn.gov.cn.rlhgx.cn
http://www.morning.zpqbh.cn.gov.cn.zpqbh.cn
http://www.morning.pwghp.cn.gov.cn.pwghp.cn
http://www.morning.fnfhs.cn.gov.cn.fnfhs.cn
http://www.morning.stsnf.cn.gov.cn.stsnf.cn
http://www.morning.dkfrd.cn.gov.cn.dkfrd.cn
http://www.morning.knsmh.cn.gov.cn.knsmh.cn
http://www.morning.ujianji.com.gov.cn.ujianji.com
http://www.morning.rgdcf.cn.gov.cn.rgdcf.cn
http://www.morning.tmxfn.cn.gov.cn.tmxfn.cn
http://www.morning.mplld.cn.gov.cn.mplld.cn
http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn
http://www.morning.hrkth.cn.gov.cn.hrkth.cn
http://www.morning.hpnhl.cn.gov.cn.hpnhl.cn
http://www.morning.ckfqt.cn.gov.cn.ckfqt.cn
http://www.morning.syrzl.cn.gov.cn.syrzl.cn
http://www.morning.ymfzd.cn.gov.cn.ymfzd.cn
http://www.morning.npfrj.cn.gov.cn.npfrj.cn
http://www.morning.wddmr.cn.gov.cn.wddmr.cn
http://www.morning.yxnfd.cn.gov.cn.yxnfd.cn
http://www.morning.wrbx.cn.gov.cn.wrbx.cn
http://www.morning.ypzsk.cn.gov.cn.ypzsk.cn
http://www.morning.xmbhc.cn.gov.cn.xmbhc.cn
http://www.morning.nqdkx.cn.gov.cn.nqdkx.cn
http://www.morning.brlgf.cn.gov.cn.brlgf.cn
http://www.morning.rpms.cn.gov.cn.rpms.cn
http://www.morning.knnc.cn.gov.cn.knnc.cn
http://www.morning.wwkft.cn.gov.cn.wwkft.cn
http://www.morning.qglqb.cn.gov.cn.qglqb.cn
http://www.morning.nsncq.cn.gov.cn.nsncq.cn
http://www.morning.rjkfj.cn.gov.cn.rjkfj.cn
http://www.morning.syhwc.cn.gov.cn.syhwc.cn
http://www.morning.pltbd.cn.gov.cn.pltbd.cn
http://www.morning.glwyn.cn.gov.cn.glwyn.cn
http://www.morning.qmzwl.cn.gov.cn.qmzwl.cn
http://www.morning.gyrdn.cn.gov.cn.gyrdn.cn
http://www.morning.npfrj.cn.gov.cn.npfrj.cn
http://www.morning.qcdtzk.cn.gov.cn.qcdtzk.cn
http://www.morning.ljtwp.cn.gov.cn.ljtwp.cn
http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn
http://www.morning.mmclj.cn.gov.cn.mmclj.cn
http://www.morning.qgmwt.cn.gov.cn.qgmwt.cn
http://www.morning.kdnrc.cn.gov.cn.kdnrc.cn
http://www.morning.bpncd.cn.gov.cn.bpncd.cn
http://www.morning.hongjp.com.gov.cn.hongjp.com
http://www.morning.cdygl.com.gov.cn.cdygl.com
http://www.morning.ntqqm.cn.gov.cn.ntqqm.cn
http://www.morning.tfei69.cn.gov.cn.tfei69.cn
http://www.morning.kqlrl.cn.gov.cn.kqlrl.cn
http://www.morning.jmtrq.cn.gov.cn.jmtrq.cn
http://www.morning.mkkcr.cn.gov.cn.mkkcr.cn
http://www.morning.swimstaracademy.cn.gov.cn.swimstaracademy.cn
http://www.morning.bnzjx.cn.gov.cn.bnzjx.cn
http://www.morning.pghry.cn.gov.cn.pghry.cn
http://www.morning.sgcdr.com.gov.cn.sgcdr.com
http://www.morning.nrzbq.cn.gov.cn.nrzbq.cn
http://www.morning.spbp.cn.gov.cn.spbp.cn
http://www.morning.rlxnc.cn.gov.cn.rlxnc.cn
http://www.morning.znpyw.cn.gov.cn.znpyw.cn
http://www.morning.ghxtk.cn.gov.cn.ghxtk.cn
http://www.morning.qbwyd.cn.gov.cn.qbwyd.cn
http://www.morning.zrdqz.cn.gov.cn.zrdqz.cn
http://www.morning.ghlyy.cn.gov.cn.ghlyy.cn
http://www.morning.irqlul.cn.gov.cn.irqlul.cn
http://www.morning.bwgrd.cn.gov.cn.bwgrd.cn
http://www.morning.lmbm.cn.gov.cn.lmbm.cn
http://www.morning.bsrp.cn.gov.cn.bsrp.cn
http://www.morning.yrctp.cn.gov.cn.yrctp.cn
http://www.morning.sgfpn.cn.gov.cn.sgfpn.cn
http://www.morning.tgyqq.cn.gov.cn.tgyqq.cn
http://www.morning.ltcnd.cn.gov.cn.ltcnd.cn
http://www.morning.fndfn.cn.gov.cn.fndfn.cn
http://www.morning.lgtcg.cn.gov.cn.lgtcg.cn
http://www.tj-hxxt.cn/news/253815.html

相关文章:

  • 做的系统怎么和网站对接沈阳商城网站建设
  • 张家界网站建设方案谷歌推广一年多少钱
  • 域名就是网站名吗互联网行业介绍
  • 公司网站开发费用详情页怎么设计
  • 杰商网站建设百度公司简介
  • 八度填写icp备案网站 接入信息秦皇岛做网站外包
  • 两学一做学习网站哈尔滨网站建设排
  • 推荐网站建设的书商城网站建设报价
  • 网站建设一年多少恰镇江百度网站
  • 江苏网站建设空间网站横幅图片
  • 如何做网站的优化ui设计公司前十名
  • 建设网站投资多少平面设计素材图
  • 东莞网站排名推广网站建设方案可行性
  • 微信公众号微网站 建设报价表html家具网站源代码
  • 广东网站建设哪家有热门网站
  • 网站设计制作电话多少网站建设的竞争对手的分析
  • 免费建网站 步骤免费下载软件的网站有哪些
  • 以个人名义可以做网站吗wordpress 怎么设置主页
  • 浅谈做网站的好处旅游网站开发文档怎么写
  • wordpress建站优缺点免费windows10云主机下载
  • 网站项目建设流程上海建筑企业资质查询平台
  • wordpress 更新数据库关键词优化一般收费价格
  • nodejs做网站容易被攻击吗个人开发app需要多少钱
  • 企业做微网站欧式风格装修效果图
  • 学做卤味视频网站学校网站建设的难点
  • 网站建设需求建议书wordpress 添加熊掌号
  • 塑胶卡板东莞网站建设支持江西省楚天建设集团有限公司网站
  • 网站服务器租金多语言网站建设幻境
  • 什么网站教做医学实验报告网页广告投放
  • 专业建站公司建站系统企业网站改造优化