-
大小: 1.36MB文件类型: .gz金币: 1下载: 0 次发布日期: 2023-09-27
- 语言: 其他
- 标签: ffmpeg decode VideoDecode 视频解码
资源简介
基于ffmpeg源码中example稍作修改,可以保存完整YUV数据。添加Makefile,便于编译。解码MPEG视频,并将解码后的数据保存成一帧帧的图片。包含演示使用的视频文件。
代码片段和文件信息
/*
* Copyright (c) 2001 Fabrice Bellard
*
* Permission is hereby granted free of charge to any person obtaining a copy
* of this software and associated documentation files (the “Software“) to deal
* in the Software without restriction including without limitation the rights
* to use copy modify merge publish distribute sublicense and/or sell
* copies of the Software and to permit persons to whom the Software is
* furnished to do so subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
* IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* video decoding with libavcodec API example
*
* @example decode_video.c
*/
#include
#include
#include
#include
#define INBUF_SIZE 4096
static void pgm_save(unsigned char *buf[] int wrap[] int xsize int ysize
char *filename)
{
FILE *f;
int i;
f = fopen(filename“w“);
fprintf(f “P5\n%d %d\n%d\n“ xsize ysize 255);
/* Save Y data */
for (i = 0; (wrap[0]) && (i < ysize); i++)
fwrite(buf[0] + i * wrap[0] 1 xsize f);
/* Save U(Cb) data */
for (i = 0; (wrap[1]) && (i < ysize/2); i++)
fwrite(buf[1] + i * wrap[1] 1 xsize / 2 f);
/* Save V(Cr) data */
for (i = 0; (wrap[2]) && (i < ysize/2); i++)
fwrite(buf[2] + i * wrap[2] 1 xsize / 2 f);
fclose(f);
}
static void decode(AVCodecContext *dec_ctx AVframe *frame AVPacket *pkt
const char *filename)
{
char buf[1024];
int ret;
ret = avcodec_send_packet(dec_ctx pkt);
if (ret < 0) {
fprintf(stderr “Error sending a packet for decoding\n“);
exit(1);
}
while (ret >= 0) {
ret = avcodec_receive_frame(dec_ctx frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return;
else if (ret < 0) {
fprintf(stderr “Error during decoding\n“);
exit(1);
}
printf(“saving frame %3d\n“ dec_ctx->frame_number);
fflush(stdout);
printf(“+++++ FLC-DBG: format:%d linesize[0]:%d linesize[1]:%d linesize[2]:%d +++++\n\n“
frame->format frame->linesize[0] frame->linesize[1] frame->linesize[2]);
/* the picture is allocated by the decoder. no need to
free it */
snprintf(buf sizeof(buf) “%s-%d“ filename dec_ctx->frame_number);
pgm_save(frame->data frame->linesize
- 上一篇:select_course.rar
- 下一篇:VERILOG-边缘检测
相关资源
- vc URL编解码类
- XSS Encode
- nginx-rtmp-win32-master.rar
- FFMEPG实现h264解码
- ffmpegh265rtmp.zip
- ffserver(windows下编译32位)
- qt_ffmpeg_mp4_export_and_import.zip
- 最简单的基于FFmpeg的推流器 1.2
- 简单的ffmpeg推流demo
- FFmpeg和SDL,读内存中的视频流,进行
- ffmpeg之pcm转AAC
- ffmpeg-2.8.14.tar.gz
- 利用ffmpeg的filter混音
- vs2010 ffmpeg实时解码h264码流
- ffmpeg 音视频转码代码
- windows上自己编译的最新的ffmpeg库
- Qt基于FFmpeg播放本地 H.264H264文件
- 从ffmpeg中抽取的h264解码器,可用于
- ffplay源代码
- 最简单的基于FFmpeg的推流器以推送R
- DVD文件VOB的生成代码
- FFmpeg 采集摄像头输出rtmp直播流媒体,
- 基于ffmpeg将avi视频转换为mp4视频
- (补充)修改output-example,将H.264AAC帧
- ffmpeg-win64位库
- X264实时编码,FFmpeg实时解码
- FFmpeg API读取视音频文件信息的一个工
- 使用FFmpeg采集摄像头图像和麦克风音
- opencv_ffmpeg249.dll
- FFmpeg-3.1 windows vs2013编译动态库静态库
评论
共有 条评论