ffmpeg学习之tutorial_1

ffmpeg播放器实现详解 - 视频显示 ffplay是ffmpeg源码中一个自带的开源播放器实例,同时支持本地视频文件的播放以及在线流媒体播放,功能非常强大。ffplay中的代码充分调用了ffmpeg中的函数库,因此,想学习ffmpeg的使用,或基于ffmpeg开发一个自己的播放器,ffplay都是一个很好的切入点。由于ffmpeg本身的开发文档比较少,且ffplay播放器源码的实现相对复杂,除了基础的ffmpeg组件调用外,还包含视频帧的渲染、音频帧的播放、音视频同步策略及线程调度等问题。 阅读详情

      最近对ffmpeg感兴趣, 由于我用的是ffmpeg1.1.3,由于 ffmpeg更新很快,网上的很多例子已经很陈旧了,找到了最新版本的这个tutorial点击打开链接。由于对ffmpeg不熟悉,所以需要不断地查看接口。在参考了http://my.oschina.net/u/555701/blog/56616?p=3#comments的基础上,于是有了如下的解析。与新手共勉。


Tutorial 1: Decoding video frames

视频播放过程

      首先简单介绍以下视频文件的相关知识。我们平时看到的视频文件有许多格式,比如 avi, mkv, rmvb, mov, mp4等等,这些被称为容器(Container), 不同的容器格式规 定了其中音视频数据的组织方式(也包括其他数据,比如字幕等)。容器中一般会封装有视频和音频轨,也称为视频流(stream)和音频 流,播放视频文件的第一步就是根据视频文件的格式,解析(demux)出其中封装的视频流、音频流以及字幕(如果有的话),解析的数据读到包 (packet)中,每个包里保存的是视频帧(frame)或音频帧,然后分别对视频帧和音频帧调用相应的解码器(decoder)进行解码,比如使用 H.264编码的视频和MP3编码的音频,会相应的调用H.264解码器和MP3解码器,解码之后得到的就是原始的图像(YUV or RGB)和声音(PCM)数据,然后根据同步好的时间将图像显示到屏幕上,将声音输出到声卡,最终就是我们看到的视频。

FFmpeg的API就是根据这个过程设计的,因此使用FFmpeg来处理视频文件的方法非常直观简单。下面就一步一步介绍从视频文件中解码出图片的过程。

声明变量

首先定义整个过程中需要使用到的变量:

 31     AVFormatContext *pFormatCtx = NULL;
 32     int i, videoStream;
 33     AVCodecContext *pCodecCtx = NULL;
 34     AVCodec *pCodec = NULL;
 35     AVFrame *pFrame = NULL;
 36     AVFrame *pFrameRGB = NULL;
 37     AVPacket packet;
 38     int frameFinished;
 39     int numBytes;
 40     uint8_t *buffer = NULL;


  • AVFormatContext:保存需要读入的文件的格式信息,比如流的个数以及流数据等。http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html
  • AVCodecContext:保存了相应流的详细编码信息,比如视频的宽、高,编码类型等。http://ffmpeg.org/doxygen/trunk/structAVCodecContext.html
  • AVCodec:真正的编解码器,其中有编解码需要调用的函数。http://ffmpeg.org/doxygen/trunk/structAVCodec.html
  • AVFrame:用于保存数据帧的数据结构,这里的两个帧分别是保存颜色转换前后的两帧图像。http://ffmpeg.org/doxygen/trunk/structAVFrame.html
  • AVPacket:解析文件时会将音/视频帧读入到packet中。http://ffmpeg.org/doxygen/trunk/structAVPacket.html

打开文件

接下来我们打开一个视频文件。


 49     // Register all formats and codecs,

 50     av_register_all();

av_register_all:
http://ffmpeg.org/doxygen/trunk/group__lavf__core.html#ga917265caec45ef5a0646356ed1a507e3
//Initialize libavformat and register all the muxers, demuxers and protocols.
     
      av_register_all() :  定义在 libavformat 里,调用它用以注册所有支持的文件格式以及编解码器,从其 实现代码里可以看到它会调用 avcodec_register_all,因此之后就可以用所有ffmpeg支持的codec了。

 52     // Open video file
 53     if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0)
 54         return -1; // Couldn't open file

