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

在线图片编辑像素深圳谷歌优化seo

在线图片编辑像素,深圳谷歌优化seo,手机网站代码下载,扬中论坛音频解析 音频解码是指将压缩的音频数据转换为可以再生的PCM(脉冲编码调制)数据的过程。 FFmpeg音频解码的基本步骤如下: 初始化FFmpeg解码器(4.0版本后可省略): 调用av_register_all()初始化编解码器。 调用avcodec_register_all()注册所有编解码器。 打开输入的音频流:…

音频解析

音频解码是指将压缩的音频数据转换为可以再生的PCM(脉冲编码调制)数据的过程。

FFmpeg音频解码的基本步骤如下:  

  1. 初始化FFmpeg解码器(4.0版本后可省略):
    调用av_register_all()初始化编解码器。

    调用avcodec_register_all()注册所有编解码器。

  2. 打开输入的音频流:

    使用avformat_open_input()函数来读取和打开音频文件。                                                        
    使用avformat_find_stream_info()函数获取流信息。

  3. 查找音频流:
    检索音频流的索AVMEDIA_TYPE_AUDIO。                                                                         
    使用av_find_best_stream()找到第一个音频流并记下它的index。
  4.  打开对应的解码器:

    查找音频流对应的解解码器avcodec_find_decoder()。
    使用avcodec_open2()函数来打开解码器。

  5.  读取音频包解码:

    遍历音频数据,读取音频包(AVPacket)。
    使用av_read_frame()来读取。
    检查包是否属于所需的音频流。

  6. 将音频包送入解码器:

    使用avcodec_send_packet()将包送入解码器准备解码。

  7. 从解码器读取解码后的音频帧:

    使用avcodec_receive_frame()获取解码后的帧(AVFrame)。
    继续从解码器获取所有解码后的帧直到返回EAGAIN或错误。

  8. 转换音频格式 (可选):

    如果需要,将音频数据转换成不同的格式或采样率,可以使用’libswresample’或者’libavresample’。

  9. 后处理 (可选):

    对解码的音频进行必要的后处理,比如音量调整、混音等。

  10.  清理和资源释放: 

    关闭解码器。
    关闭音频文件。
    释放所有使用过的AVFrame和AVPacket。
    释放编解码上下文等。

视频解析  

视频解码的流程目的是将压缩的视频数据流转换成解码后的原始视频帧(通常是YUV或RGB格式)。

 

FFmpeg视频解码的基本步骤如下:  

  1. 初始化FFmpeg解码器(4.0版本后可省略):
    调用av_register_all()初始化编解码器。

    调用avcodec_register_all()注册所有编解码器。

  2. 打开输入的视频流:

    使用avformat_open_input()函数来读取和打开音频文件。                                                        
    使用avformat_find_stream_info()函数获取流信息。

  3. 查找视频流:
     检索视频流的索AVMEDIA_TYPE_VIDEO。                                                                         
    使用av_find_best_stream()找到第一个视频流并记下它的index。
  4.  打开对应的解码器:

    查找视频流对应的解解码器avcodec_find_decoder()。
    使用avcodec_open2()函数来打开解码器。

  5.  读取视频流包解码:

    通过av_read_frame()从媒体文件中读取视频数据(AVPacket)。
    考虑只处理我们之前记下的视频流索引对应的包。

  6. 发送数据到解码器:

    使用avcodec_send_packet()将数据包送入解码器准备解码。

  7. 从解码器读取解码后的视频帧:

    使用avcodec_receive_frame()从解码器中获取解码后的视频帧(AVFrame)。
    需要循环重复此过程以获取所有解码后的帧。

  8. 视频帧处理 (可选):

    将解码的视频帧转换成需要的格式或进行处理,可以使用libswscale来进行格式转换或调整尺寸。

  9. 帧率控制  (可选):

    根据视频的PTS(Presentation Time Stamp)来处理帧率,确保视频按正确的速率播放。

  10.  清理和资源释放: 

    释放已分配的AVCodecContext和AVFormatContext。
    释放使用过的AVFrame和AVPacket。
    关闭视频流和网络库(如果初始化了)。

 视频流解析代码

decoder.h

