Ticket #41241: patch-fix-ffmpeg-support.2.diff

File patch-fix-ffmpeg-support.2.diff, 3.8 KB (added by andreas.schuh.84@…, 6 years ago)

Fix FFMPEG API calls, requires FFMPEG >= lavf 53.25.0 / 53.17.0

  • core/vidl/vidl_ffmpeg_istream_v3.txx

    diff --git a/core/vidl/vidl_ffmpeg_istream_v3.txx b/core/vidl/vidl_ffmpeg_istream_v3.txx
    index 73ab11f..019d652 100644
    open(const vcl_string& filename) 
    143143  }
    144144
    145145  // Get the stream information by reading a bit of the file
    146   if ( av_find_stream_info( is_->fmt_cxt_ ) < 0 ) {
     146  if ( avformat_find_stream_info( is_->fmt_cxt_, NULL ) < 0 ) {
    147147    return false;
    148148  }
    149149
    open(const vcl_string& filename) 
    165165
    166166  // Open the stream
    167167  AVCodec* codec = avcodec_find_decoder(enc->codec_id);
    168   if ( !codec || avcodec_open( enc, codec ) < 0 ) {
     168  if ( !codec || avcodec_open2( enc, codec, 0 ) < 0 ) {
    169169    return false;
    170170  }
    171171
    close() 
    216216    is_->vid_str_ = 0;
    217217  }
    218218  if ( is_->fmt_cxt_ ) {
    219     av_close_input_file( is_->fmt_cxt_ );
     219    avformat_close_input( &is_->fmt_cxt_ );
    220220    is_->fmt_cxt_ = 0;
    221221  }
    222222}
  • core/vidl/vidl_ffmpeg_ostream_v4.txx

    diff --git a/core/vidl/vidl_ffmpeg_ostream_v4.txx b/core/vidl/vidl_ffmpeg_ostream_v4.txx
    index 2eca21d..b74baf4 100644
    open() 
    117117  os_->fmt_cxt_->nb_streams = 0;
    118118
    119119  // Create stream
    120   AVStream* st = av_new_stream( os_->fmt_cxt_, 0 );
     120  AVStream* st = avformat_new_stream( os_->fmt_cxt_, NULL );
    121121  if ( !st ) {
    122122    vcl_cerr << "ffmpeg: could not alloc stream\n";
    123123    close();
    open() 
    229229  if (params_.video_qscale_ || params_.same_quality_)
    230230  {
    231231    video_enc->flags |= CODEC_FLAG_QSCALE;
    232     st->quality = FF_QP2LAMBDA * params_.video_qscale_;
     232    //st->quality = FF_QP2LAMBDA * params_.video_qscale_;
    233233  }
    234234  // if (bitexact)
    235235  //   video_enc->flags |= CODEC_FLAG_BITEXACT;
    open() 
    246246  video_enc->spatial_cplx_masking = params_.scplx_mask_;
    247247  video_enc->temporal_cplx_masking = params_.tcplx_mask_;
    248248  video_enc->p_masking = params_.p_mask_;
    249   video_enc->quantizer_noise_shaping= params_.qns_;
     249  //video_enc->quantizer_noise_shaping= params_.qns_;
    250250
    251   if (params_.use_umv_)
     251  // Commented below are deprecated flags https://www.ffmpeg.org/doxygen/0.10/group__deprecated__flags.html
     252  /*if (params_.use_umv_)
    252253  {
    253254    video_enc->flags |= CODEC_FLAG_H263P_UMV;
    254255  }
    open() 
    259260  if (params_.use_aiv_)
    260261  {
    261262    video_enc->flags |= CODEC_FLAG_H263P_AIV;
    262   }
     263  }*/
    263264  if (params_.use_4mv_)
    264265  {
    265266    video_enc->flags |= CODEC_FLAG_4MV;
    266267  }
    267   if (params_.use_obmc_)
     268  /*if (params_.use_obmc_)
    268269  {
    269270    video_enc->flags |= CODEC_FLAG_OBMC;
    270   }
     271  }*/
    271272  if (params_.use_loop_)
    272273  {
    273274    video_enc->flags |= CODEC_FLAG_LOOP_FILTER;
    274275  }
    275276
    276   if (params_.use_part_)
     277  /*if (params_.use_part_)
    277278  {
    278279    video_enc->flags |= CODEC_FLAG_PART;
    279280  }
    open() 
    284285  if (params_.use_scan_offset_)
    285286  {
    286287    video_enc->flags |= CODEC_FLAG_SVCD_SCAN_OFFSET;
    287   }
     288  }*/
    288289  if (params_.closed_gop_)
    289290  {
    290291    video_enc->flags |= CODEC_FLAG_CLOSED_GOP;
    open() 
    293294  {
    294295    video_enc->flags |= CODEC_FLAG_QPEL;
    295296  }
    296   if (params_.use_qprd_)
     297  /*if (params_.use_qprd_)
    297298  {
    298299    video_enc->flags |= CODEC_FLAG_QP_RD;
    299300  }
    300301  if (params_.use_cbprd_)
    301302  {
    302303    video_enc->flags |= CODEC_FLAG_CBP_RD;
    303   }
     304  }*/
    304305  if (params_.b_frames_)
    305306  {
    306307    video_enc->max_b_frames = params_.b_frames_;
    open() 
    377378
    378379  vcl_strncpy( os_->fmt_cxt_->filename, filename_.c_str(), 1023 );
    379380
    380   if ( avio_open( &os_->fmt_cxt_->pb, filename_.c_str(), URL_WRONLY) < 0 )
     381  if ( avio_open( &os_->fmt_cxt_->pb, filename_.c_str(), AVIO_FLAG_WRITE) < 0 )
    381382  {
    382383    vcl_cerr << "ffmpeg: couldn't open " << filename_ << " for writing\n";
    383384    close();
    open() 
    387388
    388389  //dump_format( os_->fmt_cxt_, 1, filename_, 1 );
    389390
    390   if ( avcodec_open( video_enc, codec ) < 0 )
     391  if ( avcodec_open2( video_enc, codec, 0 ) < 0 )
    391392  {
    392393    vcl_cerr << "ffmpeg: couldn't open codec\n";
    393394    close();