Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1.     ost->st = avformat_new_stream(oc, audio.getCodec());
  2.     if (!ost->st) throw std::runtime_error("Could not allocate stream");
  3.  
  4.     ost->st->id = oc->nb_streams - 1;
  5.  
  6.     ost->st->time_base = (AVRational){ 1, audio.getSampleRate() };
  7.     ost->st->codec->sample_rate = audio.getSampleRate();
  8.     ost->st->codec->time_base = ost->st->time_base;
  9.  
  10.     // Some formats want stream headers to be separate.
  11.     if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
  12.         ost->st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  13.     }
  14.  
  15.     AVCodecParameters *in_codecpar = audio.getCodecParameters();
  16.     int ret = avcodec_parameters_copy(ost->st->codecpar, in_codecpar);
  17.     if (ret < 0) {
  18.         throw std::runtime_error("Could not copy the stream parameters");
  19.     }
  20.  
  21.     ost->st->codecpar->codec_tag = 0;
  22.  
  23.     AVCodecContext *in_ctx = audio.getCodecContext();
  24.     ret = avcodec_copy_context(ost->st->codec, in_ctx);
  25.     if (ret < 0) {
  26.         throw std::runtime_error("Could not copy the codec context");
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement