ffmpeg hevc (x265) encoding
ffmpeg hevc (x265) encoding
我正在尝试在 FFMPEG 库中使用 H265 编码器,但给我这个错误:
Cannot open libx265 encoder.
这是我的代码:
formatContext = avformat_alloc_context();
videoStream = avformat_new_stream(formatContext,0);
if(!videoStream ) {
//error
return;
}
av_init_packet(&packet);
codecContext=videoStream->codec;
codecContext->codec_type = AVMEDIA_TYPE_VIDEO;
codecContext->width = width;
codecContext->height = height;
codecContext->time_base.den = fps;
codecContext->time_base.num = 1;
codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
codecContext->codec_id = AV_CODEC_ID_HEVC;
AVDictionary *param = 0;
av_dict_set(¶m, "x265-params", "qp=20", 0);
av_dict_set(¶m, "preset", "ultrafast", 0);
av_dict_set(¶m, "tune", "zero-latency", 0);
av_dict_set(¶m, "qmin", "0", 0);
av_dict_set(¶m, "qmax", "69", 0);
av_dict_set(¶m, "qdiff", "4", 0);
codec = avcodec_find_encoder(codecContext->codec_id);
if (!codec) {
//codec not found
return;
}
int rt = avcodec_open2(codecContext, codec, ¶m); // <----- fails here
if (rt < 0) {
// fails here!!
return;
}
此代码适用于 h264 编码器,有人知道为什么不适用于 hevc?
如果您设置
codecContext->sample_aspect_ratio.num = 4;
codecContext->sample_aspect_ratio.den = 3;
HEVC 编码器可以工作,但输出上没有视频。
嗨,你有没有打开编码器libx265
?我遇到了同样的麻烦,并尝试使用AV_CODEC_ID_H265
。我以前遇到过同样的麻烦libx264
但我通过设置解决了它:
av_dict_set(¶m, "profile", "high", 0);
编解码器配置中似乎缺少某些内容。
相关文章:
- 为什么编解码器X264/X265忽略了输入框架的PT和DTS
- OpenCV encoding to H264
- C++ equivalent to C# Encoding.ASCII.GetBytes()
- C++ UTF8 Encoding
- ffmpeg hevc (x265) encoding
- QNetworkRequest and QUrl encoding c++
- x265编码器,将YUV转换为x265_picture
- vsnprintf 文档中"encoding error"的含义是什么?
- OpenCV cv::Mat to std::ifstream for base64 encoding
- wchar_t and encoding
- Shannon-Fano encoding
- locale和Encoding (Terminal)之间的区别是什么?
- 本机c++中的备用方法Encoding.Unicode.GetBytes
- .NET Encoding.Default alternative in wxWIdgets?
- "Content-Length"或"chunked transfer-encoding"是 Http 请求的必备条件吗?
- Base 64 Encoding丢失数据