Youtube on an iBook G4

2024-03-20 | [retrocomputing] [powermac] [mac]

My bicycle project is still going by the way. I mainly use it to sit and watch videos - the only guilt free way to do so because I'm powering it myself. Even so, I've started to notice a problem - it's starting to get too easy. While the supercapacitor bank makes it so you can pedal harder or faster and still collect all the energy you produce, eventually things will balance out and you will only produce the energy that you need, which in the case of my original laptop solution is only about 20-40 watts.

To make it harder, I need to attach something that uses more power. A practical person might attach something useful, like a lamp, but in my case, I decided to try using an older and less efficient computer, so that more power will be required to watch videos.

The Apple iBook G4 laptop I have is near the end of the line for Apple's venture into the PowerPC architecture, a couple years before they switched to Intel. It's from about 2004, making it 20 years old now. But, it would have been about 2 years old when Youtube was launched, so I'd say it would be somewhat contemporary, and therefore should be able to play videos. Not modern youtube mind you, as it only has 1.25Gb of ram, and a 1.2Ghz single core processor, and is from a time before a lot of the way the web currently works was even implemented. I did upgrade to an SSD though (mSATA SSD with PATA adapter), so at least now there is plenty (256 vs 80Gb) of storage.

It can run Mac OS X 10.5.8 Leopard, the last version released for PowerPC and the first version of MacOS I ever used.

The rest of this is just going to be a list of the things I looked at.

OS X Sorbet Leopard

Did I say 10.5.8 was the last version? Yes, it is the last official apple version. It is also known to be decently slower than OS X Tiger. A few years ago there was a community project that brought together various bits and pieces of Snow Leopard betas, optimizations, and other community projects to make a "10.5.9" Leopard release. It's got some good stuff, and I've found video playback on it, whether in QuickTime, the updated Safari browser, or inside the Flash plugin, to be smoother and use a bit less CPU, so I've I've mostly been using this OS.

Youtube.com

Did not think this would work at all, but in Sorbet Leopard's "Safari 11" it sort of does. Loading youtube.com goes into the mobile version of youtube, and starts to play videos in 360p, which is a little too much to handle. Video freezes up about every 2 seconds, page is slow and unresponsive. Practically unusable.

Invidious

Invidious is one of may "alternative front ends" which is focused on "privacy" by not being the full fat youtube app or webpage loaded with its trackers. Instead, it just used youtube's own endpoints, the same ones that some mobile apps and youtube-dl get, to get the video. Comes in a docker container, or you can install it natively. Seems to default to 720p video, which freezes up the whole system on the iBook. You might get a few frames every few seconds. Unusable.

TenFiveTube

This is a slightly older project (2018-2020) which is a specialty app for PowerPC macs. As best I can tell, it's another web browser (with ? optimizations) that loads the youtube page. Results are about the same as loading youtube.com in Safari - no better. This project seems not to have updated in a while, so maybe youtube has changed since then and it doesn't work as well as when this project went online.

WarpStream

Warpstream is a rather interesting project which effectively has stored a few hundred thousand videos and pre-converted them into smaller renders so they will play on older hardware. It works, but 1) it doesn't have all the videos from youtube, and 2) you have to access it through a proxy server, effectively cutting you off from the greater internet. Here's a video explaining it better.

yt2009

I was pretty impressed with this one. It's a project meant to recreate the look and feel of youtube circa 2009. I used the docker version following the instructions, and it works straight away. It will give you either the HTML5 or Flash version of the player (you can also force the flash player on and use different versions). The players are (or at least seem to be) mildly patched real versions of the ones youtube used at that time. This works really pretty well, I was surprised. You still get 360p video from youtube (any maybe higher quality versions, but the iBook can't show those reliably). The playback is pretty choppy at the beginning, but smooths right out once the full file is loaded (remember when youtube used to load the whole video into memory?). Seems to be about the same in Flash or HTML5 on the iBook. Excellent results from 2009-era length videos; longer ones sometimes have some trouble. For sure the most polished experience of the lot. Video playback is quite smooth, but you lose the ability to do much else on the system while playback is happening. This is definitely the method I'd recommend for a get-set-up-and-go type of infrastructure.

my own archives

Nobody would archive everything their subscriptions upload to youtube, would they? Well, if I did do such a thing, then I already have a bunch of videos on my own local server, and if that's the case why should I re-stream the video again in an alternative youtube frontend? But, they are in 720p. On a modern browser, you can just click on a link to the file, and it will start playing in a new page almost instantly. 720p is too much for the iBook to handle so, I would have to re-render them.

I did spend a while looking for what video codec would be handled the best on the iBook. At first, I though about using a flash video player to play an flv file, just like I (vaguely) remember from back in the day - like jwplayer. For experimenting, I messed around with ffmpeg and converted to and FLV file first, and then went to look for players. One I tried was OS FLV PLayer; it worked with results slightly worse than yt2009. The playback is still slideshow-like at the beginning before the file is fully loaded, but once loaded it's pretty ok. The big problem here is that the OS FLV player puts up a big LOADING... indicator over the whole video as it loads, which on a wireless G connection, can take some time. This method could probably be made to work pretty well with some tweaking, but at this stage yt2009 is better.

mov

