Skip to content

Commit 1723802

Browse files
committed
camera: Add libav documentation
Add documentation to the libcamera_apps guide for the new libav backend. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent e320276 commit 1723802

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

documentation/asciidoc/accessories/camera.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ include::camera/libcamera_still.adoc[]
1414

1515
include::camera/libcamera_vid.adoc[]
1616

17+
include::camera/libcamera_apps_libav.adoc[]
18+
1719
include::camera/libcamera_raw.adoc[]
1820

1921
include::camera/libcamera_detect.adoc[]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
=== libav integration with libcamera-vid
2+
3+
`libcamera-vid` can use the ffmpeg/libav codec backend to encode audio and video streams and either save to a local file or stream over the network. At present, video is encoded through the hardware H.264 encoder, and audio is encoded by a number of available software encoders. To list the available output formats, use the `ffmpeg -formats` command.
4+
5+
To enable the libav backend, use the `--codec libav` command line option. Once enabled, the following configuration options are available:
6+
7+
----
8+
--libav-format, libav output format to be used <string>
9+
----
10+
11+
Set the libav output format to use. These output formats can be specified as containers (e.g. mkv, mp4, avi) or stream output (e.g. h264 or mpegts). If this option is not provided, libav tries to deduce the output format from the filename specified by the `-o` command line argument.
12+
13+
Example: To save a video in an mkv container, the following commands are equivalent:
14+
15+
----
16+
libcamera-vid --codec libav -o test.mkv
17+
libcamera-vid --codec libav --libav-format mkv -o test.raw
18+
----
19+
20+
----
21+
--libav-audio, Enable audio recording
22+
----
23+
24+
Set this option to enable audio encoding together with the video stream. When audio encodding is enabled, an output format that supports audio (e.g. mpegts, mkv, mp4) must be used.
25+
26+
----
27+
--audio-codec, Selects the audio codec <string>
28+
----
29+
30+
Selects which software audio codec is used for encoding. By default `aac` is used. To list the available audio codecs, use the ``ffmpeg -codec`` command.
31+
32+
----
33+
--audio-bitrate, Selects the audio bitrate <number>
34+
----
35+
36+
Sets the audio encoding bitrate in bits per second.
37+
38+
Example: To record audio at 16 kilobits/sec with the mp2 codec use `libcamera-vid --codec libav -o test.mp4 --audio_codec mp2 --audio-bitrate 16384`
39+
40+
----
41+
--audio-device, Chooses and audio recording device to use <string>
42+
----
43+
44+
Selects which ALSA input device to use for audio encoding. The audio device string can be obtained by the following command:
45+
46+
----
47+
pi@pi4:~ $ pactl list | grep -A2 'Source #' | grep 'Name: '
48+
Name: alsa_output.platform-bcm2835_audio.analog-stereo.monitor
49+
Name: alsa_output.platform-fef00700.hdmi.hdmi-stereo.monitor
50+
Name: alsa_output.usb-GN_Netcom_A_S_Jabra_EVOLVE_LINK_000736B1214E0A-00.analog-stereo.monitor
51+
Name: alsa_input.usb-GN_Netcom_A_S_Jabra_EVOLVE_LINK_000736B1214E0A-00.mono-fallback
52+
----
53+
54+
----
55+
--av-sync, Audio/Video sync control <number>
56+
----
57+
This option can be used to shift the audio sample timestamp by a value given in microseconds relative to the video frame. Negative values may also be used.
58+
59+
==== Network streaming with libav
60+
61+
It is possible to use the libav backend as a network streaming source for audio/video. To do this, the output filename specified by the `-o` argument must be given as a protocol url, see https://ffmpeg.org/ffmpeg-protocols.html[ffmpeg protocols] for more details on protocol usage. Some examples:
62+
63+
To stream audio/video using TCP
64+
----
65+
libcamera-vid -t 0 --codec libav --libav-format mpegts --libav-audio -o "tcp://0.0.0.0:1234?listen=1"
66+
----
67+
68+
To stream audio/video using UDP
69+
----
70+
libcamera-vid -t 0 --codec libav --libav-format mpegts --libav-audio -o "udp://<ip-addr>:<port>"
71+
----

documentation/asciidoc/accessories/camera/libcamera_options_vid.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This can select how the video frames are encoded. Valid options are:
4949
* h264 - use H.264 encoder (the default)
5050
* mjpeg - use MJPEG encoder
5151
* yuv420 - output uncompressed YUV420 frames.
52+
* libav - use the libav backend to encode audio and video (see the xref:camera.adoc#libav-integration-with-libcamera-vid[libav section] for further details).
5253
5354
Examples:
5455

documentation/asciidoc/accessories/camera/libcamera_vid.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Observe that the output file name is normally only sensible if we avoid over-wri
3838

3939
==== Network Streaming
4040

41+
NOTE: This section describes native streaming from `libcamera-vid`. However, it is also possible to use the libav backend for network streaming. See the xref:camera.adoc#libav-integration-with-libcamera-vid[libav section] for further details.
42+
4143
===== UDP
4244

4345
To stream video using UDP, on the Raspberry Pi (server) use

0 commit comments

Comments
 (0)