Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ost->st = avformat_new_stream(oc, audio.getCodec());
- if (!ost->st) throw std::runtime_error("Could not allocate stream");
- ost->st->id = oc->nb_streams - 1;
- ost->st->time_base = (AVRational){ 1, audio.getSampleRate() };
- ost->st->codec->sample_rate = audio.getSampleRate();
- ost->st->codec->time_base = ost->st->time_base;
- // Some formats want stream headers to be separate.
- if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
- ost->st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
- }
- AVCodecParameters *in_codecpar = audio.getCodecParameters();
- int ret = avcodec_parameters_copy(ost->st->codecpar, in_codecpar);
- if (ret < 0) {
- throw std::runtime_error("Could not copy the stream parameters");
- }
- ost->st->codecpar->codec_tag = 0;
- AVCodecContext *in_ctx = audio.getCodecContext();
- ret = avcodec_copy_context(ost->st->codec, in_ctx);
- if (ret < 0) {
- throw std::runtime_error("Could not copy the codec context");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement