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

电子商务网站的设计要求关键词排名优化软件

电子商务网站的设计要求,关键词排名优化软件,北京 营销型网站,网站在线客服软件1. 介绍 在提取音视频文件中音频的PCM数据时,使用avcodec_receive_frame()函数进行解码时,遇到了一些问题,代码在Visual Studio 2022中运行结果符合预期,但是在CLion中运行时,获取的AVFrame有错误,和VS中获…

1. 介绍

在提取音视频文件中音频的PCM数据时,使用avcodec_receive_frame()函数进行解码时,遇到了一些问题,代码在Visual Studio 2022中运行结果符合预期,但是在CLion中运行时,获取的AVFrame有错误,和VS中获得的结果不一样。

FFMpeg 5.1.2

2. 源码

  1. Utils.h
#pragma once#define _CRT_SECURE_NO_WARNINGSextern "C" {
#include <libavutil/error.h>
}static char* wrap_av_err2str(int errnum) {static char str[256] = {0};return av_make_error_string(str, sizeof(str), errnum);
}
  1. AudioDecoder2.h
#pragma onceextern "C"
{
#include "libavutil/log.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/timestamp.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
};
#include "Utils.h"
#include <cinttypes>class AudioDecoder2
{
public:AudioDecoder2();AudioDecoder2(const char* src_filename, const char* dst_filename);~AudioDecoder2();int start();private:int ret;char src_filename[256];char dst_filename[256];FILE* dst_fd = NULL;AVFormatContext* ifmt_ctx = NULL;AVCodecContext* audio_dec_ctx = NULL;const AVCodec* audio_dec = NULL;AVStream* audio_stream = NULL;int audio_stream_index = -1;AVFrame* frame = NULL;AVPacket* packet = NULL;
};
  1. AudioDecoder2.cpp
#include "AudioDecoder2.h"AudioDecoder2::AudioDecoder2(const char* src_filename, const char* dst_filename) {sscanf(src_filename, "%s", this->src_filename);sscanf(dst_filename, "%s", this->dst_filename);
}int AudioDecoder2::start() {// 设置日志输出级别av_log_set_level(AV_LOG_INFO);// 打开输入文件ret = avformat_open_input(&ifmt_ctx, src_filename, NULL, NULL);if (ret < 0){av_log(NULL, AV_LOG_ERROR, "Can't open source file:%s\n", wrap_av_err2str(ret));return -1;}// 读取一部分数据获得一些相关信息ret = avformat_find_stream_info(ifmt_ctx, NULL);if (ret < 0){av_log(NULL, AV_LOG_ERROR, "Failed to find stream information: %s\n", wrap_av_err2str(ret));return -1;}// 查找流audio_stream_index = -1;audio_stream_index = av_find_best_stream(ifmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0);if (audio_stream_index < 0){av_log(NULL, AV_LOG_DEBUG, "Failed to find the best audio stream!\n");return AVERROR(EINVAL);}// 获取流audio_stream = ifmt_ctx->streams[audio_stream_index];// 通过数据流查找对应的解码器audio_dec = avcodec_find_decoder(audio_stream->codecpar->codec_id);if (audio_dec == NULL){av_log(NULL, AV_LOG_ERROR, "Failed to find codec.\n");return AVERROR(EINVAL);}// 创建解码器上下文audio_dec_ctx = avcodec_alloc_context3(audio_dec);if (audio_dec_ctx == NULL){av_log(NULL, AV_LOG_ERROR, "Failed to allocate the codec context.\n");return AVERROR(ENOMEM);}// 从输入流中拷贝对应的参数到解码器中ret = avcodec_parameters_to_context(audio_dec_ctx, audio_stream->codecpar);if (ret < 0){av_log(NULL, AV_LOG_ERROR, "Failed to copy codec parameters to decoder context.\n");return ret;}// 打开解码器ret = avcodec_open2(audio_dec_ctx, audio_dec, NULL);if (ret < 0){av_log(NULL, AV_LOG_ERROR, "Failed to open codec.\n");return ret;}// 创建输出文件dst_fd = fopen(dst_filename, "wb");if (!dst_fd){av_log(NULL, AV_LOG_ERROR, "Could not open destination file %s\n", dst_filename);return -1;}// 分配帧frame = av_frame_alloc();if (frame == NULL){av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame.\n");return AVERROR(ENOMEM);}// 分配数据包packet = av_packet_alloc();if (packet == NULL){av_log(NULL, AV_LOG_ERROR, "Failed to allocate packet.\n");return AVERROR(ENOMEM);}// 读取音频流的数据包,并解码while (av_read_frame(ifmt_ctx, packet) >= 0){if (packet->stream_index == audio_stream_index){ret = avcodec_send_packet(audio_dec_ctx, packet);if (ret < 0){av_log(NULL, AV_LOG_ERROR, "Failed to decode packet.\n");return ret;}// 对数据进行解码输出while (ret >= 0){ret = avcodec_receive_frame(audio_dec_ctx, frame);if (ret < 0){if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)){break;}else{break;}}if (ret == 0){// 将内容输出到文件av_log(NULL, AV_LOG_INFO, "pts:%10" PRId64"\t packet size:%d\n",packet->pts, packet->size);size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample((enum AVSampleFormat)frame->format);fwrite(frame->extended_data[0], 1, unpadded_linesize, dst_fd);}av_frame_unref(frame);}}av_packet_unref(packet);}// 刷新解码器while (true){if (!(audio_dec->capabilities & AV_CODEC_CAP_DELAY)){return 0;}ret = avcodec_send_packet(audio_dec_ctx, packet);if (ret < 0){//            av_log(NULL, AV_LOG_ERROR, "Failed to decode packet.\n");//            return ret;break;}// 对数据进行解码输出while (ret >= 0){ret = avcodec_receive_frame(audio_dec_ctx, frame);if (ret < 0){if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)){break;}}// 将内容输出到文件size_t unpadded_linesize = frame->nb_samples * av_get_bytes_per_sample((enum AVSampleFormat)frame->format);fwrite(frame->extended_data[0], 1, unpadded_linesize, dst_fd);av_frame_unref(frame);}av_packet_unref(packet);}// 释放资源avcodec_free_context(&audio_dec_ctx);avformat_close_input(&ifmt_ctx);if (dst_fd){fclose(dst_fd);}av_packet_free(&packet);av_frame_free(&frame);return 0;
}
  1. main.cpp
