ffmpeg – An error occurred after encoding with h264_nvenc
1373×768 yuv420p picture
- The ffmpeg api(avcodec_send_frame, avcodec_receive_packet) will write the avpacket-data data to the file after the encoding is successful, and then decode t using ffmpeg command line, save AvPacket::data, the resulting picture is not normal
- Directly use ffmpeg command line encoding, and then decode, the resulting picture is normal
decodec command: ffmpeg -i out.h264 -ss 0 -frames:v 1 output_frame.png
ecodec command: ffmpeg -s:v 1376×768 -pix_fmt yuv420p -i input.yuv -c:v h264_nvenc out.h264
exception picture:
enter image description here
Encoder Settings for api calls:
_encodecH264 = avcodec_find_encoder_by_name("h264_nvenc");
_encodecContext = avcodec_alloc_context3(_encodecH264);
_encodecContext->codec_type = AVMEDIA_TYPE_VIDEO;
_encodecContext->time_base.num = 1;
_encodecContext->time_base.den = 25;
_encodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
_encodecContext->width = w;
_encodecContext->height = h;
_encodecContext->gop_size = 25;
av_opt_set(_encodecContext->priv_data, "tune", "zerolatency", 0);
av_opt_set(_encodecContext->priv_data, "profile", "main", 0);
Would like to ask why the api call encoding operation result is abnormal?
The first scheme uses the normal 1920×1080 picture
Read more here: Source link
