webrtc_codecs_pattern (webrtc_codecs v0.1.0)

View Source

Test media made in Erlang: a moving picture and a tone to feed an encoder when you have no camera or microphone, and the measures to compare what a decoder gives back.

Pic = webrtc_codecs_pattern:picture(320, 240, N),
ok = webrtc:send_media(Pc, Mid, Pic#{timestamp => N * 3000}).

Summary

Functions

Picture number N of the pattern: eight colour bars with a grey square that moves across them, so consecutive pictures differ. Width and Height are even. The timestamp is N at 30 pictures per second.

Peak signal to noise ratio between two pictures of the same size, in dB over the three planes; infinity when they are identical.

Signal to noise ratio of decoded audio against the original, in dB, over the samples both have; infinity when they are identical.

Ms milliseconds of a sine at Hz, the same on every channel, starting at sample Offset so consecutive calls join without a click. The timestamp is Offset.

Functions

picture(W, H, N)

Picture number N of the pattern: eight colour bars with a grey square that moves across them, so consecutive pictures differ. Width and Height are even. The timestamp is N at 30 pictures per second.

psnr/2

-spec psnr(webrtc_codecs:picture(), webrtc_codecs:picture()) -> float() | infinity.

Peak signal to noise ratio between two pictures of the same size, in dB over the three planes; infinity when they are identical.

snr/2

-spec snr(webrtc_codecs:audio(), webrtc_codecs:audio()) -> float() | infinity.

Signal to noise ratio of decoded audio against the original, in dB, over the samples both have; infinity when they are identical.

tone/4

-spec tone(number(),
           pos_integer(),
           #{sample_rate := pos_integer(), channels := pos_integer()},
           non_neg_integer()) ->
              webrtc_codecs:audio().

Ms milliseconds of a sine at Hz, the same on every channel, starting at sample Offset so consecutive calls join without a click. The timestamp is Offset.