Dead Hackers Society
Encode video from Hatari »

68k Inside

Sommarhack 2024

Silly Venture 2024 SE

How to make 1080p50 Youtube videos from Hatari ST/STe-recordings

Hatari settings

  1. Make sure "Drive led" is off
  2. Set frameskip to ZERO or OFF
  3. Make sure "Crop statusbar" in checked (avoids recording the statusbar)
  4. Set audio frequency to 50066 Hz (STe audio will then be 1:1 in the source material)
  5. Set video codec to PNG (slow, smaller) or BMP (big, faster)
  6. Set Hatari Max window size as:
    For a program in ST-LOW with borders: 416*312
    For a program in ST-LOW without borders: 320*216
    For a program that is sometimes or always in ST-MED with borders: 832*624
    For a program that is always in ST-MED without borders: 640*432
    For a program in ST-HIGH: 640*432

    The reason for extra Y-height is that Hatari includes it's statusbar in the calculation (stupid, but true)


We're going to use two tools, both are linked to in OS X versions, there should be Windows binaries at other places:
  1. Ffmpeg (commandline tool) - MANDATORY
    I've compiled this for my system, if it doesn't run at your place, you need to get it from someplace else
  2. Mpeg Streamclip (GUI tool) - OPTIONAL
    Get it from the Squared 5 site
Ffmpeg is used to crop, pad, scale, re-encapsulate and encode the video that we send to Youtube. Yes it is commandline but it's the only tool I found in a reasonable time that does what I want, with correct nearest neighbor scaling.

Mpeg Streamclip is used to easily cut out start/ending and perhaps unintended pauses in the stream. Start/stop can be done with more complex ffmpeg parameter as well. If you do not need to trim the video, Mpeg Streamclip is not needed.

Encoding the file for Youtube

The encoding is made in a single ffmpeg command, and need different parameters depending on the input video resolution (different crop and padding applied). The scaling of pixels are made with nearest neighbor (no filter) so pixels are perfect without any blur or fuzzyness. Scaling is also only made with integer, so they are only zoomed up 2x, 3x, 4x, 5x and so forth. That ensures no odd-sized pixel that will happen.

So, here are the commandlines to use, they are a single line but the browser will show as several.
  1. ST-LOW 320*200 Hatari video
    ffmpeg -i hatari.avi -vf "scale=1600:1000, pad=1920:1080:160:40:black" -sws_flags neighbor -vcodec png -acodec copy

  2. ST-LOW 416*276 (incl. borders) Hatari video
    ffmpeg -i hatari.avi -vf "crop=400:270:0:6, scale=1600:1080, pad=1920:1080:160:0:black" -sws_flags neighbor -vcodec png -acodec copy

  3. ST-MED/ST-HIGH 640*400 Hatari video
    ffmpeg -i hatari.avi -vf "scale=1280:800, pad=1920:1080:320:140:black" -sws_flags neighbor -vcodec png -acodec copy

  4. ST-MED 832*552 (incl. borders) Hatari video
    ffmpeg -i hatari.avi -vf "crop=800:540:0:12, scale=1600:1080, pad=1920:1080:160:0:black" -sws_flags neighbor -vcodec png -acodec copy

The finished file will be lossless and suitable for storage if you need it at a later time. It's a good source for any video site.

Trim start/end of the video using Mpeg Streamclip

This part is only if you want to trim the start/ending or cut out uninteded waiting in the middle of the video. If that's not needed, stop here.

The 1080p .mov-file is ready to be loaded into Mpeg Streamclip. Once there, you set start of the movie with "i" and end of the movie with "o". When both are set, select "File/Save As" and save it with a suitable filename. Voila, we now have a trimmed video file. It won't re-encode as our video file are single PNG-frames. It's good to remember that if you want to make a H.264 (or other distributable format) trim it first while the frames are separated.

You can also use ffmpeg with the -ss and -t parameters, see the ffmpeg manual for further details.

That's all folks!
© 1994-2024 Dead Hackers Society Contact: Anders Eriksson