成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

FFmpegYUV420保存JPEG例子-創(chuàng)新互聯(lián)

說(shuō)明 FFmpeg3.4版本

我們提供的服務(wù)有:網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、壽縣ssl等。為近千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的壽縣網(wǎng)站制作公司

bool SaveYUV420ToJPEG(const std::string &strFileName, int nWidth, int nHeight, int linesize, uint8_t * Y, uint8_t * U, uint8_t * V)
{
?AVFormatContext* pFormatCtx;
?AVCodecContext* pCodecCtx;
?AVCodec* pCodec;
?AVFrame* pFrame;???
?AVPacket pkt;???????
?int nRet = 0;?
?
?avformat_alloc_output_context2(&pFormatCtx, NULL, NULL, strFileName.c_str());???
???
?AVStream* pVideoAVStream = avformat_new_stream(pFormatCtx, 0);
?if (NULL == pVideoAVStream) return false;
??
?pCodecCtx = avcodec_alloc_context3(NULL);
?if (NULL == pCodecCtx)?return false;

avcodec_parameters_to_context(pCodecCtx, pVideoAVStream->codecpar);

pCodecCtx->codec_id = pFormatCtx->oformat->video_codec;
?pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;??
?pCodecCtx->pix_fmt = AV_PIX_FMT_YUVJ420P;
?pCodecCtx->width? = nWidth;???
?pCodecCtx->height = nHeight;????
?pCodecCtx->time_base.num = 1;??
?pCodecCtx->time_base.den = 25;???

pCodec = avcodec_find_encoder(pCodecCtx->codec_id);???
?if (NULL == pCodec) return false;
??
?if (avcodec_open2(pCodecCtx, pCodec,NULL) < 0)
?{?????????
??return false;??
?}???
?pFrame = av_frame_alloc();??

int nJpegQuality = 80;?????
?pCodecCtx->qcompress = (float)nJpegQuality/100.f; // 0~1.0, default is 0.5??????
?pCodecCtx->qmin = 2;??????
?pCodecCtx->qmax = 31;??????
?pCodecCtx->max_qdiff = 3;???????
???
?avformat_write_header(pFormatCtx,NULL);????
?av_new_packet(&pkt, pCodecCtx->width * pCodecCtx->height * 3);
?pFrame->data[0] = Y;???
?pFrame->data[1] = U;??
?pFrame->data[2] = V;???
?pFrame->linesize[0] = linesize;???
?pFrame->linesize[1] = linesize/2;???
?pFrame->linesize[2] = linesize/2;???
?
?nRet = avcodec_send_frame(pCodecCtx, pFrame);
?if (avcodec_receive_packet(pCodecCtx, &pkt) != 0) return false;
?????
?pkt.stream_index = 0;???????
?nRet = av_write_frame(pFormatCtx, &pkt);??????
?av_packet_unref(&pkt);
??
?av_write_trailer(pFormatCtx);????
?avcodec_close(pCodecCtx);
?avcodec_free_context(&pCodecCtx);
?av_frame_free(&pFrame);???????
?avio_close(pFormatCtx->pb);???
?avformat_free_context(pFormatCtx);????
?return true;
}

調(diào)用例子

SaveYUV420ToJPEG("fengyuzaitu.jpg", pFrame->width, pFrame->height, pFrame->linesize[0], pFrame->data[0], pFrame->data[1], pFrame->data[2]);

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

分享題目:FFmpegYUV420保存JPEG例子-創(chuàng)新互聯(lián)
本文鏈接:http://jinyejixie.com/article30/dichpo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、ChatGPT、企業(yè)建站、建站公司、用戶體驗(yàn)品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司
井冈山市| 平潭县| 吴忠市| 泸溪县| 屯留县| 南溪县| 沐川县| 务川| 安康市| 探索| 都安| 香格里拉县| 建德市| 景谷| 漳平市| 通道| 霍山县| 格尔木市| 炉霍县| 全南县| 乃东县| 舞阳县| 乌什县| 丹阳市| 乐安县| 楚雄市| 古田县| 佛山市| 马尔康县| 赤峰市| 大同市| 芮城县| 阳曲县| 丹东市| 承德市| 观塘区| 清镇市| 固镇县| 嘉定区| 广西| 鹿邑县|