FFmpeg 'avcodec_copy_context' deprecated (视频裁剪)

在学习一些代码的时候发现有些已经弃用了:记录一下新的写法:1,avcodec_copy_context以前的写法:ret = avcodec_copy_context(outStream->codec, inStream->codec); if (ret < 0) { fprintf(stderr, "Failed to copy contex...
摘要由CSDN通过智能技术生成

在学习一些代码的时候发现有些已经弃用了:记录一下新的写法:


1,avcodec_copy_context
以前的写法:

ret = avcodec_copy_context(outStream->codec, inStream->codec);
    if (ret < 0)
    {
      fprintf(stderr, "Failed to copy context from input to output stream codec context\n");
      goto end;
    }
    outStream->codec->codec_tag = 0;
    if (outFmtCtx->oformat->flags & AVFMT_GLOBALHEADER)
    {
      outStream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
    }

新的写法:(来自雷霄骅:https://blog.csdn.net/leixiaohua1020/article/details/25422685)

   AVCodecContext *codecCtx = avcodec_alloc_context3(codec);
    ret = avcodec_parameters_to_context(codecCtx, inStream->codecpar);
    if (ret < 0)
    {
      printf("Failed to copy in_stream codecpar to codec context\n");
      goto end;
    }
    codecCtx->codec_tag = 0;
    if (outFmtCtx->oformat->flags & AVFMT_GLOBALHEADER)
    {
      codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
    }
    ret = avcodec_parameters_from_context(outStream->codecpar, codecCtx);
    if (ret < 0)
    {
      printf("Failed to copy codec context to out_stream codecpar context\n");
      goto end;
    }

2,av_free_packet(&pkt)
新的写法:

av_packet_unref(&pkt);

视频裁剪

#include <stdio.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>

int cut
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值