Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. AVCodec* vcodec = avcodec_find_encoder_by_name("h264_nvenc");
  2. AVStream* vstrm = avformat_new_stream(outctx, vcodec);
  3. if (!vstrm) {
  4. std::cerr << "fail to avformat_new_stream";
  5. fclose(time_fp);
  6. return 2;
  7. }
  8.  
  9. avcodec_get_context_defaults3(vstrm->codec, vcodec);
  10. vstrm->codec->width = dst_width;
  11. vstrm->codec->height = dst_height;
  12. vstrm->codec->pix_fmt = vcodec->pix_fmts[0];
  13. vstrm->codec->time_base = vstrm->time_base = av_inv_q(dst_fps);
  14. vstrm->r_frame_rate = vstrm->avg_frame_rate = dst_fps;
  15. if (outctx->oformat->flags & AVFMT_GLOBALHEADER)
  16. vstrm->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  17.  
  18. // open video encoder
  19. ret = avcodec_open2(vstrm->codec, vcodec, nullptr);
  20. if (ret < 0) {
  21. std::cerr << "fail to avcodec_open2: ret=" << ret;
  22. fclose(time_fp);
  23. return 2;
  24. }
  25.  
  26. std::cout << "outfile: " << file_name.c_str() << "\n"
  27. << "format: " << outctx->oformat->name << "\n"
  28. << "vcodec: " << vcodec->name << "\n"
  29. << "size: " << dst_width << 'x' << dst_height << "\n"
  30. << "fps: " << av_q2d(dst_fps) << "\n"
  31. << "pixfmt: " << av_get_pix_fmt_name(vstrm->codec->pix_fmt) << "\n"
  32. << std::flush;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement