[gst-devel] how to encode yuv files using h.264 encoder?

Tim-Philipp Müller t.i.m at zen.co.uk
Sat Oct 23 16:21:14 CEST 2010


On Fri, 2010-10-22 at 23:25 +0300, Marco Ballesio wrote:

> I suggest you to use, if possible, a container format to wrap
> your yuv frames with,

e.g. .y4m files (yuv4mpeg).

> ... when dealing with raw data, you need to give it some context,
> usually through a parser element. In case of uncompressed video, you
> don't even need that, but just some basilar algebra..
>
> Basically, once you know the source resolution, you should compute the
> frame size with something like w x h x bpp (3/2 for yuv420, 2 for
> yuv422 and similar), then use caps of the like of the following
> between source and encoder:
>
> "video/x-raw-yuv, width=w, height=h, framerate=(fraction)n/d"
>
> d and n are denomiator and numerator for the target frame rate (e.g.
> 1/30). And don't forget to set the buffer-size of your filesrc to the
> value you computed above for the frame size ;)!

An easier solution, because you don't need to calculate the size in
bytes yourself, is to use the videoparse element, like this for example:

gst-launch-0.10 filesrc location=foreman_cif.yuv ! videoparse width=352
height=288 format=i420 framerate=25/1 ! ffmpegcolorspace ! ximagesink

(xvimagesink would be even better, but may not always work)

Cheers
 -Tim







More information about the gstreamer-devel mailing list