Last edited one year ago

How to encode a video stream with the hardware video encoder



When using complex GStreamer bins such as encodebin or encodebin2, hardware acceleration is abstracted to the user and automatically selected to achieve the best level of performances.

Here is an example with a local encoding of a 10 s video test pattern in VP8:

 gst-launch-1.0 videotestsrc num-buffers=300 ! video/x-raw, width=640, height=480, framerate=30/1 ! encodebin profile="video/x-vp8" ! matroskamux ! filesink location=v_vp8_640x480_30fps.webm
[...]
Got EOS from element "pipeline0".
Execution ended after 0:00:01.229040368
[...]

Play back the file to check the encoded content:

 gst-play-1.0 v_vp8_640x480_30fps.webm
[...]
0:00:10.0 / 0:00:10.0     
Reached end of play list.

Here is another example with a local encoding of a 10 s video test pattern in H264:

 gst-launch-1.0 videotestsrc num-buffers=300 ! video/x-raw, width=640, height=480, framerate=30/1 ! encodebin profile="video/x-h264" ! qtmux ! filesink location=v_h264_640x480_30fps.mp4
[...]
Got EOS from element "pipeline0".
Execution ended after 0:00:01.125719575
[...]

Play back the file to check the encoded content:

 gst-play-1.0 v_h264_640x480_30fps.mp4
[...]
0:00:10.0 / 0:00:10.0     
Reached end of play list.