中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

女裝網(wǎng)站建設(shè)規(guī)劃網(wǎng)站怎樣被百度收錄

女裝網(wǎng)站建設(shè)規(guī)劃,網(wǎng)站怎樣被百度收錄,南寧保潔網(wǎng)站建設(shè),bootsrap做app網(wǎng)站一、使用場景 因為項目中需要加載MP4播放開機視頻,而我們的設(shè)備所使用的架構(gòu)為arm架構(gòu),其中缺乏一些多媒體庫。安裝這些插件庫比較麻煩,所以最終決定使用FFmpeg播放視頻。 二、下載編譯ffmpeg庫 2.1 下載源碼 源碼下載路徑:http…

一、使用場景

  因為項目中需要加載MP4播放開機視頻,而我們的設(shè)備所使用的架構(gòu)為arm架構(gòu),其中缺乏一些多媒體庫。安裝這些插件庫比較麻煩,所以最終決定使用FFmpeg播放視頻。

二、下載編譯ffmpeg庫

2.1 下載源碼

  源碼下載路徑:https://www.ffmpeg.org/download.html#build-windows

2.2 編譯源碼

  1) 解壓:將源碼放到指定目錄,并運行"tar -jxvf ffmpeg-snapshot.tar.bz2"。若是xxx.tar.gz源文件,則用"tar -zxvf ffmpeg-xxx.tar.gz"。

  2) 創(chuàng)建構(gòu)建目錄,"cd ffmpeg", "mkdir build";

  3)編譯:

  a) ubuntu編譯: "./configure --enable-static --prefix=./build"

  b)arm交叉編譯: "./configure --cc=xxx/aarch64-linux-gnu-gcc(QT指定的gcc路徑) --cxx=xxx/aarch64-linux-gnu-g++ --enable-staticc(QT指定的g++路徑) --prefix=./build --enable-cross-compile --arch=arm64 --target-os=linux"。

  4) make安裝: "make && make install"。

  5) 運行:若需要運行ffmpeg則需要增加--enable-shared參數(shù),并且添加環(huán)境變量"export LD_LIBRARY_PATH=xxx/build/lib/"。

  6)使用幫助: 在xxx/build/bin路徑下運行"./ffmpeg --help"。

2.3 常見報錯

  1) 交叉編譯需要指定對應(yīng)的gcc和g++編譯器和其它的如平臺參數(shù),Linux的QTCreator可以通過如下選項查看對應(yīng)的編譯器路徑,工程-》管理構(gòu)建-》編譯器-》指南(Manual)-》雙擊gcc或g++。注意在操作之前需要先選擇工程當前的運行和構(gòu)建平臺為arrch64。

  2) make install 報錯:"strip: Unable to recognise the format of the input file":將config.mak中的"Trip=strip"改為"Trip=arm -linux-strip"。

三、使用源碼

  1.在工程中導(dǎo)入頭文件和庫,注意庫順序。eg:

INCLUDEPATH += xxx/build/include
LIBS += -Lxxx/xxx -lavformat\-lavdevice \-lavcodec \-lswresample \-lavfilter \    -lavutil \-lswscale

  2.頭文件

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QDebug>
#include <QTimer>
#include <QTime>
#include <QAudioOutput>
extern "C"
{#include <libavcodec/avcodec.h>#include <libavformat/avformat.h>#include <libswscale/swscale.h>#include <libavdevice/avdevice.h>#include <libavformat/version.h>#include <libavutil/time.h>#include <libavutil/mathematics.h>#include <libavfilter/buffersink.h>#include <libavfilter/buffersrc.h>#include <libavutil/avutil.h>#include <libavutil/imgutils.h>#include <libavutil/pixfmt.h>#include <libswresample/swresample.h>
}#define MAX_AUDIO_FRAME_SIZE 192000namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{Q_OBJECTpublic:explicit MainWindow(QWidget *parent = nullptr);~MainWindow();public slots:void timeCallback(void);void on_play_clicked();void resizeEvent(QResizeEvent* );private:Ui::MainWindow *ui;int playVedio(void);QTimer *timer;      // 定時播放,根據(jù)幀率來int vedioW,vedioH;  // 圖像寬高QList<QPixmap> vedioBuff;   // 圖像緩存區(qū)QString myUrl = QString("E:/workspace/Qt_workspace/ffmpeg/三國之戰(zhàn)神無雙.mp4");  // 視頻地址AVFormatContext    *pFormatCtx;AVCodecContext  *pCodecCtx;AVCodec         *pCodec;AVFrame         *pFrame, *pFrameRGB;int ret, got_picture,got_audio;  // 視頻解碼標志int videoindex;        // 視頻序號// 音頻int audioindex;        // 音頻序號AVCodecParameters   *aCodecParameters;AVCodec             *aCodec;AVCodecContext      *aCodecCtx;QByteArray          byteBuf;//音頻緩沖QAudioOutput        *audioOutput;QIODevice           *streamOut;
};#endif // MAINWINDOW_H

  3.源文件:

