資源簡介
Qt工程,ffmpeg庫和h264測試文件。純原創,僅供交流學習。
代碼片段和文件信息
#include?“formatthread.h“
#include?
#include?
#include?
//?===============================?video?start?=============================
FormatThread::FormatThread()
{
????pFormatCtx?=?NULL;
????videoStreamIdx?=?-1;
????fileLen=0;
????av_register_all();
}
FormatThread::~FormatThread()
{
????qDebug()<<“Format?thread?exit!“;
????if(NULL!=pFormatCtx)
????{
????????avformat_close_input(&pFormatCtx);
????????free(pFormatCtx);
????}
}
int?FormatThread::openUrl(QString?url)
{
????int?nRet=0;
????pFormatCtx?=?avformat_alloc_context();
????nRet?=?avformat_open_input(&pFormatCtx?url.toStdString().c_str()?NULLNULL);
????if?(nRet?0)
????{
????????qDebug()<<“Can?not?open:“< ????????return?-1;
????}
????if?(avformat_find_stream_info(pFormatCtxNULL)?0)
????{
????????qDebug()<<“Unable?to?get?stream?info!“;
????????return?-2;
????}
????int?i;
????videoStreamIdx?=?-1;
????for?(i?=?0;?i?nb_streams;?i++)
????{
????????if?(pFormatCtx->streams[i]->codec->codec_type?==?AVMEDIA_TYPE_VIDEO)
????????{
????????????videoStreamIdx?=?i;
????????????break;
????????}
????}
????if?(videoStreamIdx?==?-1)
????{
???????qDebug()<<“Unable?to?find?video?stream!“;
???????return?-3;
????}
????QString?strValue;
????strValue=QString::number(pFormatCtx->streams[videoStreamIdx]->codec->width)?+?“*“?+
????????????QString::number(pFormatCtx->streams[videoStreamIdx]->codec->height);
????emit?sig(0strValue0);?//?發送分辨率
????strValue=QString::number(pFormatCtx->streams[videoStreamIdx]->avg_frame_rate.num);
????emit?sig(1strValue0);?//?發送幀率
????QFileInfo?fileInfo;
????fileInfo.setFile(url);
????if(!fileInfo.isFile())?return?-4;
????fileLen=fileInfo.size()/1024;
????strValue=QString::number(fileLen)+“?KB“;
????emit?sig(2strValue0);?????????//?文件大小
}
void?FormatThread::setOutFileName(QString?fileName)
{
????outFileName=fileName;
}
?void??FormatThread::run()
?{
????if(NULL==pFormatCtx)?return;
????qDebug()<<“Thread?start.“;
????AVFormatContext?*o_fmt_ctx;
????AVStream?*o_video_stream;
????AVStream?*i_video_stream;
????int?startFlag=false;
????int?frameCount=0;
????uint32_t?sizeCount=0;
????i_video_stream=pFormatCtx->streams[videoStreamIdx];
????avformat_alloc_output_context2(&o_fmt_ctx?NULL?NULLoutFileName.toStdString().c_str());
????o_video_stream?=?avformat_new_stream(o_fmt_ctx?NULL);
????avcodec_copy_context(o_video_stream->codec?i_video_stream->codec);
????o_video_stream->codec->codec_tag?=?0;
????o_video_stream->codec->flags?=?i_video_stream->codec->flags;
????o_video_stream->codec->flags?|=?CODEC_FLAG_GLOBAL_HEADER;
????o_video_stream->codec->time_base.num?=?i_video_stream->avg_frame_rate.den;
????o_video_stream->codec->time_base.den?=?i_video_stream->avg_frame_rate.num;
????avio_open(&o_fmt_ctx->pb?outFileName.toStdString().c_str()?AVIO_FLAG_WRITE);
????avformat_write_header(o_fmt_ctx?NULL);
?????while?(av_
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????45665??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\developer.html
?????文件???????5642??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\avio_dir_cmd.c
?????文件???????4060??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\avio_reading.c
?????文件??????19624??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\decoding_encoding.c
?????文件??????14634??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\demuxing_decoding.c
?????文件???????5747??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\extract_mvs.c
?????文件??????10058??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\filtering_audio.c
?????文件???????9180??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\filtering_video.c
?????文件??????11854??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\filter_audio.c
?????文件???????5223??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\http_multiclient.c
?????文件???????1758??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\Makefile
?????文件???????1941??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\me
?????文件??????21668??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\muxing.c
?????文件??????14366??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\qsvdec.c
?????文件????????888??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\README
?????文件???????5631??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\remuxing.c
?????文件???????8005??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\resampling_audio.c
?????文件???????5028??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\scaling_video.c
?????文件??????29409??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\transcode_aac.c
?????文件??????20612??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\examples\transcoding.c
?????文件??????58639??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\faq.html
?????文件??????12505??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\fate.html
?????文件????1422304??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-all.html
?????文件??????14155??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-bitstream-filters.html
?????文件?????190242??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-codecs.html
?????文件??????94347??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-devices.html
?????文件?????772460??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-filters.html
?????文件?????141019??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-formats.html
?????文件??????64946??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-protocols.html
?????文件??????13188??2017-03-12?17:03??MediaTools\MediaTools\ffmpeg-3.2.4\doc\ffmpeg-resampler.html
............此處省略227個文件信息
- 上一篇:百度地圖v3.7.0 鷹眼軌跡v2.1.6
- 下一篇:中國河湖矢量數據
評論
共有 條評論