avformat_open_input:
 http://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32

Open an input stream and read the header.

The codecs are not opened. The stream must be closed with av_close_input_file().


使用新的API avformat_open_input来打开一个文件,第一个参数是一个AVFormatContext指针变量的地址,它会根据打开的文件信息填充AVFormatContext, 需要注意的是,此处的pFormatContext必须为NULL或由avformat_alloc_context分配得到,这也是上一节中将其初始化为NULL的原因,否则此函数调用会出问题。第二个参数是打开的文件名,通过argv[1]指定,也就是命令行的第一个参数。后两个参数分别用于指定特定的输入格式( AVInputFormat)以及指定文件打开额外参数的 AVDictionary结构,这里均留作NULL。

 56     // Retrieve stream information
 57     if(avformat_find_stream_info(pFormatCtx, NULL)<0)
 58         return -1; // Couldn't find stream information
 59
 60     // Dump information about file onto standard error
 61     av_dump_format(pFormatCtx, 0, argv[1], 0);

avformat_find_stream_info:
http://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32
Read packets of a media file to get stream information.

av_dump_format:
http://ffmpeg.org/doxygen/trunk/group__lavf__misc.html#gae2645941f2dc779c307eb6314fd39f10

avformat_open_input函数只是读文件头,并不会填充流信息,因此我们需要接下来调用avformat_find_stream_info获取文件中的流信息,此函数会读取packet,并确定文件中所有的流信息,设置pFormatCtx->streams指向文件中的流,但此函数并不会改变文件指针,读取的packet会给后面的解码进行处理。
最后调用一个帮助函数av_dump_format,输出文件的信息,也就是我们在使用ffmpeg时能看到的文件详细信息。第二个参数指定输出哪条流的信息,-1表示给ffmpeg自己选择。最后一个参数用于指定dump的是不是输出文件,我们dump的是输入文件,因此一定要是0。

现在 pFormatCtx->streams 中已经有所有流了,因此现在我们遍历它找到第一条视频流:


 63     // Find the first video stream
 64     videoStream=-1;
 65     for(i=0; i<pFormatCtx->nb_streams; i++)
 66         if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
 67             videoStream=i;
 68             break;
 69         }
 70     if(videoStream==-1)
 71         return -1; // Didn't find a video stream

pFormatCtx:http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html中查看数据结构相关参数

codec_type 的宏定义已经由以前的 CODEC_TYPE_VIDEO 改为 AVMEDIA_TYPE_VIDEO 了。接下来我们通过这条 video stream 的编解码信息打开相应的解码器:

 73     // Get a pointer to the codec context for the video stream
 74     pCodecCtx=pFormatCtx->streams[videoStream]->codec;
 75
 76     // Find the decoder for the video stream
 77     pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
 78     if(pCodec==NULL) {
 79         fprintf(stderr, "Unsupported codec!\n");
 80         return -1; // Codec not found
 81     }
 82     // Open codec
 83     if(avcodec_open2(pCodecCtx, pCodec, &optionsDict)<0)
 84         return -1; // Could not open codec

avcodec_find_decoder:
http://ffmpeg.org/doxygen/trunk/group__lavc__decoding.html#ga19a0ca553277f019dd5b0fec6e1f9dca
Find a registered decoder with a matching codec ID.
avcodec_open2:
http://ffmpeg.org/doxygen/trunk/group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d
Initialize the AVCodecContext to use the given AVCodec.

分配图像缓存

接下来我们准备给即将解码的图片分配内存空间。

 86     // Allocate video frame
 87     pFrame=avcodec_alloc_frame();
 88
 89     // Allocate an AVFrame structure
 90     pFrameRGB=avcodec_alloc_frame();
 91     if(pFrameRGB==NULL)
 92         return -1;

avcodec_alloc_frame:
http://ffmpeg.org/doxygen/trunk/group__lavc__core.html#gad5f9212dec34c9fff0124171fa684a18

Allocate an AVFrame and set its fields to default values.

The resulting struct must be freed using avcodec_free_frame().


调用 avcodec_alloc_frame 分配帧,因为最后我们会将图像写成 24-bits RGB 的 PPM 文件,因此这里需要两个 AVFrame,pFrame用于存储解码后的数据,pFrameRGB用于存储转换后的数据:

 94     // Determine required buffer size and allocate buffer
 95     numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
 96             pCodecCtx->height);
 

avpicture_get_size:

http://ffmpeg.org/doxygen/trunk/group__lavc__picture.html#ga18a08bcb237767ef442fd5d3d1dd2084

Calculate the size in bytes that a picture of the given width and height would occupy if stored in the given picture format.

Always assume a linesize alignment of 1.


这里调用 avpicture_get_size,根据 pCodecCtx 中原始图像的宽高计算 RGB24 格式的图像需要占用的空间大小,这是为了之后给 pFrameRGB 分配空间:

 97     buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
 98
 99     sws_ctx =
100         sws_getContext
101         (
102          pCodecCtx->width,
103          pCodecCtx->height,
104          pCodecCtx->pix_fmt,
105          pCodecCtx->width,
106          pCodecCtx->height,
107          PIX_FMT_RGB24,
108          SWS_BILINEAR,
109          NULL,
110          NULL,
111          NULL
112         );
113
114     // Assign appropriate parts of buffer to image planes in pFrameRGB
115     // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
116     // of AVPicture
117     avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
118             pCodecCtx->width, pCodecCtx->height);

av_malloc:
http://ffmpeg.org/doxygen/trunk/group__lavu__mem.html#gacbca30ebc510a7e4156d66e7aceb2dc8
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU).
sws_getContext:
http://ffmpeg.org/doxygen/trunk/group__lsws.html#gaf360d1a9e0e60f906f74d7d44f9abfdd

Allocate and return an SwsContext.

You need it to perform scaling/conversion operations using sws_scale().

avpicture_fill:
http://ffmpeg.org/doxygen/trunk/group__lavc__picture.html#ga18a08bcb237767ef442fd5d3d1dd2084
Fill in the AVPicture fields, always assume a linesize alignment of 1.

接着上面的,首先是用 av_malloc 分配上面计算大小的内存空间,然后调用 avpicture_fill 将 pFrameRGB 跟 buffer 指向的内存关联起来。

获取图像

OK,一切准备好就可以开始从文件中读取视频帧并解码得到图像了。

120     // Read frames and save first five frames to disk
121     i=0;
122     while(av_read_frame(pFormatCtx, &packet)>=0) {
123         // Is this a packet from the video stream?
124         if(packet.stream_index==videoStream) {
125             // Decode video frame
126             avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,
127                     &packet);
128
129             // Did we get a video frame?
130             if(frameFinished) {
131                 // Convert the image from its native format to RGB
132                 sws_scale
133                     (
134                      sws_ctx,
135                      (uint8_t const * const *)pFrame->data,
136                      pFrame->linesize,
137                      0,
138                      pCodecCtx->height,
139                      pFrameRGB->data,
140                      pFrameRGB->linesize
141                     );
142
143                 // Save the frame to disk
144                 if(++i <= 20)
145                 {
146                     SaveFrame(pFrameRGB, pCodecCtx->width,
147                             pCodecCtx->height, i);
148                     if (20 == i)
149                         break;
150                 }
151             }
152         }
153
154         // Free the packet that was allocated by av_read_frame
155         av_free_packet(&packet);
156     }
157
158     // Free the RGB image
159     av_free(buffer);
160     av_free(pFrameRGB);
161
162     // Free the YUV frame
164
165     // Close the codec
166     avcodec_close(pCodecCtx);
167
168     // Close the video file
169     avformat_close_input(&pFormatCtx);
170
171     return 0;
172 }

av_read_frame:
http://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61

Return the next frame of a stream. 

This function returns what is stored in the file, and does not validate that what is there are valid frames for the decoder. It will split what is stored in the file into frames and return one for each call. It will not omit invalid data between valid frames so as to give the decoder the maximum information possible for decoding.


avcodec_decode_video2:

http://ffmpeg.org/doxygen/trunk/group__lavc__decoding.html#ga99ee61b6dcffb7817a275d39da58cc74

Decode the video frame of size avpkt->size from avpkt->data into picture. Some decoders may support multiple frames in a singleAVPacket, such decoders would then just decode the first frame.


sws_scale:
http://ffmpeg.org/doxygen/trunk/group__lsws.html#gae531c9754c9205d90ad6800015046d74