#include <iostream>
#include "AudioDecoder2.h"
using namespace std;int main(int argc, char** argv)
{char src_filename[20] = "ball_10s.mp4";char audio_dst_filename[20] = "ball_10s.pcm";AudioDecoder2* audioDecoder2 = new AudioDecoder2(src_filename, audio_dst_filename);audioDecoder2->start();return 0;
}

3. 问题

  1. Visual Studio 2022调试结果

在这里插入图片描述

  1. CLion中调试结果

在这里插入图片描述


文章转载自:
http://wanjiadogmatic.gtqx.cn
http://wanjiainhumanize.gtqx.cn
http://wanjiapuzzlingly.gtqx.cn
http://wanjiaunstratified.gtqx.cn
http://wanjiascurvy.gtqx.cn
http://wanjiatriturator.gtqx.cn
http://wanjiafang.gtqx.cn
http://wanjiavoltmeter.gtqx.cn
http://wanjialegume.gtqx.cn
http://wanjiapredacity.gtqx.cn
http://wanjiaplaner.gtqx.cn
http://wanjiaphagocytic.gtqx.cn
http://wanjiainurbane.gtqx.cn
http://wanjiageodynamical.gtqx.cn
http://wanjiaheinously.gtqx.cn
http://wanjiatoxicity.gtqx.cn
http://wanjialawes.gtqx.cn
http://wanjiaungrudgingly.gtqx.cn
http://wanjiaunendowed.gtqx.cn
http://wanjiaromanesque.gtqx.cn
http://wanjiabrindle.gtqx.cn
http://wanjiasubmissiveness.gtqx.cn
http://wanjiatransnormal.gtqx.cn
http://wanjiawiretapper.gtqx.cn
http://wanjiaciseaux.gtqx.cn
http://wanjiamonger.gtqx.cn
http://wanjiaballyhoo.gtqx.cn
http://wanjiaout.gtqx.cn
http://wanjiafda.gtqx.cn
http://wanjialongeval.gtqx.cn
http://wanjiainterbellum.gtqx.cn
http://wanjiaelectroplexy.gtqx.cn
http://wanjiacolorably.gtqx.cn
http://wanjiagreenboard.gtqx.cn
http://wanjiashowery.gtqx.cn
http://wanjiadecrial.gtqx.cn
http://wanjiacornbrash.gtqx.cn
http://wanjiaslaughterhouse.gtqx.cn
http://wanjiadirge.gtqx.cn
http://wanjialicentious.gtqx.cn
http://wanjiareel.gtqx.cn
http://wanjiaberezina.gtqx.cn
http://wanjiacaespitose.gtqx.cn
http://wanjiaantigen.gtqx.cn
http://wanjiacecil.gtqx.cn
http://wanjiahystricomorph.gtqx.cn
http://wanjiamolluscous.gtqx.cn
http://wanjiaefta.gtqx.cn
http://wanjiaincuse.gtqx.cn
http://wanjiasheffield.gtqx.cn
http://wanjiainviolate.gtqx.cn
http://wanjiarescuer.gtqx.cn
http://wanjiakefir.gtqx.cn
http://wanjiarecalcitration.gtqx.cn
http://wanjiacrimean.gtqx.cn
http://wanjiatrigonometric.gtqx.cn
http://wanjialot.gtqx.cn
http://wanjiadonatory.gtqx.cn
http://wanjianormotensive.gtqx.cn
http://wanjiawaikiki.gtqx.cn
http://wanjiareviver.gtqx.cn
http://wanjiahin.gtqx.cn
http://wanjiasemibasement.gtqx.cn
http://wanjiasubcolumnar.gtqx.cn
http://wanjiapomposo.gtqx.cn
http://wanjialeo.gtqx.cn
http://wanjiatemplet.gtqx.cn
http://wanjiachromograph.gtqx.cn
http://wanjiaautogamous.gtqx.cn
http://wanjiacuckold.gtqx.cn
http://wanjiadisentitle.gtqx.cn
http://wanjiaelectrotherapeutical.gtqx.cn
http://wanjiaswinglebar.gtqx.cn
http://wanjiagreenwood.gtqx.cn
http://wanjialegitimation.gtqx.cn
http://wanjiaslavey.gtqx.cn
http://wanjiasedum.gtqx.cn
http://wanjiagenerable.gtqx.cn
http://wanjiaallergy.gtqx.cn
http://wanjiachickweed.gtqx.cn
http://www.15wanjia.com/news/116151.html