#ifndef DECODER_H
#define DECODER_H#include <QThread>
#include <QImage>extern "C"
{
//#include "libavfilter/avfiltergraph.h"
#include "libavfilter/buffersink.h"
#include "libavfilter/buffersrc.h"
#include "libswscale/swscale.h"
#include "libavdevice/avdevice.h"
#include "libavutil/pixfmt.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "libavutil/imgutils.h"
}#include "audiodecoder.h"class Decoder : public QThread
{Q_OBJECTpublic:enum PlayState {STOP,PAUSE,PLAYING,FINISH};explicit Decoder();~Decoder();double getCurrentTime();void seekProgress(qint64 pos);int getVolume();void setVolume(int volume);private:void run();void clearData();void setPlayState(Decoder::PlayState state);void displayVideo(QImage image);static int videoThread(void *arg);double synchronize(AVFrame *frame, double pts);bool isRealtime(AVFormatContext *pFormatCtx);int initFilter();int fileType;int videoIndex;int audioIndex;int subtitleIndex;QString currentFile;QString currentType;qint64 timeTotal;AVPacket seekPacket;qint64 seekPos;double seekTime;PlayState playState;bool isStop;bool gotStop;bool isPause;bool isSeek;bool isReadFinished;bool isDecodeFinished;AVFormatContext *pFormatCtx;AVCodecContext *pCodecCtx;          // video codec contextAvPacketQueue videoQueue;AvPacketQueue subtitleQueue;AVStream *videoStream;double videoClk;    // video frame timestampAudioDecoder *audioDecoder;AVFilterGraph   *filterGraph;AVFilterContext *filterSinkCxt;AVFilterContext *filterSrcCxt;public slots:void decoderFile(QString file, QString type);void stopVideo();void pauseVideo();void audioFinished();signals:void readFinished();void gotVideo(QImage image);void gotVideoTime(qint64 time);void playStateChanged(Decoder::PlayState state);};#endif // DECODER_H

decoder.cpp 

#include <QDebug>#include "decoder.h"Decoder::Decoder() :timeTotal(0),playState(STOP),isStop(false),isPause(false),isSeek(false),isReadFinished(false),audioDecoder(new AudioDecoder),filterGraph(NULL)
{av_init_packet(&seekPacket);seekPacket.data = (uint8_t *)"FLUSH";connect(audioDecoder, SIGNAL(playFinished()), this, SLOT(audioFinished()));connect(this, SIGNAL(readFinished()), audioDecoder, SLOT(readFileFinished()));
}Decoder::~Decoder()
{}void Decoder::displayVideo(QImage image)
{emit gotVideo(image);
}void Decoder::clearData()
{videoIndex = -1,audioIndex = -1,subtitleIndex = -1,timeTotal = 0;isStop  = false;isPause = false;isSeek  = false;isReadFinished      = false;isDecodeFinished    = false;videoQueue.empty();audioDecoder->emptyAudioData();videoClk = 0;
}void Decoder::setPlayState(Decoder::PlayState state)
{
//    qDebug() << "Set state: " << state;emit playStateChanged(state);playState = state;
}bool Decoder::isRealtime(AVFormatContext *pFormatCtx)
{if (!strcmp(pFormatCtx->iformat->name, "rtp")|| !strcmp(pFormatCtx->iformat->name, "rtsp")|| !strcmp(pFormatCtx->iformat->name, "sdp")) {return true;}// if(pFormatCtx->pb && (!strncmp(pFormatCtx->filename, "rtp:", 4)//     || !strncmp(pFormatCtx->filename, "udp:", 4)//     )) {//     return true;// }return false;
}int Decoder::initFilter()
{int ret;AVFilterInOut *out = avfilter_inout_alloc();AVFilterInOut *in = avfilter_inout_alloc();/* output format */enum AVPixelFormat pixFmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE};/* free last graph */if (filterGraph) {avfilter_graph_free(&filterGraph);}filterGraph = avfilter_graph_alloc();/* just add filter ouptut format rgb32,* use for function avfilter_graph_parse_ptr()*/QString filter("pp=hb/vb/dr/al");QString args = QString("video_size=%1x%2:pix_fmt=%3:time_base=%4/%5:pixel_aspect=%6/%7").arg(pCodecCtx->width).arg(pCodecCtx->height).arg(pCodecCtx->pix_fmt).arg(videoStream->time_base.num).arg(videoStream->time_base.den).arg(pCodecCtx->sample_aspect_ratio.num).arg(pCodecCtx->sample_aspect_ratio.den);/* create source filter */ret = avfilter_graph_create_filter(&filterSrcCxt, avfilter_get_by_name("buffer"), "in", args.toLocal8Bit().data(), NULL, filterGraph);if (ret < 0) {qDebug() << "avfilter graph create filter failed, ret:" << ret;avfilter_graph_free(&filterGraph);goto out;}/* create sink filter */ret = avfilter_graph_create_filter(&filterSinkCxt, avfilter_get_by_name("buffersink"), "out", NULL, NULL, filterGraph);if (ret < 0) {qDebug() << "avfilter graph create filter failed, ret:" << ret;avfilter_graph_free(&filterGraph);goto out;}/* set sink filter ouput format */ret = av_opt_set_int_list(filterSinkCxt, "pix_fmts", pixFmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);if (ret < 0) {qDebug() << "av opt set int list failed, ret:" << ret;avfilter_graph_free(&filterGraph);goto out;}out->name       = av_strdup("in");out->filter_ctx = filterSrcCxt;out->pad_idx    = 0;out->next       = NULL;in->name       = av_strdup("out");in->filter_ctx = filterSinkCxt;in->pad_idx    = 0;in->next       = NULL;if (filter.isEmpty() || filter.isNull()) {/* if no filter to add, just link source & sink */ret = avfilter_link(filterSrcCxt, 0, filterSinkCxt, 0);if (ret < 0) {qDebug() << "avfilter link failed, ret:" << ret;avfilter_graph_free(&filterGraph);goto out;}} else {/* add filter to graph */ret = avfilter_graph_parse_ptr(filterGraph, filter.toLatin1().data(), &in, &out, NULL);if (ret < 0) {qDebug() << "avfilter graph parse ptr failed, ret:" << ret;avfilter_graph_free(&filterGraph);goto out;}}/* check validity and configure all the links and formats in the graph */if ((ret = avfilter_graph_config(filterGraph, NULL)) < 0) {qDebug() << "avfilter graph config failed, ret:" << ret;avfilter_graph_free(&filterGraph);}out:avfilter_inout_free(&out);avfilter_inout_free(&in);return ret;
}void Decoder::decoderFile(QString file, QString type)
{
//    qDebug() << "Current state:" << playState;qDebug() << "File name:" << file << ", type:" << type;if (playState != STOP) {isStop = true;while (playState != STOP) {SDL_Delay(10);}SDL_Delay(100);}clearData();SDL_Delay(100);currentFile = file;currentType = type;this->start();
}void Decoder::audioFinished()
{isStop = true;if (currentType == "music") {SDL_Delay(100);emit playStateChanged(Decoder::FINISH);}
}void Decoder::stopVideo()
{if (playState == STOP) {setPlayState(Decoder::STOP);return;}gotStop = true;isStop  = true;audioDecoder->stopAudio();if (currentType == "video") {/* wait for decoding & reading stop */while (!isReadFinished || !isDecodeFinished) {SDL_Delay(10);}} else {while (!isReadFinished) {SDL_Delay(10);}}
}void Decoder::pauseVideo()
{if (playState == STOP) {return;}isPause = !isPause;audioDecoder->pauseAudio(isPause);if (isPause) {av_read_pause(pFormatCtx);setPlayState(PAUSE);} else {av_read_play(pFormatCtx);setPlayState(PLAYING);}
}int Decoder::getVolume()
{return audioDecoder->getVolume();
}void Decoder::setVolume(int volume)
{audioDecoder->setVolume(volume);
}double Decoder::getCurrentTime()
{if (audioIndex >= 0) {return audioDecoder->getAudioClock();}return 0;
}void Decoder::seekProgress(qint64 pos)
{if (!isSeek) {seekPos = pos;isSeek = true;}
}double Decoder::synchronize(AVFrame *frame, double pts)
{double delay;if (pts != 0) {videoClk = pts; // Get pts,then set video clock to it} else {pts = vi

文章转载自:
http://epicure.gtqx.cn
http://millimicron.gtqx.cn
http://styrax.gtqx.cn
http://clithral.gtqx.cn
http://conceited.gtqx.cn
http://requiescat.gtqx.cn
http://imprecision.gtqx.cn
http://purlicue.gtqx.cn
http://duodenum.gtqx.cn
http://remount.gtqx.cn
http://folkway.gtqx.cn
http://compossible.gtqx.cn
http://dogwood.gtqx.cn
http://awake.gtqx.cn
http://hegira.gtqx.cn
http://gland.gtqx.cn
http://sputnik.gtqx.cn
http://redissolve.gtqx.cn
http://habanero.gtqx.cn
http://eurasian.gtqx.cn
http://autotransfusion.gtqx.cn
http://waveform.gtqx.cn
http://marvel.gtqx.cn
http://phosphorous.gtqx.cn
http://enwreathe.gtqx.cn
http://agendum.gtqx.cn
http://sarod.gtqx.cn
http://decinormal.gtqx.cn
http://apostatize.gtqx.cn
http://inconceivability.gtqx.cn
http://trigonous.gtqx.cn
http://squeezability.gtqx.cn
http://zed.gtqx.cn
http://vitreosil.gtqx.cn
http://estrade.gtqx.cn
http://sugarbush.gtqx.cn
http://renovator.gtqx.cn
http://combust.gtqx.cn
http://waziristan.gtqx.cn
http://transgression.gtqx.cn
http://barricade.gtqx.cn
http://tailband.gtqx.cn
http://webbing.gtqx.cn
http://acpi.gtqx.cn
http://placate.gtqx.cn
http://scabies.gtqx.cn
http://qoran.gtqx.cn
http://sympetalous.gtqx.cn
http://yellowback.gtqx.cn
http://foundryman.gtqx.cn
http://fabliau.gtqx.cn
http://pratincole.gtqx.cn
http://russetish.gtqx.cn
http://laa.gtqx.cn
http://marsha.gtqx.cn
http://glomus.gtqx.cn
http://crustless.gtqx.cn
http://alma.gtqx.cn
http://capitalisation.gtqx.cn
http://curling.gtqx.cn
http://vacherin.gtqx.cn
http://tabbinet.gtqx.cn
http://boschbok.gtqx.cn
http://heatspot.gtqx.cn
http://bilievable.gtqx.cn
http://linkwork.gtqx.cn
http://lairage.gtqx.cn
http://photosynthate.gtqx.cn
http://handiness.gtqx.cn
http://acosmism.gtqx.cn
http://parachute.gtqx.cn
http://nabobery.gtqx.cn
http://agranulocyte.gtqx.cn
http://aubergine.gtqx.cn
http://clupeid.gtqx.cn
http://unexpressive.gtqx.cn
http://mucific.gtqx.cn
http://outcross.gtqx.cn
http://discursion.gtqx.cn
http://estop.gtqx.cn
http://libertarism.gtqx.cn
http://quizzicality.gtqx.cn
http://cradle.gtqx.cn
http://pygmalion.gtqx.cn
http://sfa.gtqx.cn
http://incidentally.gtqx.cn
http://arrestant.gtqx.cn
http://decenniad.gtqx.cn
http://domestically.gtqx.cn
http://thespis.gtqx.cn
http://locational.gtqx.cn
http://grecize.gtqx.cn
http://colorway.gtqx.cn
http://objectify.gtqx.cn
http://promotee.gtqx.cn
http://punily.gtqx.cn
http://climacteric.gtqx.cn
http://mikvah.gtqx.cn
http://jocundly.gtqx.cn
http://rigatoni.gtqx.cn
http://www.15wanjia.com/news/94175.html

相关文章:

  • 旅游网站模板 手机搜索引擎入口网址
  • 服务器网站源码在哪营销方法有哪些方式
  • .net电子商务网站开发福州专业的seo软件
  • 北海网站制作商丘搜索引擎优化
  • 网站开发基础课程想做电商怎么入手
  • 用电信固定IP做网站公司推广方法有哪些
  • 31省今天全国疫情最新消息谷歌seo技巧
  • 做一个网站app需要多少钱重庆官网seo分析
  • 国外html5特效网站如何网站推广
  • 做网站图片要求大数据营销推广精准粉
  • 百度对网站的收录电子营销主要做什么
  • 镇江专业网站建设制作目前最好的营销模式
  • 铭万魔方做网站怎么样十大培训机构教育培训机构哪家好
  • 网络推广培训网站今日舆情热点
  • 中国设计网站导航建站网站关键词优化
  • 辽宁省政府网站集约化建设查询网入口
  • 一键卸载wordpress二十条优化疫情措施
  • seo全称是什么重庆搜索引擎seo
  • 有没有哪个做美食的网站软文大全500篇
  • 个人如何做一个网站长沙市网站制作
  • 做的网站不能放视频播放器5g站长工具查询
  • 如何根据流量选择网站竞价推广账户竞价托管收费
  • 嘉兴做网站公司哪家好google chrome官网
  • 外贸公司都是在什么网站做推广关键词优化外包服务
  • 怎么做淘宝联盟网站推广广告宣传
  • 一流的嘉兴网站建设免费培训机构管理系统
  • 日照网站建设公司怎么免费搭建自己的网站
  • 一键建站模板巩义网络推广
  • seo网站设计多少钱全国疫情实时资讯
  • 煜阳做网站备案查询网