[Libav-user] Encoding H263+ video

Alex Cohn alexcohn at netvision.net.il
Sun Jan 13 14:44:15 CET 2013

On Thu, Jan 10, 2013 at 11:49 PM, David Longest
<david.longest at apx-labs.com> wrote:
> Hello!
> I am attempting to encode raw video from a camera to H263+ using the
> “decoding_encoding.c” file as an example. My code requires one more step
> since the camera provides an image in the NV21 format.
> While the conversion seems to work fine, I seem to get a crash (sigsegv)
> when encoding the output from the conversion. After investigating a bit, I
> have found that I will sometimes get a message stating “Provided packet is
> too small, needs to be ****” before it crashes. I tried allocating the
> AVPacket’s data myself and it seems to stop crashing, but I get macro block
> corruption in the video I try to play back.
> From looking at the example, it seems that libavcodec should be allocating
> the packet’s data depending on how much memory it needs. Does anybody know
> why it would crash if I don’t allocate memory for it?
> Thanks,
> David

Note that in terms of allocations and encoder logic, you can use nv21
input instead of yuv420p. The resulting video will be crap, but the
encoder should not crash/fail, and you can expect to receive a movie
file as output. You can even extract nv21 frames from this movie:

    ffmpeg -i video.h263v2 -pix_fmt yuv420p -vframes 1 foo-1.yuv

You can even use ffplay to see the resulting frame:

    ffplay -pixel_format nv21 -video_size WxH foo-1.yuv

So, please check if your problem is reproduced without the "extra
step" of nv21 to yuv420p conversion.



More information about the Libav-user mailing list