#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{ui->setupUi(this);
//    qDebug(avcodec_configuration());
//    unsigned version = avcodec_version();
//    QString ch = QString::number(version,10);
//    qDebug()<<"version:"<<version;timer = new QTimer(this);timer->setTimerType(Qt::PreciseTimer);   // 精準定時設(shè)置connect(timer,SIGNAL(timeout()),this,SLOT(timeCallback()));
}void MainWindow::timeCallback(void)
{// 視頻緩存播放if(!vedioBuff.isEmpty()){ui->label->setPixmap(vedioBuff.at(0));vedioBuff.removeAt(0);}else {timer->stop();}// 音頻緩存播放if(audioOutput && audioOutput->state() != QAudio::StoppedState && audioOutput->state() != QAudio::SuspendedState){int writeBytes = qMin(byteBuf.length(), audioOutput->bytesFree());streamOut->write(byteBuf.data(), writeBytes);byteBuf = byteBuf.right(byteBuf.length() - writeBytes);}
}void Delay_MSec(unsigned int msec)
{QTime _Timer = QTime::currentTime().addMSecs(msec);while( QTime::currentTime() < _Timer )QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}int MainWindow::playVedio(void)
{QAudioFormat fmt;fmt.setSampleRate(44100);fmt.setSampleSize(16);fmt.setChannelCount(2);fmt.setCodec("audio/pcm");fmt.setByteOrder(QAudioFormat::LittleEndian);fmt.setSampleType(QAudioFormat::SignedInt);audioOutput = new QAudioOutput(fmt);streamOut = audioOutput->start();char *filepath = myUrl.toUtf8().data();av_register_all();avformat_network_init();pFormatCtx = avformat_alloc_context();// 打開視頻文件,初始化pFormatCtx結(jié)構(gòu)if(avformat_open_input(&pFormatCtx,filepath,NULL,NULL)!=0){qDebug("視頻文件打開失敗.\n");return -1;}// 獲取音視頻流if(avformat_find_stream_info(pFormatCtx,NULL)<0){qDebug("媒體流獲取失敗.\n");return -1;}videoindex = -1;audioindex = -1;//nb_streams視音頻流的個數(shù),這里當查找到視頻流時就中斷了。for(int i=0; i<pFormatCtx->nb_streams; i++)if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){videoindex=i;break;}if(videoindex==-1){qDebug("找不到視頻流.\n");return -1;}//nb_streams視音頻流的個數(shù),這里當查找到音頻流時就中斷了。for(int i=0; i<pFormatCtx->nb_streams; i++)if(pFormatCtx->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_AUDIO){audioindex=i;break;}if(audioindex==-1){qDebug("找不到音頻流.\n");return -1;}//獲取視頻流編碼結(jié)構(gòu)pCodecCtx=pFormatCtx->streams[videoindex]->codec;float frameNum = pCodecCtx->framerate.num;  // 每秒幀數(shù)if(frameNum>100)  frameNum = frameNum/1001;int frameRate = 1000/frameNum;   //qDebug("幀/秒 = %f  播放間隔是時間=%d\n",frameNum,frameRate);//查找解碼器pCodec=avcodec_find_decoder(pCodecCtx->codec_id);if(pCodec==NULL){qDebug("找不到解碼器.\n");return -1;}//使用解碼器讀取pCodecCtx結(jié)構(gòu)if(avcodec_open2(pCodecCtx, pCodec,NULL)<0){qDebug("打開視頻碼流失敗.\n");return -1;}//獲取音頻流編碼結(jié)構(gòu)-------------------------------------------------------------aCodecParameters = pFormatCtx->streams[audioindex]->codecpar;aCodec = avcodec_find_decoder(aCodecParameters->codec_id);if (aCodec == 0) {qDebug("找不到解碼器.\n");return -1;}aCodecCtx = avcodec_alloc_context3(aCodec);avcodec_parameters_to_context(aCodecCtx, aCodecParameters);//使用解碼器讀取aCodecCtx結(jié)構(gòu)if (avcodec_open2(aCodecCtx, aCodec, 0) < 0) {qDebug("打開視頻碼流失敗.\n");return 0;}// 清空緩存區(qū)byteBuf.clear();vedioBuff.clear();//創(chuàng)建幀結(jié)構(gòu),此函數(shù)僅分配基本結(jié)構(gòu)空間,圖像數(shù)據(jù)空間需通過av_malloc分配pFrame = av_frame_alloc();pFrameRGB = av_frame_alloc();// 獲取音頻參數(shù)uint64_t out_channel_layout = aCodecCtx->channel_layout;AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16;int out_sample_rate = aCodecCtx->sample_rate;int out_channels = av_get_channel_layout_nb_channels(out_channel_layout);uint8_t *audio_out_buffer = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE*2);SwrContext *swr_ctx = swr_alloc_set_opts(NULL, out_channel_layout, out_sample_fmt,out_sample_rate, aCodecCtx->channel_layout, aCodecCtx->sample_fmt, aCodecCtx->sample_rate, 0, 0);swr_init(swr_ctx);//創(chuàng)建動態(tài)內(nèi)存,創(chuàng)建存儲圖像數(shù)據(jù)的空間unsigned char *out_buffer = (unsigned char *)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_RGB32, pCodecCtx->width, pCodecCtx->height, 1));av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, out_buffer, AV_PIX_FMT_RGB32, pCodecCtx->width, pCodecCtx->height, 1);AVPacket *packet = (AVPacket *)av_malloc(sizeof(AVPacket));//初始化img_convert_ctx結(jié)構(gòu)struct SwsContext *img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);timer->start(frameRate);  //定時間隔播放while (av_read_frame(pFormatCtx, packet) >= 0){if (packet->stream_index == audioindex){int ret = avcodec_decode_audio4(aCodecCtx, pFrame, &got_audio, packet);if ( ret < 0){qDebug("解碼失敗.\n");return 0;}if (got_audio){int len = swr_convert(swr_ctx, &audio_out_buffer, MAX_AUDIO_FRAME_SIZE, (const uint8_t **)pFrame->data, pFrame->nb_samples);if (len <= 0){continue;}int dst_bufsize = av_samples_get_buffer_size(0, out_channels, len, out_sample_fmt, 1);QByteArray atemp =  QByteArray((const char *)audio_out_buffer, dst_bufsize);byteBuf.append(atemp);}}//如果是視頻數(shù)據(jù)else if (packet->stream_index == videoindex){//解碼一幀視頻數(shù)據(jù)ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet);if (ret < 0){qDebug("解碼失敗.\n");return 0;}if (got_picture){sws_scale(img_convert_ctx, (const unsigned char* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height,pFrameRGB->data, pFrameRGB->linesize);QImage img((uchar*)pFrameRGB->data[0],pCodecCtx->width,pCodecCtx->height,QImage::Format_RGB32);img = img.scaled(vedioW, vedioH);QPixmap temp = QPixmap::fromImage(img);vedioBuff.append(temp);Delay_MSec(frameRate-5);  // 這里需要流出時間來顯示,如果不要這個延時界面回卡死到整個視頻解碼完成才能播放顯示//ui->label->setPixmap(temp);}}av_free_packet(packet);}sws_freeContext(img_convert_ctx);av_frame_free(&pFrameRGB);av_frame_free(&pFrame);avcodec_close(pCodecCtx);avformat_close_input(&pFormatCtx);
}void MainWindow::resizeEvent(QResizeEvent* )
{vedioW = ui->label->width();vedioH = ui->label->height();
}
MainWindow::~MainWindow()
{delete ui;
}void MainWindow::on_play_clicked()
{vedioW = ui->label->width();vedioH = ui->label->height();if(timer->isActive())   timer->stop();playVedio();
}

