-
大小: 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-边缘检测
相关资源
- ffmpeg的so文件
- ffmpeg的avi转flv
- ffmpeg 支持水印
- mp3decode.rar
- FFmpeg-full-SDK-3.2.zip
- 一个可以解码并实时播放H264的播放器
- QT+ffmpeg+多摄像头+实时Ubuntu直接可用(
- 基于qt4的多媒体播放器图片,音乐,
- HEVC Reference Software (HM) 16.10
- 使用FFmpeg和Qt制作图形化转码工具
- 多媒体编程开发之FFmpeg基础库(pdf)
- AVS2_Release.rar
- h264+ffmpeg+opencv开发手册
- 基于FFmpeg的H_264解码器实现_王彤
- windows32位下的ffmpeg.exe
- ffmpeg-20180130-42323c3-win64-static.zip
- ffmpeg.win32.exe
- ffmpeg-win32-v3.2.4.exe
- ffmpeg之H265解码
-
rtspPla
yer.rar - FFmpeg录屏
- ffmpeg.exe+ffprobe.exe+ffplay.exe
- linux-ffmpeg-3.3.1.tar.gz
- Centos6.5一键安装ffmpeg(含依赖包)
- ffmpeg+SDL2实现的视频播放器(windows版
- H264+ffmpeg解码+VFW播放
- ffmpeg-win64
- ffmpeg实现视频播放
- PlistDecoder
- CMake+opencv3.4编译时 Download: opencv_ffmp
评论
共有 条评论