Scale the image slice in srcSlice and put the resulting scaled slice in the image in dst.

A slice is a sequence of consecutive rows in an image.

Slices have to be provided in sequential order, either in top-bottom or bottom-top order. If slices are provided in non-sequential order the behavior of the function is undefined.


avformat_close_input:
http://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4

Close an opened input AVFormatContext.

Free it and all its contents and set *s to NULL.


av_read_frame 从文件中读取一个packet,对于视频来说一个packet里面包含一帧图像数据,音频可能包含多个帧(当音频帧长度固定时),读到这一帧后,如果是视频帧,则使用avcodec_decode_video2 对packet中的帧进行解码,有时候解码器并不能从一个packet中解码得到一帧图像数据(比如在需要其他参考帧的情况下),因此会设置 frameFinished,如果已经得到下一帧图像则设置 frameFinished 非零,否则为零。所以这里我们判断 frameFinished 是否为零来确定 pFrame 中是否已经得到解码的图像。注意在每次处理完后需要调用av_free_packet 释放读取的packet。

解码得到图像后,很有可能不是我们想要的 RGB24 格式,因此需要使用 swscale 来做转换,调用 sws_getCachedContext 得到转换上下文,使用 sws_scale 将图形从解码后的格式转换为 RGB24,最后将前50帧写人 ppm 文件。最后释放图像以及关闭文件。



   8 void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
   9     FILE *pFile;
 10     char szFilename[32];
 11     int y;
 12
 13     // Open file
 14     sprintf(szFilename, "frame%d.ppm", iFrame);
 15     pFile=fopen(szFilename, "wb");
 16     if(pFile==NULL)
 17         return;
 18
 19     // Write header
 20     fprintf(pFile, "P6\n%d %d\n255\n", width, height);
 21
 22     // Write pixel data
 23     for(y=0; y<height; y++)
 24         fwrite(pFrame->data[0]+y*pFrame->linesize[0], 1, width*3, pFile);
 25
 26     // Close file
 27     fclose(pFile);
 28 }


    附注:

  接口网址:http://ffmpeg.org/doxygen/trunk/index.html

   数据结构接口:http://ffmpeg.org/doxygen/trunk/annotated.html


这个是http://my.oschina.net/u/555701/blog/56616?p=3#comments里的另一种接口。由于sws_getContext将被放弃,所以更推荐用下面的方法。具体参考前面链接。
sws_getCachedContext:
http://ffmpeg.org/doxygen/trunk/group__lsws.html#gadffa09f208a3eba7fa3a6b1f74ab77f7

Check if context can be reused, otherwise reallocate a new one.

If context is NULL, just calls sws_getContext() to get a new context. Otherwise, checks if the parameters are the ones already saved in context. If that is the case, returns the current context. Otherwise, frees context and gets a new context with the new parameters.

Be warned that srcFilter and dstFilter are not checked, they are assumed to remain the same.


总结:

av_register_all();//初始化ffmpeg库,如果系统里面的ffmpeg没配置好这里会出错 avformat_open_input(); avformat_find_stream_info();//查找文件的流信息 av_dump_format();//dump只是个调试函数,输出文件的音、视频流的基本信息了,帧率、分辨率、音频采样等等 for(...);//遍历文件的各个流,找到第一个视频流,并记录该流的编码信息 sws_getContext();//根据编码信息设置渲染格式 avcodec_find_decoder();//在库里面查找支持该格式的解码器 avcodec_open2();//打开解码器 pFrame=avcodec_alloc_frame();//分配一个帧指针,指向解码后的原始帧 pFrameRGB=avcodec_alloc_frame();//分配一个帧指针,指向存放转换成RGB后的帧 avpicture_fill(pFrameRGB);//给pFrameRGB帧加上分配的内存; while true{      av_read_frame();//读取一个帧(到最后帧则break)      avcodec_decode_video2();//解码该帧      sws_getCachedContext()sws_scale();//把该帧转换(渲染)成RGB      SaveFrame();//对前5帧保存成ppm图形文件(这个是自定义函数,非API)      av_free_packet();//释放本次读取的帧内存 }

  av_free(buffer);   av_free(pFrameRGB);   av_free(pFrame);   avcodec_close(pCodecCtx);   avformat_close_input(&pFormatCtx);

 libavcodec:CODEC其实是Coder/Decoder的缩写,也就是编码解码器;