http://www.risenshineclean.com/news/41770.html

相關(guān)文章:

  • 怎么做網(wǎng)站的后臺管理系統(tǒng)手機360優(yōu)化大師官網(wǎng)
  • 微網(wǎng)站后臺怎么注冊互聯(lián)網(wǎng)推廣平臺有哪些公司
  • 辦公室現(xiàn)代簡約裝修效果圖武漢seo服務(wù)
  • 金山石化網(wǎng)站建設(shè)襄陽seo優(yōu)化排名
  • 做網(wǎng)站建設(shè)的上市公司有哪些百度競價是seo還是sem
  • lamp網(wǎng)站開發(fā) pdf企業(yè)網(wǎng)站建設(shè)需求分析
  • 做便民工具網(wǎng)站怎么樣百度問答兼職怎么做
  • 網(wǎng)站怎么防采集如何推廣普通話
  • 長子營網(wǎng)站建設(shè)產(chǎn)品優(yōu)化是什么意思
  • 做3d模型的叫什么牛的網(wǎng)站磁力鏈搜索引擎入口
  • 黃色風(fēng)格網(wǎng)站模板商城小程序
  • 十堰網(wǎng)站建設(shè)兼職發(fā)軟文的平臺
  • 長沙的互聯(lián)網(wǎng)網(wǎng)站公司營銷培訓(xùn)方案
  • 門戶網(wǎng)站系統(tǒng)設(shè)計sem全稱
  • wordpress qq客服代碼seo有什么作用
  • 廣州網(wǎng)站提升排名百度指數(shù)使用指南
  • 做發(fā)票網(wǎng)站淘寶如何刷關(guān)鍵詞增加權(quán)重
  • 可視化網(wǎng)站建設(shè)軟件百度競價品牌廣告
  • 專業(yè) 網(wǎng)站設(shè)計公司外貿(mào)網(wǎng)站seo教程
  • 北京公司網(wǎng)站建設(shè)價格廣州網(wǎng)站制作服務(wù)
  • 貴州省建設(shè)廳二建報名網(wǎng)站全球疫情最新數(shù)據(jù)
  • 做證書的網(wǎng)站廈門seo推廣外包
  • 網(wǎng)站開發(fā)功能需求表百度關(guān)鍵詞優(yōu)化軟件
  • 南通網(wǎng)站關(guān)鍵詞優(yōu)化發(fā)稿吧
  • 裝修網(wǎng)站開發(fā)前的準備工作百度推廣一個月多少錢
  • pc網(wǎng)站是什么seo網(wǎng)頁優(yōu)化培訓(xùn)
  • 網(wǎng)站備案跟域名備案廣告文案經(jīng)典范例200字
  • 一個網(wǎng)站按鈕怎么做精準的搜索引擎優(yōu)化
  • 國家市場監(jiān)督管理總局60號令百度seo排名原理
  • 湛江高端網(wǎng)站建設(shè)頁面優(yōu)化的方法