Skip to content

Instantly share code, notes, and snippets.

@jnslxndr
Last active January 24, 2021 21:19
Show Gist options
  • Select an option

  • Save jnslxndr/3fe0dea67fcf215e06fc304be4ed6cc0 to your computer and use it in GitHub Desktop.

Select an option

Save jnslxndr/3fe0dea67fcf215e06fc304be4ed6cc0 to your computer and use it in GitHub Desktop.

Revisions

  1. jens alexander ewald revised this gist Jan 24, 2021. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions vhs.pi.md
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,14 @@


    ```
    # FInally worked in one go:
    vlc v4l2:///dev/video0:input=0:width=720:height=576:norm=PAL:input-slave=pulse://alsa_input.usb-Hauppauge_Hauppauge_Device_0014080666-01.stereo-fallback --demux rawvideo --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --fullscreen
    # 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.
  2. jens alexander ewald revised this gist Jan 24, 2021. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions vhs.pi.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,15 @@
    vlc v4l2:///dev/video0:input=0:width=720:height=576:norm=PAL:input-slave=pulse://alsa_input.usb-Hauppauge_Hauppauge_Device_0014080666-01.stereo-fallback --demux rawvideo --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --fullscreen
    ```

    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
  3. jens alexander ewald revised this gist Jan 24, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions vhs.pi.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,12 @@
    # Raspberry Pi Notes


    ```
    # FInally worked in one go:
    vlc v4l2:///dev/video0:input=0:width=720:height=576:norm=PAL:input-slave=pulse://alsa_input.usb-Hauppauge_Hauppauge_Device_0014080666-01.stereo-fallback --demux rawvideo --qt-fullscreen-screennumber=1 --aspect-ratio=16:9 --autoscale --fullscreen
    ```


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

  4. jens alexander ewald revised this gist Jan 24, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion vhs.pi.md
    Original file line number Diff line number Diff line change
    @@ -162,6 +162,7 @@ vlc v4l2:///dev/video0:input=0:width=720:height=576:norm=PAL:input-slave=alsa://

    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 \
    @@ -197,5 +198,5 @@ 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

    ```

  5. jens alexander ewald created this gist Jan 24, 2021.
    201 changes: 201 additions & 0 deletions vhs.pi.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,201 @@
    # Raspberry Pi Notes


    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

    * Extensive list of details on diplsay and the pi: https://www.improwis.com/projects/hw_RaspberryPiSPIdisplays/



    ## 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