libavdevice:对输出输入设备的支持;

libavformat:对音频视频格式的解析

libavutil:集项工具;

libpostproc:后期效果处理;

libswscale:视频场景比例缩放、色彩映射转换;




【ffmpeg-libav-tutorial】ffmpeg的hello world FFmpeg的hello world ffmpeg的hello world并不是打印hello world,而是打印视频的信息。比如他的容器格式、长度、分辨率、音频通道,最后我们将会解码一些帧并将他们保存为图片 ffmpeg的架构 首先先了解一下ffmpeg的架构以及他的组件如何与其他组件进行通信,如图是视频解码的过程: 首先,我们需要将视频文件加载到AVFormatContext结构体,实际上... 阅读详情

相关推荐

FFmpeg Tutorial.pdf

FFmpeg 教程,仅供参考

学习FFmpeg API

学习FFmpeg API – 解码视频 <!-- #favor_form {width:200px} #favor_form p {color:#666} #favor_form form {height:60px; width:200px} #favor_form form ._favor_input {display:block; margin:2px

hsp494980719的专栏 1万+

ffmpeg的tutorial中文版.pdf

用FFmpeg编写一个简单播放器

视频播放器播放flv报错Flv: Unsupported audio codec idx: 7

一、详细报错信息如下 [TransmuxingController] > DemuxException: type = CodecUnsupported, info = Flv: Unsupported audio codec idx: 7 Uncaught (in promise) Error: Unhandled error. (undefined) at EventEmitter.emit (events.js:135) at EventEmitter.eval (flv-pla

1万+

YOLOv11多模态融合实战:基于YOLOFuse的RGB与红外线(IR)协同检测技术解析

本文深入解析了YOLOv11多模态融合技术,重点介绍基于YOLOFuse框架的RGB与红外线(IR)协同检测方法。通过动态权重分配、跨模态特征对齐等创新设计,实现在低光照等复杂环境下的高精度目标检测,mAP提升高达37%。文章包含实战案例、训练技巧和部署方案,为计算机视觉开发者提供完整的多模态融合解决方案。

weixin_29038345的博客 304

映泰TB250-BTC主板魔改BIOS支持8/9代CPU实战与开机故障排查

BIOS(基本输入输出系统)是计算机硬件与操作系统之间的桥梁,负责初始化硬件和提供运行时服务。其工作原理是通过存储在主板芯片中的固件程序,在上电自检(POST)阶段完成对CPU、内存等关键组件的检测与配置。魔改BIOS的技术价值在于突破硬件限制,通过修改微码和电源管理模块,让旧平台支持新处理器,从而以极低成本实现性能跃升,在预算有限或追求极致性价比的DIY、办公和软路由等应用场景中极具吸引力。本文以映泰TB250-BTC矿板为例,详细解析了通过软刷方式刷入魔改BIOS,并重点解决了刷写后常见的“开机风扇转一

weixin_29164185的博客 437

flv.js播放报错

错误:DemuxException: type = CodecUnsupported, info = Flv: Unsupported audio codec idx: 7 flv.min.js:1 Uncaught (in promise) Error: Uncaught, unspecified “error” event. (MediaError) 分析:前端没有错误 原因:谷歌不是禁止视频,而是禁止音频,但是视频中包含了音频信息,所以得看播放流中是否含有对音频的操作 这里修改推流命令解决: 原来:

qq_41906696的博客 8012

细说STM32单片机SPI-Flash芯片的FatFS移植及其应用实例详解

本文以开发板上的SPI-Flash芯片W25Q16为媒介详细介绍CubeMX中FatFS各个参数的意义和设置,分析生成的代码中FatFS各个文件的作用和关联,完成针对W25Q16的硬件访问层的移植。继续使用旺宝红龙开发板STM32F407ZGT6 KITV1.0。

wenchm的博客 1661

DemuxException: type = CodecUnsupported, info = Flv: Unsupported codec in video frame: 2

在浏览器中拉流播放报错DemuxExceptiontype=CodecUnsupported,info=FlvUnsupportedcodecinvideoframe2。推流加上参数-vcodeclibx264,表示强制使用libx264进行编解码。

qq_23350817的博客 1万+

【华为2021校招】笔试题【通用硬件】

时间:2020/07/15 19:00 时长:60min 题型:40单选+5多选 难度:中等 考察范围:模电、数电、SI、EMC、电源、微机原理、计算机网络、材料

Jkcia的博客 4万+

2025机械考研复试面试问题汇总篇(含13门科目),考研机械复试专业面试常见重点问题总结!考研机械复试专业面试准备看这一篇就够了!

(完整版内容:)1.汇集了本科各科的重点知识及多个机械名校800多个常见问题,共8.7万字185页,涵盖机械所以专业课的重点知识和常见问答。 2.涉及机械大类重点科目,包括:材料力学、控制工程、数控技术、机械制造技术基础、理论力学、液压传动、机械设计、机械原理、工程材料、互换性与技术测量、测试技术、汽车理论、程序设计与C语言等13门必修课。

weixin_56510835的博客 1870

An ffmpeg and SDL Tutorial在ffmpeg-1.0.1上的更新,tutorial01

An ffmpeg and SDL Tutorial在ffmpeg-1.0.1上的更新 Tutorial01 http://cutebunny.blog.51cto.com/blog/301216/1121847 本篇是整个系列的基础,详细介绍了ffmpeg的整个工作流程,以及重要的数据结构。Sample code实现了将视频中的前5帧图像提取出来...

weixin_34390105的博客 138

【100%通过率】2023华为od机试C卷【电脑病毒感染】C++ 实现

一个局域网内有很多台电脑,分别标注为 0 ~ N-1 的数字。相连接的电脑距离不一样,所以感染时间不一样,感染时间用t 表示。其中网络内一台电脑被病毒感染,求其感染网络内所有的电脑最少需要多长时间。如果最后有电脑不会感染,则返回-1.

MISAYAONE的博客 1736

【ffmpeg学习记录】解决ffmpeg-tutorial的噪声问题

在ffmpeg 2.5.1版本下编译ffmpeg-tutorial,发现所有与音频相关的tutorial都有噪声,而ffplay却能完美播放。问度娘谷歌无果,只好看ffplay的代码。 在ffplay.c中,有三个与audio有关的重要函数,分别是read_thread、decoder_decode_frame、audio_decode_frame。read_thread负责从文件或流中读取数据

sgwhp的专栏 4412

Untiy之如何实现AI+MR (Pico4u 相机推流MR画面给Server做实时AI图像识别)

本文介绍了基于Pico4U企业版开发AI+MR应用的实现方案。文章详细说明了硬件准备步骤,包括购买企业版设备、申请相机权限和注册管理平台。重点讲解了Unity开发中获取摄像头画面的两种技术方案:通过Overlay直接渲染到Android Surface,或使用API获取图像数据转换为Texture。提供了完整的代码示例和权限配置说明,并揭示了底层通过JNI调用Android原生API的技术原理。该方案适用于带电操作等实习场景,可提升安全性和学习趣味性。

TxNet 1372

深度学习100例-卷积神经网络(CNN)彩色图片分类 | 第2天

文章目录前期工作设置GPU导入数据标准化可视化构建CNN网络编译训练模型预测模型评估 前期工作 设置GPU 如果使用的是CPU可以忽略这步 import tensorflow as tf gpus = tf.config.list_physical_devices("GPU") if gpus: gpu0 = gpus[0] #如果有多个GPU,仅使用第0个GPU tf.config.experimental.set_memory_growth(gpu0, True) #设置GPU显存用量

“365天深度学习训练营”报名进行中~ 7864

ffmpeg的tutorial中文版学习笔记(三)

fmpeg 教程3:播放声音           现在我们要来播放声音。SDL 也为我们准备了输出声音的方法。函数SDL_OpenAudio()本身就是用来打开声音设备的。它使用一个叫做SDL_AudioSpec 结构体作为参数,这个结构体中包含了我们将要输出的音频的所有信息。           在我们展示如何建立之前,让我们先解释一下电脑是如何处理音频的。数字音频是由一长串的样本流组成的。

坤哥的学习笔记 1708

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

FFmpeg Tutorial

本文转载自Github上面殷汶杰-yinwenjie的一个项目FFmpeg_Tutorial FFmpeg TutorialFFmpeg_Tutorial一、使用FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑1、基本介绍2、FFmpeg组成3、FFMpeg工具的下载和使用(1)FFmpeg工具的下载:(2)ffplay.exe的使用(3)ffprobe的使用(4)ffmpeg的使用二、调用FFmpeg SDK对YUV视频序列进行编码1、FFMpeg进行视频编码所需要的结构:2、FFMpeg编码的

ccf19881030的专栏 655

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

FFmpeg-Tutorial-CN: 掌握多媒体处理的利器

FFmpeg-Tutorial-CN: 掌握多媒体处理的利器 则是一个精心编译的中文教程集合,旨在帮助中国开发者更好地理解和使用 FFmpeg。 项目简介 FFmpeg-Tutorial-CN 是 Huwan 在 GitCode 上发布的一个开源项目,它提供了 FFmpeg 的详细教程和实战案例,覆盖了从基础概念到高级应用的各种场景。这个项目不仅有丰富的文字说明,还包含了许多实例代码,对于初学者和...

gitblog_00096的博客 600

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

ffmpeg学习(2)--An ffmpeg and SDL Tutorial

ffmpeg学习(2)--An ffmpeg and SDL Tutorial 安装好ffmpeg后,就开始学习如何应用了,主要也就是熟悉一些常用API。 同事推荐了一个ffmpeg的自学教程--An ffmpeg and SDL Tutorial,觉得不错,就开始照敲代码了。这个教程的网址为:http://dranger.com/ffmpeg/tutorial01.html 学习过程中

gavin的专栏 5013

FFmpeg_Tutorial

FFmpeg工具和sdk库的使用demo--https://github.com/yinwenjie/FFmpeg_Tutorial 一、使用FFmpeg命令行工具和批处理脚本进行简单的音视频文件编辑 1、基本介绍 对于每一个从事音视频技术开发的工程师,想必没有一个人对FFmpeg这个名称感到陌生。FFmpeg是一套非常知名的音视频处理的开源工具,它包含了开发完成的工具软件、封装好的函数库以...

508

ffmpeg tutorial

第一部分:制作屏幕录像

xutom2006的专栏 1193

ffmpeg tutorial1

## An ffmpeg and SDL Tutorial Page 1 2 3 4 5 6 7 End Prev Home Next &nbsp_place_holder; Text version ## Tutorial 01: Making Screencaps Code: tutorial01.c ### Overview Movie files have a few basi

烟台 嵌入式产品开发 703

VS2008+ffmpeg SDK3.2调试tutorial01

VS2008+ffmpeg SDK3.2调试tutorial01 分类: FFmpeg 2012-02-22 11:07 2749人阅读 评论(9) 收藏 举报 codecstreamvideobufferfilenull 最近研究ffmpeg,在ubuntu下感觉不太好调试,老是找不到函数的声明。所以我就把他移到windows下用vs2008分析 关于环境的

心之所向,身之所往 1084

FFmpeg入门(3)-An ffmpeg and SDL Tutorial

ffmpeg学习(2)--An ffmpeg and SDL Tutorial 安装好ffmpeg后,就开始学习如何应用了,主要也就是熟悉一些常用API。 同事推荐了一个ffmpeg的自学教程--An ffmpeg and SDL Tutorial,觉得不错,就开始照敲代码了。这个教程的网址为:http://dranger.com/ffmpeg/tutorial01.html 学习过

s170262941的专栏 1568

ffmpeg_tutorial 学习过程

测试ffmpeg_tutorial 这个测试系列的代码是一个外国人写的,大概有七八篇,有代码,也有相关的说明。 1)tutorial01  这第一个测试读取一个文件,并且解码,然后把解码的数据保存成rgb格式的文件。 文件名是PPM(这个需要专门的文件打开) 写文件的时候,一开始需要写入P6,以及宽高,以及一个特殊标记255 调试代码的过程中,第一个函数 avforma

为了理想而奋斗 1709
上一篇: windows 安装程序不允许安装从远程桌面连接
下一篇: ffmpeg tutorial2 解析
wdxz6547
博客等级 码龄16年 5粉丝 21原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值