<mark>'''[STEP1]'''</mark>
*Edit the <code>/boot/firmware/config.txt</code> file (sudo privileges required):
<pre>
sudo nano /boot/firmware/config.txt
<mark>'''[STEP2]''' </mark>
*Add the line:
<pre>
dtoverlay=tc358743
<mark>'''[STEP3]'''</mark>
*Use the following command to check the amount of memory allocated to the CMA heap:
<pre>
dmesg | grep cma
<mark>'''[STEP4]'''</mark>
*Reboot the device. If everything works properly, you should see the <code>/dev/video0</code> device, and running the following command will show it is provided by Unicam:
<pre>
v4l2-ctl --list-devices
<mark>'''[STEP5]'''</mark>
*After connecting all cables, power on the Raspberry Pi and enter the commands below:
<pre>
pi@raspberrypi:~ $ ls /dev/video0
</pre>
:'''NOTE: This driver gives full control to the user or the user's applications. By default, no EDID (Extended Display Identification Data) is loaded in the chip, so it cannot inform the HDMI source of the supported resolutions.'''
*Several EDID editors are available on the market. You need to first create an edid.txt file (you can use the <code>command nano edid.txt</code> to create and edit the file), then copy the content below into the edid.txt file:
<mark>'''[STEP6]'''</mark>
*Detect the presence of HDMI signal input at present via command:
<pre>
pi@raspberrypi:~ $ v4l2-ctl --query-dv-timings
*Use the command <code>v4l2-ctl --set-dv-bt-timings query</code> to make the driver automatically set the video timing parameters (such as resolution and frame rate) based on the current HDMI input signal, ensuring the capture card correctly recognizes and processes the current HDMI signal.
:The chip supports two formats — BGR3 (default) and UYVY. BGR3 is 24bpp, while UYVY is YUV4:2:2 16bpp.
:On the standard two CSI-2 lanes, the data rate allows BGR3 to support up to 1080p30, whereas UYVY can support up to 1080p50.
*Use the following command to select UYVY (however, your application may override this setting):
<pre>
v4l2-ctl -v pixelformat=UYVY
</pre>
<mark>'''[STEP7]'''</mark>
*Check if the audio driver/sound card is available for ALSA:
<pre>
pi@raspberrypi:~ $ arecord -l.
**** List of CAPTURE Hardware Devices ****.
card 1: tc358743 [tc358743], device 0: bcm2835-i2s-dir-hifi dir-hifi-0 [bcm2835-i2s-dir-hifi dir-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
</pre>
:'''NOTE: card 1 means the audio card number for the TC358743XBG is 1. This number may vary.'''
<mark>'''[STEP8]'''</mark>
*Install the GStreamer tools:
<pre>
sudo apt install gstreamer1.0-tools
</pre>
*Check the GStreamer tool version:
<pre>
pi@raspberrypi:~ $ gst-launch-1.0 --version
gst-launch-1.0 version 1.18.4
GStreamer 1.18.4
http://packages.qa.debian.org/gstreamer1.0
</pre>
:'''NOTE: Command-line arguments may vary across different versions, which can be confusing.'''
----
<mark>'''[Application Example — Using GStreamer to Record Video and Audio]'''</mark>
<pre>
# GStreamer v1.14 Command
gst-launch-1.0 v4l2src io-mode=5 ! video/x-raw, format=UYVY, framerate=25/1 ! v4l2h264enc output-io-mode=4 ! video/x-h264,profile=high ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux.
</pre>
<code>foo.mkv</code> is the output file.
If your GStreamer version is 1.8 or higher, you can try the following test command. Additionally, <code>alsasrc device=hw:1</code> refers to the sound card for TC358743; you can check this with the command <code>arecord -l</code>.
<pre>
# Command to record video with audio(GStreamer 1.18.4)
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=30/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux.
# Example command to record video without audio (C779 does not support audio)
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=30/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv
# Press CTRL+C to stop the recording.
</pre>
'''<span class="tb_red">Important Note:</span>''' We recommend you set the above framerate parameter to the actual frame rate of your HDMI signal. You can get this value from the output of the command <code>v4l2-ctl --query-dv-timings</code>.
[[File:Editting frame rate.png|thumb 600px]]
For the HDMI device mentioned above, since the frame rate is 60, we set the framerate parameter to 60, as shown in the following command:
*Record video only:
<pre>
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=60/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv
</pre>
*Record video and audio (if your module supports audio):
<pre>
gst-launch-1.0 -vvv v4l2src ! "video/x-raw,framerate=60/1,format=UYVY" ! v4l2h264enc extra-controls="controls,h264_profile=4,h264_level=13,video_bitrate=256000;" ! "video/x-h264,profile=high, level=(string)4.2" ! h264parse ! queue ! matroskamux name=mux ! filesink location=foo.mkv alsasrc device=hw:1 ! audio/x-raw,rate=48000,channels=2 ! audioconvert ! avenc_aac bitrate=48000 ! aacparse ! queue ! mux.
</pre>
:'''NOTE: The "1" in <code>alsasrc device=hw:1</code> is the sound card number, and you must change it to the correct one.(Check the sound card number with the <code>arecord -l</code> command, refer to Step 9)
<span class="tb_red"></span>