91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.28MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-01-30
  • 語言: 其他
  • 標簽: ffmpeg??

資源簡介

利用ffmpeg庫進行視頻的解碼,將解碼獲取到的幀進行本地存儲為ppm格式的圖片文件。ppm格式的圖片文件大部分的圖片軟件都能進行解析。

資源截圖

代碼片段和文件信息

#include?

extern?“C“{
#include?“libavcodec/avcodec.h“
#include?“libavformat/avformat.h“
#include?“libswscale/swscale.h“
}

void?saveframe(AVframe*?pframe?int?width?int?height?int?iframe)
{
FILE?*pFile;
char?szFilename[32];
int?y;

sprintf(szFilename?“frame%d.ppm“?iframe);
pFile?=?fopen(szFilename?“wb“);
if?(pFile?==?NULL)
return;

fprintf(pFile?“P6\n%d?%d\n255\n“?width?height);

for?(y?=?0;?y? fwrite(pframe->data[0]?+?y*pframe->linesize[0]?1?width?*?3?pFile);

fclose(pFile);
}
int?main()
{
AVFormatContext?*pFormatCtx;
int?i?videoIndex;
AVCodecContext?*pCodecCtx?=?NULL;
AVCodec?*pCodec?=?NULL;

AVPacket?packet;
int?frameFinished;
int?numBytes;
uint8_t?*buffer;

//char*?filename?=?“nihao.avi“;
char*?filename?=?“cuc_ieschool.flv“;
pFormatCtx?=?avformat_alloc_context();
av_register_all();
if?(avformat_open_input(&pFormatCtx?filename?NULL?0)?!=?0)
return?-1;
if?(avformat_find_stream_info(pFormatCtx?NULL)? return?-1;
av_dump_format(pFormatCtx?0?filename?0);

videoIndex?=?-1;
for?(i?=?0;?i?nb_streams;?++i){
if?(pFormatCtx->streams[i]->codec->codec_type?==?AVMEDIA_TYPE_VIDEO){
videoIndex?=?i;
break;
}
}
if?(videoIndex?==?-1)
{
fprintf(stderr?“unsupport?codec\n“);
return?-1;
}
pCodecCtx?=?pFormatCtx->streams[videoIndex]->codec;
pCodec?=?avcodec_find_decoder(pCodecCtx->codec_id);
if?(avcodec_open2(pCodecCtx?pCodec?NULL)? return?-1;

AVframe?*pframeRGB?*pframe;
pframe?=?av_frame_alloc();
pframeRGB?=?av_frame_alloc();
if?(pframe?==?NULL)
return?-1;

numBytes?=?avpicture_get_size(PIX_FMT_RGB24?pCodecCtx->width?pCodecCtx->height);
buffer?=?(uint8_t?*)av_malloc(numBytes?*?sizeof(uint8_t));

avpicture_fill((AVPicture*)pframeRGB?buffer?PIX_FMT_RGB24?pCodecCtx->width?pCodecCtx->height);

i?=?0;
struct?SwsContext*?img_convert_ctx;
img_convert_ctx?=?sws_getContext(pCodecCtx->width?pCodecCtx->height?pCodecCtx->pix_fmt
pCodecCtx->width?pCodecCtx->height?PIX_FMT_RGB24?SWS_BICUBIC?NULL?NULL?NULL);

while?(av_read_frame(pFormatCtx?&packet)?>=?0){
if?(packet.stream_index?==?videoIndex){
avcodec_decode_video2(pCodecCtx?pframe?&frameFinished?&packet);

if?(frameFinished)
{
sws_scale(img_convert_ctx?pframe->data?pframe->linesize?0?pCodecCtx->height?
pframeRGB->data?pframeRGB->linesize);

if?(++i?<=?100)
saveframe(pframeRGB?pCodecCtx->width?pCodecCtx->height?i);
}
}
av_free_packet(&packet);
}

av_free(buffer);
av_free(pframeRGB);
av_free(pframe);
avcodec_close(pCodecCtx);
return?0;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件?????933615??2014-01-01?18:46??ffmpeg_get_ppm\cuc_ieschool.flv

?????文件???????4474??2014-11-11?16:32??ffmpeg_get_ppm\ffmpeg01.vcxproj

?????文件????????945??2014-11-11?15:41??ffmpeg_get_ppm\ffmpeg01.vcxproj.filters

?????文件???????1051??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\aix\math.h

?????文件??????33225??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\avisynth\avisynth_c.h

?????文件???????2679??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\avisynth\avisynth_c_25.h

?????文件??????26159??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\avisynth\avxsynth_c.h

?????文件???????1743??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\avisynth\windowsPorts\basicDataTypeConversions.h

?????文件???????2322??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\avisynth\windowsPorts\windows2linux.h

?????文件???????1140??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\float\float.h

?????文件????????872??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\float\limits.h

?????文件???????2477??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\getopt.c

?????文件???????2126??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\msvcrt\snprintf.c

?????文件??????????0??2014-11-04?10:02??ffmpeg_get_ppm\include\compat\msvcrt\snprintf.d

?????文件???????1298??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\msvcrt\snprintf.h

?????文件???????6894??2014-11-04?10:02??ffmpeg_get_ppm\include\compat\msvcrt\snprintf.o

?????文件???????3708??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\os2threads.h

?????文件????????118??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\plan9\head

?????文件???????1154??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\plan9\main.c

?????文件?????????86??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\plan9\printf

?????文件???????2126??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\snprintf.c

?????文件???????1298??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\snprintf.h

?????文件???????2778??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\strtod.c

?????文件??????????0??2014-11-04?10:02??ffmpeg_get_ppm\include\compat\strtod.d

?????文件???????9200??2014-11-04?10:02??ffmpeg_get_ppm\include\compat\strtod.o

?????文件???????1071??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\tms470\math.h

?????文件???????1064??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\va_copy.h

?????文件???????8566??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\w32pthreads.h

?????文件???????3279??2014-08-17?21:33??ffmpeg_get_ppm\include\compat\windows\makedef

?????文件?????176375??2014-11-04?10:14??ffmpeg_get_ppm\include\libavcodec\avcodec.h

............此處省略169個文件信息

評論

共有 條評論