webrtc_codecs_h264 (webrtc_codecs v0.1.0)
View SourceH.264 codec plugin, on OpenH264.
webrtc:add_transceiver(Pc, video, #{frames => true, codec_plugin => {webrtc_codecs_h264, #{}}}).decode/2 takes an access unit in Annex B and gives one
webrtc_codecs:picture/0 per picture, with the RTP timestamp of the
frame. It decodes the baseline, main and high profiles. After a frame it
cannot decode it drops frames until the next key frame.
encode/2 takes webrtc_codecs:picture/0 and encodes constrained
baseline in real time, which every negotiated profile-level-id of
those three profiles can decode. It follows bitrate (bits per second)
and makes a key frame, with its parameter sets, for keyframe => true.
Pictures of another size start a new stream with a key frame. Width
and height have to be even.
Options:
bitrate: of the encoder at start, default from the picture sizemin_bitrate,max_bitrate: bounds for the bitrate, default 30000 and nonekeyframe_interval: most frames between two key frames, default 3000threads: of the encoder, default from the picture size and the number of schedulersmax_pixels: largest picture the decoder accepts, default 3840 x 2160
Summary
Types
What a sequence parameter set declares (ITU-T H.264 section 7.3.2.1.1): its id, its profile, the size of the pictures as they are coded (whole macroblocks, which is what a decoder allocates) and as they are shown (cropping applied).
Functions
The NAL units of an access unit in Annex B (ITU-T H.264 annex B),
without their start codes: {Type, Unit} where Type is
nal_unit_type.
Read a sequence parameter set, a NAL unit of type 7; error when it cannot be read.
Types
-type sps_info() :: #{id := non_neg_integer(), profile := byte(), coded := {pos_integer(), pos_integer()}, cropped := {pos_integer(), pos_integer()}}.
What a sequence parameter set declares (ITU-T H.264 section 7.3.2.1.1): its id, its profile, the size of the pictures as they are coded (whole macroblocks, which is what a decoder allocates) and as they are shown (cropping applied).
Functions
The NAL units of an access unit in Annex B (ITU-T H.264 annex B),
without their start codes: {Type, Unit} where Type is
nal_unit_type.
Read a sequence parameter set, a NAL unit of type 7; error when it cannot be read.