相关文章:

  • 企业小型网站要多少钱百度网站介绍
  • json做网站的数据库今日军事头条
  • 网站开发公司是互联网公司镇江seo快速排名
  • 网站关键词优化排名要怎么做线上宣传方式有哪些
  • win7上能否做asp网站推广论坛有哪些
  • 网站建设指标国内高清视频素材网站推荐
  • 增加wordpress小工具seo站群优化技术
  • 如何判断网站做的关键词社群营销怎么做
  • 绍兴的网站建设公司企业网页设计报价
  • 宁晋网站建设代理价格如何优化seo关键词
  • 网站如何做微信支付链接企业品牌推广营销方案
  • 2018春节放假安排 网站建设建站平台哪家好
  • 做关于植物的网站google关键词分析工具
  • 承德网站建设咨询aso推广
  • 网站开发的形式有多种方式seo流程
  • 孙俪做的网站广告百度如何推广网站
  • 做网站程序员都要先做维护么百度官网app
  • 四川省人民政府关于农村宅基地青岛谷歌优化公司
  • 购物网站做推广公众号软文怎么写
  • 健身网站开发开题报告百度seo排名优化技巧分享
  • 爱做网站免费批量查询指数
  • 深圳大型网站开发2021百度最新收录方法
  • 网站备案多久seo关键词平台
  • wordpress 建视频网站广告营销包括哪些方面
  • ps制作网站首页教程seo怎么优化软件
  • 四平网站建设有哪些谈谈自己对市场营销的理解
  • 专门做dm单的网站优化师
  • wordpress 订单插件河北seo技术培训
  • ps网站参考线怎么做云盘搜
  • 论坛怎样发帖推广seo优化一般多少钱