Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wicknix

macrumors 68030
Original poster
Jun 4, 2017
2,707
5,407
Wisconsin, USA
So @ActionRetro has been streaming to Twitch on a Quad G5, and even a G3. I wanted to test this out myself and did a stream from my 1.33ghz 12" PowerBook G4 using ffmpeg (and ffplay to capture my usb webcam) on Void ppc32. You can check out the 5 FPS stream here. Watch in theater mode or full screen to read the text.


Pretty cool stuff these old machines can still pull off.

Cheers
 
Last edited:
Would having an Elgato help for encoding? There is an older firewire-based one which encodes H.264, though I'm not sure how the software could set up to utilize it...
 
I'd like to figure out how to do this from Leopard as i already have ffmpeg and ffplay built from macports. The issue i'm running in to is that there is no coremedia/avfoundation on anything lower than Lion which seems to be a requirement for ffmpeg streaming on OS X to capture the screen and audio.

Cheers
 
According to https://www.bhphotovideo.com/c/prod..._Systems_10020196_turbo_264_HD_USB_H_264.html it can do 1080p@30Hz but I think the more difficult part would be to pipe the screen to it and then get the result stream to send up to twitch.
That unit is intel only - this was the PPC version:

 
  • Like
Reactions: TheShortTimer
I was able to stream on iBook G4 running Void. I am trying to get Tiger to stream. Will be cool if I get it to work. Running into the same issue with no coremedia/avfoundation
 
  • Like
Reactions: wicknix
I have made it with my PB G4 DVI Running Debian 11 :) .. very unstable using wifi.. will try later with ethernet...
 

Attachments

  • Captura de pantalla 2022-02-12 a las 00.38.27.png
    Captura de pantalla 2022-02-12 a las 00.38.27.png
    236.2 KB · Views: 98
Sadly i don't think it's possible as i noted above. We need avfoundation for it to work from everything i've read. I did have 1 weird idea however. Since x11 is available for leopard, it *might* be possible to somehow use x11grab like we do on linux to capture the desktop. It might just capture the actual x11 applications though. I haven't had the time to investigate further however.

Cheers
 
  • Like
Reactions: G4fanboy
@wicknix and everyone I think I have made some progress but I need some second and third set of eyes. I tried using x11 but that is not supported (spent 2 days compiling the software in macports). However my research brought me to this post The components he used was vlc, ffmpeg, sox, and soundflower. Then he incorperated this into a script that I have made slight changes which I will attach. I got ffmpeg to stream (I see the packets in tcpdump). However the audio crashes and I do not see the stream on twitch. I am building wireshark to see if I can recreate the stream from the packets to verify my screen is being broadcasted. Any feedback will be appreciated.

Code:
#!/bin/sh -xe

API_KEY=$(cat twitch.key)
FPS="20"

# I don't know how this'll behave on multimon, so you might want to hard-code.
# INRES='1440x900'
INRES=$(osascript -e 'tell application "Finder" to get bounds of window of desktop'|sed 's/, /x/g'|cut -f3- -dx)
OUTRES='1280x800'
# You can change this to record microphone or something else, from man soxformat (under coreaudio):
# The valid names can be seen in the System Preferences->Sound menu and then under the Output and Input tabs.
COREAUDIO_DEVICE="Soundflower (2ch)"

VIDEO_FIFO=/tmp/vlc-ffmpeg.raw
AUDIO_FIFO=/tmp/sox-ffmpeg.wav

for fifo in "$VIDEO_FIFO" "$AUDIO_FIFO"; do
  rm -f "$fifo"
  mkfifo "$fifo"
done

# This is called when you ^C or an app quits. It kills all the processes and deletes the FIFOs.
function cleanup() {
  trap "" EXIT INT

  [[ ! -z "$vlc_pid" ]] && kill -9 "$vlc_pid"
  [[ ! -z "$sox_pid" ]] && kill -9 "$sox_pid"
  [[ ! -z "$ffmpeg_pid" ]] && kill -9 "$ffmpeg_pid"
  rm -f "$VIDEO_FIFO"
  rm -f "$AUDIO_FIFO"
}

trap "cleanup" EXIT INT

# VLC streams screen:// to $VIDEO_FIFO, in a raw BGRA format.
$VLC_PATH screen:// :screen-fps="$FPS" -I dummy --sout="file/dummy:$VIDEO_FIFO" &
vlc_pid=$!

# SOX streams $COREAUDIO_DEVICE to $AUDIO_FIFO (with an increased buffer size, 4MB)
sox --buffer 4194304 -q -c 2 -t coreaudio "$COREAUDIO_DEVICE" -t wav "$AUDIO_FIFO" &
sox_pid=$!

# ffmpeg reads raw video from $VIDEO_FIFO, recodes it using libx264, combines it with mp3 that's been
# transcoded from $AUDIO_FIFO with LAME, and ships it as FLV to justin.tv's RTMP server.
ffmpeg -threads 0 \
  -f rawvideo -pix_fmt bgra -s "$INRES" -r "$FPS" -i "$VIDEO_FIFO" \
  -f wav -i "$AUDIO_FIFO" \
  -vcodec libx264 -s "$OUTRES" \
  -acodec libmp3lame -ab 128k -ar 44100 \
  -f flv "rtmp://jfk.contribute.live-video.net/app/$API_KEY" &
ffmpeg_pid=$!

wait $ffmpeg_pid $sox_pid $vlc_pid
 
  • Like
Reactions: dwk and wicknix
Cool. I played around with it for a few hours and actually got a live stream working... Just not well. I disabled all the sound stuff to simplify my tests. Twitch requires -pix_fmt yuv420p from ffmpeg. Other options (like bgra) wont work. That's probably why you didn't see anything go live. The issue i ran in to is that yuv420p seems b0rked on ppc os x. The capture is garbled and wrong size, but it went live! I tested locally with outputting to a test.flv using -pix_fmt argb and it was perfect. I then tried that going live. It marked me as live, but the video wont play or be visable. Only the thumbnail showed up on twitch. Anyway, you can check out the busted yuv420p stream from here:


My modified script so far:
Code:
#!/bin/sh -xe

API_KEY=$(cat ~/.twitch-key)
FPS="10"
VLC_PATH="/Applications/VLC.app/Contents/MacOS/VLC"
INRES='1280x854'
OUTRES='720x480'
VIDEO_FIFO=vlc.raw

for fifo in "$VIDEO_FIFO"; do
  rm -f "$fifo"
  mkfifo "$fifo"
done

# This is called when you ^C or an app quits. It kills all the processes.
function cleanup() {
  trap "" EXIT INT

  [[ ! -z "$vlc_pid" ]] && kill -9 "$vlc_pid"
  [[ ! -z "$ffmpeg_pid" ]] && kill -9 "$ffmpeg_pid"
  rm -f "$VIDEO_FIFO"
}

trap "cleanup" EXIT INT

# VLC streams screen:// to vlc.raw, in a raw BGRA format.
$VLC_PATH screen:// :screen-fps="$FPS" -I dummy --sout="file/dummy:$VIDEO_FIFO" &
vlc_pid=$!

sleep 5 # Need to let VLC load before ffmpeg kicks in.

# use -pix_fmt argb for proper colors & screen res. it's not supported by twitch.tv however. that requires yuv420p.
# ffmpeg reads raw video from vlc.raw, recodes it using libx264, and ships it as FLV to twitch.tv RTMP server.
ffmpeg -threads 0 \
  -f rawvideo -pix_fmt yuv420p -s "$INRES" -r "$FPS" -i "$VIDEO_FIFO" -preset ultrafast -vcodec libx264 -s "$OUTRES" \
  -f flv "rtmp://ord02.contribute.live-video.net/app/$API_KEY" &
ffmpeg_pid=$!

wait $ffmpeg_pid $vlc_pid

Cheers
 
Last edited:
This works for me for just capturing desktop video.

Code:
#!/bin/sh -xe

FPS="10"
VLC_PATH="/Applications/VLC.app/Contents/MacOS/VLC"
INRES='1280x854'
OUTRES='720x480'
VIDEO_FIFO=vlc.raw

for fifo in "$VIDEO_FIFO"; do
  rm -f "$fifo"
  mkfifo "$fifo"
done

# This is called when you ^C or an app quits. It kills all the processes.
function cleanup() {
  trap "" EXIT INT

  [[ ! -z "$vlc_pid" ]] && kill -9 "$vlc_pid"
  [[ ! -z "$ffmpeg_pid" ]] && kill -9 "$ffmpeg_pid"
  rm -f "$VIDEO_FIFO"
}

trap "cleanup" EXIT INT

# VLC streams screen:// to vlc.raw, in a raw BGRA format.
$VLC_PATH screen:// :screen-fps="$FPS" -I dummy --sout="file/dummy:$VIDEO_FIFO" &
vlc_pid=$!

sleep 5 # Need to let VLC load before ffmpeg kicks in.

# ffmpeg reads raw video from vlc.raw, recodes it using libx264, and creates a FLV video.
ffmpeg -threads 0 \
  -f rawvideo -pix_fmt argb -s "$INRES" -r "$FPS" -i "$VIDEO_FIFO" -preset ultrafast -vcodec libx264 -s "$OUTRES" \
  -f flv capture.flv
ffmpeg_pid=$!

wait $ffmpeg_pid $vlc_pid

The capture.flv will be saved to the same directory this script is run from. I just put the script on my desktop so i can see that it's working. Let me know how it works for you. I use ffmpeg built from macports on Leopard. However it seems like its captured at 4x speed? Still playing with different options.

Cheers
 
@wicknix can you share your modified script?
It's just the same as the script a few posts up. I just switched -pix_fmt yuv420p to argb. It wont stream to twitch in real time because twitch requires yuv420p, but it will eventually be uploaded as a video to twitch.

I'm wondering if i can have ffmpeg encode as argb, then pipe that back to ffmpeg again, and have it encode to the proper yuv420p format. This is much easier on ppc linux. Lol.

Cheers
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.