Then, I found out that the Sorbet Safari could embed MOV videos. The consensus on best codec seemed to be MPEG4 Part 2 / XVID, so that's what I went with. I also tried H264 and an mp4 container, which worked about the same, if not slightly worse, but I stayed with MPEG4. I could also downgrade to 240p video to get a bit better framerate (this seems way more important that image quality to me). Audio didn't seem to affect things much, I copied the AAC it came as. Edit: youtube seems to often be breaking format 22, which comes as h264/aac/mp4, and now I have to get it in a webm container with different codecs. So now I have to convert to aac instead of copy.

What we're trying to find here is a balance between video quality, framerate and resolution, which will play on the iBook acceptably while downloading (so you can't take up all the CPU). I eventually found that 480x250 resolution video at 800k bitrate worked well for this purpose.

I then chatGPT wrote this little PHP script to accept a link to the mp4 (downloaded) version of the video, convert it with ffmpeg, and then present the converted mov file. (and if you don't give it a link, you get rick rolled!).

The first time you load it, it will start ffmpeg in the background. Once automatically refreshed, it sees the .mov file already exists, and looks for the ffmpeg process still running on that file. Once the process is not found, assuming completion - it embeds the file into the page using the browser player. Ffmpeg does seem to run pretty quick, even on my 10 year old 4 core old main server which I run everything on - a 15 minute video takes less than a minute to complete, after which it will not need to be converted again.

<html>
<head><meta charset="UTF-8"><link rel="stylesheet" href="/bs.css">
<title>iBook G4 video converter</title>
</head>
<body>
<center><h3>iBook G4 Video</h3></center>
<?php
$filename = 'Rick Astley - Never Gonna Give You Up (Official Music Video) [dQw4w9WgXcQ].mp4';
if(isset($_GET['file'])){$filename = $_GET['file'];}
    $sourcePath = '/mnt/diskC/yt-mini/videos/' . $filename;
    $movFilename = pathinfo($filename, PATHINFO_FILENAME) . '.mov';
    $destinationPath = '/mnt/diskC/yt-mini/x/g4/' . $movFilename;
    if(file_exists($destinationPath)) {
        $filesize = filesize($destinationPath) / (1024 * 1024); //get file zise in Mb
        $search = substr($filename, -16); //filenames always end in [dQw4w9WgXcQ].mp4, so we should be able to look at this 
        $currentPID = getmypid();
        $command2 = "pgrep -af 'ffmpeg.*$search' | grep -v $currentPID";
        $runcheck = shell_exec($command2);
        if(!empty($runcheck)){
          echo '<center> Converting.... | '.round($filesize, 2) .' MB</center><br>';
          //echo $runcheck;
          echo '<meta http-equiv="refresh" content="2">';
        }else{
          echo '<center><a href="g4/'.$movFilename.'">'.$movFilename."</a> | ".round($filesize, 2) . " MB</center><br>";
          echo '<center><div style="display: flex; justify-content: center; align-items: center; height: 75vh;">
                <video width="480" height="250" controls>
                <source src="g4/' . $movFilename . '" type="video/quicktime">
                </video>
                </div></center>';
        }
    } else {
        $escapedSourcePath = escapeshellarg($sourcePath);
        $escapedDestinationPath = escapeshellarg($destinationPath);
        $ffmpegCommand = "ffmpeg -i $escapedSourcePath -vf scale=480:250 -c:v mpeg4 -b:v 800k -c:a aac $escapedDestinationPath > /dev/null &";
        exec($ffmpegCommand);
        echo '<center>Conversion process started....</center>';
        echo '<meta http-equiv="refresh" content="5">';
    }

?>
</body>
</html>

This provides the best playback I have yet seen. Once converted and the file is ready, the video starts playing the moment you click on it, at full framerate - clearly before the full file has loaded into the iBook's ram.

I also tried this on regular Leopard, and it's Safari 5 can also embed the video. However, it stutters a bit at the beginning until the full file is loaded. The browser also does not seem to support the same CSS as what I had for the Sorbet version. The biggest noticeable thing here is that if you zoom in the page at all, the framerate drops dramatically! It seems that a Leopard era install cannot cope with the extra rendering capacity of enlarging the video. You can zoom in with no problem on the Sorbet version though, and I do set the embedded video zoomed in to 360p just so the screen isn't so empty.

Also, since the converted file is a native Apple MOV, QuickTime loads and plays it just fine, even better than what the browser embeds (in both Leopard and Sorbet). But, I haven't found a way to just click a link and have it open in QuickTime, so I'll just go with the embedded version for now.

Conclusions

... well, if you can call it that. For the forseeable future, I'll be using my iBook G4 running Sorbet Leopard to watch videos as I power it from my bicycle. I'll use my local ffmpeg conversion script to watch those videos which I already have archived, and yt2009 for everything else.

Video quality is not the best when compared to any modern youtube watching solution (240-360p), and bitrate can be a bit cramped, but it does work reliably, and is perfectly suitable for bicycle-riding for an hour or so.

Plus it keeps a working retrocomputer off the shelf and in use. In this case - especially because it uses more power than a typical laptop.

edit 1

This seems to make videos that stay in audio sync a bit better on the ibook:

$ffmpegCommand = "ffmpeg -i $escapedSourcePath -vf scale=480:250 -c:v mpeg4 -b:v 700k -r 25 -c:a mp3 -b:a 96k $escapedDestinationPath > /dev/null &";
comments | Alnwlsn 2024