I used libx264 in ffmpeg to encode video, I used the configuration below.
enCodecContext->bit_rate = 300000;
enCodecContext->width = 80;
enCodecContext->height = 60;
enCodecContext->time_base = (AVRational) {1, 25};
enCodecContext->gop_size = 10;
enCodecContext->max_b_frames = 1;
enCodecContext->pix_fmt = PIX_FMT_YUV420P;
enCodecContext->qcompress = 0.6;
av_opt_set(enCodecContext->priv_data, "preset", "slow", 0);
But when I called avcodec_encode_video2 with enCodecContext, I got the error Input picture width (40) is greater than stride (0).
avcodec_encode_video2(enCodecContext, &filteredAVPacket, pFilteredAVFrame, &got_packet_ptr);
The pFilteredAVFrame->width and pFilteredAVFrame->height is 80 and 60 respectively.
Did I missed something when configured libx264, How can I get a workable configuration for libx264 to encode my video?
x264 is fine. You must fill in the AVPicture.linestride variable for your image planes. The stride describes how the image is laid out in memory. The stride must be at least as big as the image width. In the case of YUV 4:2:0, the stride must be at least half the width on the second and third plane.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa473780(v=vs.85).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With