Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AVCodec* vcodec = avcodec_find_encoder_by_name("h264_nvenc");
- AVStream* vstrm = avformat_new_stream(outctx, vcodec);
- if (!vstrm) {
- std::cerr << "fail to avformat_new_stream";
- fclose(time_fp);
- return 2;
- }
- avcodec_get_context_defaults3(vstrm->codec, vcodec);
- vstrm->codec->width = dst_width;
- vstrm->codec->height = dst_height;
- vstrm->codec->pix_fmt = vcodec->pix_fmts[0];
- vstrm->codec->time_base = vstrm->time_base = av_inv_q(dst_fps);
- vstrm->r_frame_rate = vstrm->avg_frame_rate = dst_fps;
- if (outctx->oformat->flags & AVFMT_GLOBALHEADER)
- vstrm->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
- // open video encoder
- ret = avcodec_open2(vstrm->codec, vcodec, nullptr);
- if (ret < 0) {
- std::cerr << "fail to avcodec_open2: ret=" << ret;
- fclose(time_fp);
- return 2;
- }
- std::cout << "outfile: " << file_name.c_str() << "\n"
- << "format: " << outctx->oformat->name << "\n"
- << "vcodec: " << vcodec->name << "\n"
- << "size: " << dst_width << 'x' << dst_height << "\n"
- << "fps: " << av_q2d(dst_fps) << "\n"
- << "pixfmt: " << av_get_pix_fmt_name(vstrm->codec->pix_fmt) << "\n"
- << std::flush;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement