Difference between revisions of "Mainline Hardware Encoding"
(VP8 got an RFC for RK3399) |
(Add VP8 GStreamer encoding info) |
||
Line 46: | Line 46: | ||
gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2jpegenc extra-controls=s,compression_quality=95 ! matroskamux ! filesink location=output.mkv | gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2jpegenc extra-controls=s,compression_quality=95 ! matroskamux ! filesink location=output.mkv | ||
== VP8 Encoding == | |||
{{hint|'''Note:''' This requires a draft [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3736 GStreamer merge request] and the RFC kernel patchset applied.}} | |||
This example converts an input MP4 file to an output VP8-inside-MKV file with a quantiser between 12 and 28, without any audio. The quantiser value goes from 0 (best quality, biggest filesize) to 63 (worst quality, smallest filesize). | |||
gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2slvp8enc min-quality=12 max-quality=28 ! queue ! matroskamux ! filesink location=output.mkv | |||
Alternatively, you can encode in variable bitrate mode with a target bitrate given in bits per second. Do note that Hantro doesn't seem to do target bitrates below 2 mbit/s. In this example, the file is transcoded at a target bitrate of 3 megabits per second. | |||
gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2slvp8enc bitrate=3000000 ! queue ! matroskamux ! filesink location=output.mkv | |||
= See Also = | = See Also = |
Revision as of 16:32, 18 March 2023
Mainline Hardware Encoding of video can be achieved through the V4L2 user-space API, for which currently only GStreamer implements the required code.
SoC Support
The following table shows the current supported codecs for encoding for each SoC. Support for decoding is separate.
SoC Codec
|
RK3328 | RK3399 | RK3566 | RK3588 |
---|---|---|---|---|
JPEG | N/A | Yes | Yes | No |
VP8 | N/A | In review[1] | No | No |
H.264/AVC | No | No | No | No |
H.265/HEVC | No | N/A | No | No |
Encoding With GStreamer
With GStreamer, in general, any V4L2 control can be set using the extra-controls=foo,name=value
syntax after the encode pipeline stage identifier, where foo
is any name you wish which GStreamer will promptly ignore, name
is the name of the V4L2 control as shown by v4l2-ctl --list-ctrls
(make sure to pick the right device with -d
), and value
is whatever value you want to set it to.
JPEG Encoding
This example converts an input MP4 file to an output MJPEG-inside-MKV file at JPEG quality 95, without any audio.
gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2jpegenc extra-controls=s,compression_quality=95 ! matroskamux ! filesink location=output.mkv
VP8 Encoding
This example converts an input MP4 file to an output VP8-inside-MKV file with a quantiser between 12 and 28, without any audio. The quantiser value goes from 0 (best quality, biggest filesize) to 63 (worst quality, smallest filesize).
gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2slvp8enc min-quality=12 max-quality=28 ! queue ! matroskamux ! filesink location=output.mkv
Alternatively, you can encode in variable bitrate mode with a target bitrate given in bits per second. Do note that Hantro doesn't seem to do target bitrates below 2 mbit/s. In this example, the file is transcoded at a target bitrate of 3 megabits per second.
gst-launch-1.0 filesrc location=input.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoconvert ! v4l2slvp8enc bitrate=3000000 ! queue ! matroskamux ! filesink location=output.mkv