Home | Mμse | Docs | Art | Music | Videos | Projects | Forum | Shop

[ Click to visit TheOuterLinux's 'Support Me' page ] [ QRCode ] [ RSS ]



"StreamPi - FFMPEG for RTMP Streaming" by TheOuterLinux



Description

Grab a copy: https://gitlab.com/theouterlinux/StreamPi

A while back I asked for help on using ffmpeg to stream to Twitch with a Raspberry Pi 3. After countless testing, Internet searching, and suggestions, I've created a script to help make this mess a little easier:

A. If you are using a Raspberry Pi (anything other than i686 or x86_64):

    Use ALSA by default
    Automatically detect monitor size
    If monitor is larger than 720p wide, scale down

B. If you are using an i686 (32-bit):

    Automatically use PulseAudio if running
    Automatically use JACK if running
    If monitor is larger than 720p wide, scale down

C. If you are using an x86_64 (64-bit):

    Automatically use PulseAudio if running
    Automatically use JACK if running
    Do not scale monitor

D. Variables you can adjust (Supplied with #Notes in the script):

    RTMP="$1" --> Either store RTMP URL in script or use as /path/to/StreamPi [URL]
    SOUNDSERVER=alsa --> Shouldn't need to touch
    SCALE="trunc(oh*a/2)2:720" --> Prevents "odd number" errors
    QUALITY=23 --> Same as CRF value, but don't use "0"
    THREAD_QUEUE=1024 --> Not needed for the Pi, but required on other systems
    SPANMONITORS=N --> Record/Stream if two monitors or non-mirroring a laptop
    ANTI_BOTTOM_PANEL=0 --> Use to help hide a bottom panel (in pixels)
    ANTI_TOP_PANEL=0 --> Use to help hide a top panel (in pixels)
    ANTI_LEFT_PANEL=0 --> Use to help hide a left-side, vertical panel (in pixels)
    ANTI_RIGHT_PANEL=0 --> Use to help hide a right-side, vertical panel (in pixels)

Having that said, I made a video showing off this script via "/path/to/StreamPi out.flv" because I could not stream and record at the same time with the firepower that I had. Just know that the frame rates and audio quality appear to be about the same in either case. In the video there are three computers: 1. Raspberry Pi 3 [Raspbian], 2. Acer Aspire One ZG5 Netbook (2008) [AntiX Linux], and a MacBook 4,1 (2008) [MX Linux]. I also test this on a newer x86_64 laptop, but the audio was out of sync from the video by about 10-20 seconds, so I would stick with using OBS Studio on systems that it's still "gracious" enough to support. Maybe if you have an older computer, you can use this. To make this faster, I set an alias in my .bashrc file as "alias stream_twitch='/path/to/StreamPi rtmp://...'"; this way, all I have to do is type "twitch_stream" in a terminal (with X running) and I'm good to go.

Keywords: command-line, linux, streaming, Twitch, recording, ffmpeg

Video License: CC-BY-NC-ND 4.0

Disclaimer