Skip to content

Instantly share code, notes, and snippets.

@jens-a-e
Last active January 24, 2021 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jens-a-e/3fe0dea67fcf215e06fc304be4ed6cc0 to your computer and use it in GitHub Desktop.
Save jens-a-e/3fe0dea67fcf215e06fc304be4ed6cc0 to your computer and use it in GitHub Desktop.

Raspberry Pi Notes

# Final Version to launch on second screen. The spaces in the options with ":" are important!
vlc v4l2:///dev/video0:input=0 :v4l2-standard=PAL :input-slave=pulse://alsa_input.usb-Hauppauge_Hauppauge_Device_0014080666-01.stereo-fallback :live-caching=300 --demux rawvideo --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --fullscreen

There is some more from the VLC gui:

:v4l2-standard=PAL :input-slave=pulse://alsa_input.usb-Hauppauge_Hauppauge_Device_0014080666-01.stereo-fallback :live-caching=300

Using the pulse://<source name from paced list-sources|grep 'name:'> for the input slave worked finally.

To get the names of the device run:

pacmd list-sources | grep 'name:'

Recommended VHS hardware and other tips: https://www.vinett-video.de/geraete_und_technik/kaufempfehlung-vhs-videorecorder

http://thomas-messmer.com/index.php/15-free-knowledge/allerlei/technische-informationen/43-s-vhs-videorecorder

Some ads on Kleinanzeigen:

Hm… 200€ https://www.ebay-kleinanzeigen.de/s-anzeige/jvc-highend-videorecorder-hr-s9700eu/1636905185-175-719

https://www.ebay-kleinanzeigen.de/s-anzeige/panasonic-nv-hs-900/1591493115-175-13590

Getting Display to work

I am trying to get the Blackmagic Ultrastudio Express video capture card working with PAL over HDMI

I had it working with the desktop environment once but struggled ever since.

Links

Notes from the CLI

Ultrastudio Express' EDID is: device_name=HXA-BMD_HDMI

# Get the edid info:
tvservice -d /tmp/edid

# Read the edid info:
edidparser /tmp/edid 

# preferred resolution
edidparser /tmp/edid | grep preferred

# supposedly this refreshes the screen buffer
fbset -depth 8 && fbset -depth 16
# maybe to 8 bit for PAL
fbset -depth 16 && fbset -depth 8

Did not resolve the BMD card to recognise 576i or p over HDMI

For composite there is no matching cable,

Resolution

Using 720p and stretch window then anamorphic conversion of the BMD UltraStudio Express to convert it back to PAL 4:3. Basically 720p down to SD; then use PAL 625i50 preset while capturing.

The Video Commands


cvlc v4l2:///dev/video0 :v4l2-width=720 :v4l2-height=576 :input-slave="alsa://hw:CARD=Cx231xxAudio" --aspect-ratio=4:3 --crop=4:3 --fullscreen

cvlc v4l2:///dev/video0:v4l2-width=720:v4l2-height=576:input-slave=alsa://sysdefault:CARD=Cx231xxAudio --aspect-ratio=4:3 --crop=4:3 --no-autoscale --no-video-deco --fullscreen 

cvlc v4l2:///dev/video0:v4l2-width=720:v4l2-height=576:input-slave=alsa://sysdefault:CARD=Cx231xxAudio --aspect-ratio=16:9 --autoscale --no-video-deco --fullscreen 

# This one worked finally
cvlc v4l2:///dev/video0 --aspect-ratio=16:9 --autoscale --no-video-deco --fullscreen

The Service Files for systemd

###############################
# vhs.image.service

[Unit]
Description=Pipes /dev/video0 to fullscreen using VLC
After=multi-user.target

[Service]
Type=idle
User=pi
Restart=on-abort
# Important to set the DISPLAY for VLC
Environment=DISPLAY=:0
ExecStart=/usr/bin/vlc -I dummy --deinterlace=1 v4l2:///dev/video0 --aspect-ratio=16:9 --autoscale --no-video-deco --fullscreen

