Log in

View Full Version : FFmpeg error while encoding raw video into H.264


serhannn
19th October 2015, 15:29
I use the following FFmpeg command to encode the well-known Akiyo (https://media.xiph.org/video/derf/) sequence from raw `y4m` format with H.264:

ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 352x288 -r 30 -i akiyo_cif.y4m -c:v libx264 akiyo_cif.mp4

However, the encoded video I get is distorted, i.e. there is horizontal panning/sliding of frames and the colors are not accurate. FFmpeg yields the following error:

[rawvideo @ 0x7f5e7c57b140] Invalid buffer size, packet size 1844 < expected frame_size 152064
Error while decoding stream #0:0: Invalid argument

I don't understand the error. I provided the CIF resolution (352x288) and frame rate (30 fps) as input, so there shouldn't be anything wrong with those. What could be the source of this problem?

vivan
19th October 2015, 17:18
rawvideoy4m is not raw video - it has headers. You should just omit everything, ffmpeg -i akiyo_cif.y4m -c:v libx264 akiyo_cif.mp4

serhannn
20th October 2015, 08:15
This solved my problem. I didn't know that y4m was not raw video. Thank you!