当前位置: 首页 > news >正文

网站开发工程师学什么语言seo伪原创工具

网站开发工程师学什么语言,seo伪原创工具,广西建设职业技术学院,聊城做网站推广公司FFmpeg是一个开源的音视频处理库,提供了丰富的API用于音视频的编解码、转码、过滤、播放等操作。 一、使用FFmpeg API解码涉及到的函数及一般流程如下: 1. av_register_all(): 注册所有的编解码器和格式。 av_register_all(); 2. avformat_open_inpu…

FFmpeg是一个开源的音视频处理库,提供了丰富的API用于音视频的编解码、转码、过滤、播放等操作。

一、使用FFmpeg API解码涉及到的函数及一般流程如下:

1. av_register_all(): 注册所有的编解码器和格式。

av_register_all();

2. avformat_open_input(): 打开输入文件(流)并获取文件(流)的格式信息。

AVFormatContext *fmt_ctx = NULL;
if (avformat_open_input(&fmt_ctx, input_file, NULL, NULL) < 0) {// 打开文件失败
}

3. avformat_find_stream_info(): 获取流的详细信息。
 

if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {// 获取流信息失败
}

4. avcodec_find_decoder(): 查找解码器。
 

AVCodec *codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (!codec) {// 找不到解码器
}

5. avcodec_open2(): 打开解码器。
 

AVCodecContext *codec_ctx = avcodec_alloc_context3(codec);
if (avcodec_open2(codec_ctx, codec, NULL) < 0) {// 打开解码器失败
}

6. av_read_frame(): 读取一帧音视频数据。
 

AVPacket packet;
while (av_read_frame(fmt_ctx, &packet) >= 0) {// 处理音视频数据av_packet_unref(&packet);
}

7. avcodec_send_packet()和avcodec_receive_frame(): 解码音视频数据。
 

AVFrame *frame = av_frame_alloc();
while (av_read_frame(fmt_ctx, &packet) >= 0) {if (packet.stream_index == audio_stream_index) {// 解码音频数据avcodec_send_packet(codec_ctx, &packet);while (avcodec_receive_frame(codec_ctx, frame) >= 0) {// 处理解码后的音频帧}} else if (packet.stream_index == video_stream_index) {// 解码视频数据avcodec_send_packet(codec_ctx, &packet);while (avcodec_receive_frame(codec_ctx, frame) >= 0) {// 处理解码后的视频帧}}av_packet_unref(&packet);
}

二、与解码类似,编码的流程一般为:

8. avformat_alloc_output_context2(): 创建输出格式上下文。
 

AVFormatContext *out_fmt_ctx = NULL;
if (avformat_alloc_output_context2(&out_fmt_ctx, NULL, NULL, output_file) < 0) {// 创建输出格式上下文失败
}

9. avcodec_find_encoder(): 查找编码器。
 

AVCodec *encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
if (!encoder) {// 找不到编码器
}

10. avcodec_open2(): 打开编码器。
 

AVCodecContext *encoder_ctx = avcodec_alloc_context3(encoder);
if (avcodec_open2(encoder_ctx, encoder, NULL) < 0) {// 打开编码器失败
}

11. avformat_write_header(): 写入输出文件的头部信息。
 

if (avformat_write_header(out_fmt_ctx, NULL) < 0) {// 写入头部信息失败
}

12. avcodec_send_frame()和avcodec_receive_packet(): 编码音视频数据。
 

AVPacket encoded_packet;
while (av_read_frame(fmt_ctx, &packet) >= 0) {if (packet.stream_index == audio_stream_index) {// 编码音频数据avcodec_send_frame(encoder_ctx, frame);while (avcodec_receive_packet(encoder_ctx, &encoded_packet) >= 0) {// 处理编码后的音频数据}} else if (packet.stream_index == video_stream_index) {// 编码视频数据avcodec_send_frame(encoder_ctx, frame);while (avcodec_receive_packet(encoder_ctx, &encoded_packet) >= 0) {// 处理编码后的视频数据}}av_packet_unref(&packet);
}

13. av_write_frame()和av_write_trailer(): 写入编码后的音视频数据。
 

if (av_write_frame(out_fmt_ctx, &encoded_packet) < 0) {// 写入音视频数据失败
}

三、解码和编码结束后都要及时释放内存:

14. avformat_close_input(): 关闭输入文件。
 

avformat_close_input(&fmt_ctx);

15. avcodec_free_context(): 释放编解码器上下文。
 

avcodec_free_context(&codec_ctx);

16. av_frame_free(): 释放帧对象。
 

av_frame_free(&frame);

17. avformat_free_context(): 释放格式上下文。
 

avformat_free_context(fmt_ctx);

了解这些常用API及流程对使用FFmpeg开发将大有裨益。

http://www.yidumall.com/news/58892.html

相关文章:

  • w网站建设广州网站推广服务
  • 宁波新亚建设内部网站怎么线上推广自己的产品
  • 与小学生一起做网站营销和销售的区别
  • 深圳做网站(官网)关键词查网站
  • 酒店网站开发协议包括哪些内容
  • 建设网站费用多少钱免费网站免费
  • 深圳网站建设延安网店推广运营
  • WordPress考勤模板seo在哪可以学
  • css网站开发教程视频老鬼seo
  • 修改网站版权安卓系统最好优化软件
  • 兰州网站优化公司搜索优化指的是什么
  • win10建站wordpress互联网搜索引擎
  • 免费b2b网站大全在线搜索关键词的方法
  • 网站常用的蓝色灰色词快速排名接单
  • 扁平化个人网站女教师遭网课入侵直播
  • 用sublime text做网站看片应该搜什么关键词哪些词
  • 网站开发外贸变现流量推广app
  • 深圳东门有什么好玩的青岛seo推广公司
  • 网站打开慢的原因营销型网站有哪些平台
  • 团购做的比较好的网站seo关键词优化是什么意思
  • 找潍坊做网站的事件营销的案例有哪些
  • 行业网站做的好的优化seo哪家好
  • 网站设计如何收费百度推广关键词排名规则
  • 柳州做网站制作的公司有哪些百度游戏
  • 大型网站建设推广引流渠道平台
  • 淄博专业网站建设公司爱站关键词挖掘工具
  • 古典网站建设磁力狗在线引擎
  • 重庆网站建设优化qq空间刷赞网站推广
  • 成都动力无限科技有限公司做网站故事式的软文广告例子
  • 经营性网站怎么备案微信引流主动被加软件