[Install]
WantedBy=multi-user.target

VLC hangs once in a while after ~90 minutes

This is a version with ffmpeg straight to the frame buffer

[Unit]
Description=Pipes /dev/video0 to fullscreen HDMI out
After=multi-user.target

[Service]
Type=idle
User=pi
#Restart=on-abort
Environment=DISPLAY=:0
#ExecStart=/usr/bin/vlc -I dummy --deinterlace=1 v4l2:///dev/video0 --aspect-ratio=16:9 --autoscale --no-video-deco --fullscreen
ExecStart=/usr/bin/ffmpeg -i /dev/video0 -vf yadif -vf scale=1280:720 -pix_fmt rgb565le -f fbdev /dev/fb0 -hide_banner -loglevel panic
# ExecStart=/usr/bin/vlc -I dummy --deinterlace=1 v4l2:///dev/video0 --aspect-ratio=16:9 --autoscale --no-video-deco --fullscreen
# Oder /usr/bin/cvlc -I dummy --deinterlace=0 v4l2:///dev/video0 --aspect-ratio=16:9 --autoscale --no-video-deco --fullscreen

[Install]
WantedBy=multi-user.target
###############################
# vhs.audio.service

[Unit]
Description=Pipes audio from /dev/video0 to HDMI0 audio
After=multi-user.target

[Service]
Type=idle
ExecStart=/bin/bash -c "/usr/bin/arecord -D hw:2,0 -t wav -f dat | /usr/bin/aplay -D hw:0,0"

[Install]
WantedBy=multi-user.target

Install both of the in /lib/systemd/system/vhs.image.service and /lib/systemd/system/vhs.audio.service respectively.

Then to install and enable:

sudo chmod 644 /lib/systemd/system/vhs.*
sudo systemctl daemon-reload

# And enable
sudo systemctl enable vhs.image.service
sudo systemctl enable vhs.audio.service

More tests

vlc v4l2:///dev/video0:input=0:width=720:height=576:norm=PAL:input-slave=alsa://hw:3,0 --demux rawvideo --fullscreen --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --aout=alsa --alsa-audio-device="plughw:1,0"

vlc v4l2:///dev/video0:input=0:width=720:height=576:norm=PAL:input-slave=alsa://plughw:3,0 --demux rawvideo --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --aout=alsa --alsa-audio-device="plughw:1,0" --fullscreen

streaming

Hauppauge USB Live 2

ffmpeg -f v4l2 -i /dev/video0 -f alsa -i hw:3 -profile:v high -pix_fmt yuvj420p -level:v 4.1 -preset ultrafast -tune zerolatency -vcodec libx264 -r 10 -b:v 512k -s 720x576 -acodec aac -strict -2 -ac 2 -ab 32k -ar 48000 -f mpegts -flush_packets 0 udp://192.168.0.193:5000?pkt_size=1316

ffmpeg -f v4l2 -i /dev/video0 -f alsa -i hw:3 \
-profile:v high \
-pix_fmt yuvj420p \
-level:v 4.1 \
-preset ultrafast \
-vcodec libx264 \
-r 25 \
-b:v 1024k \
-s 720x576 \
-acodec aac -strict -2 -ac 2 -ab 32k -ar 48000 \
-f mpegts -flush_packets 0 \
udp://127.0.0.1:5000?pkt_size=1316

ffmpeg -f v4l2 -i /dev/video0 -thread_queue_size 16 \
-f alsa -i hw:3 \
-vcodec libx264 \
-profile:v high \
-pix_fmt yuvj420p \
-level:v 4.1 \
-crf 18 \
-tune zerolatency \
-preset ultrafast \
-r 25 \
-b:v 165888k \
-s 720x576 \
-acodec aac -strict -2 -ac 2 -ab 320k -ar 48000 \
-f mpegts -flush_packets 0 \
udp://127.0.0.1:5000?pkt_size=1316



vlc udp://@0.0.0.0:5000 --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --aout=alsa --alsa-audio-device="plughw:1,0" --fullscreen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment