MacFlim flim player source code and utilities

Related tags

Utilities macflim
Overview

MacFlim Video player source code

Please do not barf on code quality. It was not in releasable state, but people wanted to use it. You may even be one of those people. Hi!

Content

flimmaker : A C++ binary that can generate flim files for Macintosh playback

flimutil : A C utility that can manipulate flim files

MacFlim Source Code.dsk : A dsk file with the source code of the client application and the full development environment.

How to compile the tools to generate flims on linux?

Just use make

$ make
c++ -O3 flimmaker.cpp -o flimmaker
cc -O3 -Wno-unused-result  flimutil.c -o flimutil
$ 

And on other platforms?

Use make, or make adjustment and do a pull request. I don't want dependencies, so be as simple as possible.

What is flimmaker? How do I use it?

flimmaker is the C++ tool that generates flim files. It performs the dithering on grayscale images and generate the "proprietary" files for playback. flimmaker runs on a set of 512x342, 8 bits grayscale pgm files. See further on how to generate such files using ffmpeg.

Syntax is:

flimmaker [-g] --in <%d.pgm> [--from <index>] [--to <index>] [--cover <index>] --out <file>

-g : enable debug information (mostly info on progress)

--in <pattern> : filename pattern for the pgm files that contains a * '%d' that will be replaced by an incrementing index. Yes, if you put '%s', you'll crash.

--from <index> : the index we take the first image from. Default to 1

--to <index> : the last index of the frame to be included (the number of frames is to-from+1). flimmaker will stop if it cannot read a file, so you can safely pass a large number here. Default to basically infinity.

--cover <index> : the frame index of the cover. If specified, flimmaker will generate a set of 24 pgm images, named cover-000000.pgm to cover-000023.pgm in the current directory. Those images can be used to generate an animated gif of the movie. Default to 1/3rd of "to" and "from". If outside of the movie, there will be no cover generated.

-- out <file> : the name of the flim file to generate

The input is supposed to be 24 frames per second (ie: every frame represent 1/24th of a second)

The generated flim will always contain the 4 standard streams:

  • 256x171x12 fps (only half of the input images are used)
  • 256x171x24 fps
  • 512x342x12 fps (only half of the input images are used)
  • 512x342x24 fps

What is flimutil? How do I use it?

flimutil is a C tool that reads a flim and check/display the content. It is a separate tool for now, as I am still evaluating if I want to bloat flimmaker or not with additional features (like cutting flims, concatenating flims, extracting streams, upgrading to new formats, etc).

Can you walk me in the process of creating my own flim?

Sure. To follow this tutorial, you will need the following packages:

  • youtube-dl => (optional) retreive youtube sample movie

  • mediainfo => (optional) find source material frame rate

  • ffmpeg => generate pgm images for flimmaker

  • ImageMagick => (optional) generate gifs of you flim

Create a directory to store all the temporary files

mkdir sample && cd sample

Get the source media (youtube example)

Remember that you can use youtube-dl -F to list formats. -f 22 is not always the right one.

youtube-dl -f 22 https://youtu.be/MiRtNavqfpg -o sample.mp4

Check the framerate of the media (useful later)

mediainfo sample.mp4

...
Video
...
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
...


Audio
...
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
...

In this example, the source contains 30 image per second. You will need to decide if you want to play it slower, but with all the images, or if you prefer skipping images.

Extract the part you want to encode

As files are just huge for now, you probably want to select a minute or so that you are intersted in.

ffmpeg -v warning -stats -y -ss 00:00:02.100 -t 00:00:30 -i sample.mp4 extract.mp4

Rescale it to 512x342

The command is a testament to the exterme user friendliness of ffmpeg.

ffmpeg -v warning -stats -y -i extract.mp4 -vf "scale=(iw*sar)*max(512.1/(iw*sar)\,342.1/ih):ih*max(512.1/(iw*sar)\,342.1/ih), crop=512:342" 512x342.mp4

Extract all the grayscale images

The 30 below is the original framerate. Why do we have to pass it is something I cannot understand while sober. We then ask ffmpeg to extract 24 images every second. Note: the first image is 1, not 0.

ffmpeg -v warning -stats -y -r 30 -i 512x342.mp4 -r 24 source-%06d.pgm

Execute flimmaker on the images, to generate the flim

The output of flimmaker is pretty terse for now, and the -g option doesn't do much more yet.

../flimmaker --in "source-%06d.pgm" --out sample.flim --cover 116

Stopped read at [source-000735.pgm]
Added 13 frames
Stopped read at [source-000735.pgm]
Added 6 frames
Stopped read at [source-000735.pgm]
Added 13 frames
Stopped read at [source-000735.pgm]
Added 6 frames

The "stopped read" message indicates that flimmaker didn't find the image 735 and assumed (correctly) that the flim should ends at 734. You can also use --from and --to to control which part you want the flim to be created from (in which case you would extract a larger part of the source media and manually search for the first and last images you want you flim to include)

flimmaker generates everything in batches of 20, for internal reasons that are linked to playback. For 24fps streams, if the source material is not a multiple of 20 frames, it will duplicate the last frames to generate an integral number of 20 frames blocks. For 12fps streams, it will duplicate the last frames if the total source if not a multiple of 40.

The "added nn frames" message indicates that it added frames at the end. You can tweak the extract duration if you want to be "perfect" (the '-t 00:00:30' of the extract part)

Check that the flim is correct

../flimutil sample.flim

should display:

STREAM COUNT: 4
  #0 (0/0) 256x171 12.000 fps
           380 frames, starting at 108, length 2079360
  #1 (0/0) 256x171 24.000 fps
           740 frames, starting at 2079468, length 4049280
  #2 (0/0) 512x342 12.000 fps
           380 frames, starting at 6128748, length 8317440
  #3 (0/0) 512x342 24.000 fps
           740 frames, starting at 14446188, length 16197120

Generating a static cover gif

This uses ImageMagick to create a simple gif, suitable for insertion in web pages.

convert cover-000000.pgm sample-poster.gif

Note: if you plan to get this image on your vintage mac, I suggest you generate a tga file and open it with Photoshop 1.0.7. For web display, you can also choose to generate png images. Note that you absolutely want to avoid lossy compression, as black and white dithered images are a worst case for lossy compression.

Generating the animated cover gif (the one I use on macflim.com)

convert -delay 5 -loop 0 "cover-*.pgm" sample.gif

Generating an mp4 identical to the flim

All the 512x342 images have been generated by flimmaker in the current directory, so you can use ffmpeg to create a mac-like movie.

ffmpeg -y -framerate 24 -pattern_type sequence -start_number 1 -framerate 24 -i "out-%06d.pgm" -s 512x342 sample.flim.mp4

Generating an mp4 flim suitable for youtube upload

If you want to update a flim to youtube with maximal quality (without filming the flim), you can use this command to generate something high quality that youtube will not distort, and get a result similar to https://youtu.be/xUCUK2k_hjk (choose HD in youtube, or the compression kills everything)

ffmpeg -y -framerate 24 -pattern_type sequence -start_number 1 -framerate 24 -i "out-%06d.pgm" -filter:v pad="in_w:in_h+90:0:-45" -s 1280x1080 sample-hq.flim.mp4

Cleanup

$ rm *.pgm extract.mp4 512x342.mp4
$ ls -l
total 240860
-rw-rw-r-- 1 fred fred  30643308 avril  3 14:00 sample.flim
-rw-rw-r-- 1 fred fred  18182043 avril  3 13:39 sample.flim.mp4
-rw-rw-r-- 1 fred fred    516493 avril  3 13:36 sample.gif
-rw-rw-r-- 1 fred fred  52392940 avril  3 13:47 sample-hq.flim.mp4
-rw-rw-r-- 1 fred fred 144868275 avril  1 16:19 sample.mp4
-rw-rw-r-- 1 fred fred     21573 avril  3 13:36 sample-poster.gif
$

sample.flim : the flim you can play on the real hardware

sample.flim.mp4 : exactly the same thing, but that you can play locally to check. No suitable for video platform, because of the Mac aspect-ratio and the low quality settings.

sample.gif : a short animated poster of you flim

sample-hq.flim.mp4 : the flim in high quality and good aspect ratio for sharing

sample.mp4 : the original source material

sample-poster.gif : a simple black and white poster

Do I really need to type all that?

No, if you already have a 512x342 24fps grayscale mp4 that you want to flimize, you just need to execute the "Extract all the grayscale images" and "Execute flimmaker on the images, to generate the flim" commands, which, at their simplest expressions are:

ffmpeg -r 24 -i 512x342.mp4 -r 24 movie-%06d.pgm

(change the first 24 to your source framerate)

and

flimmaker --out myflim.flim

(because 'movie-%06d.pgm' is the default for the '--in' option)

Just remember to execute them in a temporary directory...

Where are the code comments?

Release or comments. Had to choose.

Why templates?

It sounded like a good idea in the beginning, and I was tired.

Why so many hard-coded behaviors?

See above.

Oh, I see that there is also the Mac application source code, can you tell me more about it?

Sure. First, it is absolutely not fit for release, but again, people manifested interest, so here it is, in all its ugly glory.

Why a .dsk file?

Well, having the files on the host machine would make things difficult for the Think C project and the Resource file, which cannot be represented easily on a non-Mac file system. I opted for a completely vintage approach, and the content of the dsk is what you could find on a development environment of the late 80s.

I also wanted to have something turnkey, you don't have to know anything about those things to start playing with the source code.

Can you explain me what I will find on the dsk file?

Yep:

A universal system 6.0.8. This makes the dsk file bootable on a real mac, or on minivmac (which I use for development).

A 'src' directory, containing the THINK C project, the source code, including the resource file, release README documents, and a sample flim for development purposes.

THINK Reference, a very handy tool containing all the reference you need to toolbox routines.

Super ResEdit 2.1.3, the resource editor, for hacking the resource file.

3 support applications, included for testing purposes (testing the export and copy-paste functions): MacPaint 1.5, AdobePhotoshop and MacWrite 4.6

TeachText, to edit and distribute the README documents.

ImportF1 and ExportF1, to enable easy copy in and out minivmac

THINK C, the complete C development environment

You mean I can build the app myself?

Yep. Boot the .dsk drive, go in the 'src' folder, double-click on the MacFlim project, choose "Project/Build Application...", select an output directory, and here you go.

Anything else?

Please don't change and distribute it too widely, it is going to be difficult to collaborate on a vintage Mac app (to be honest, I still have trouble understanding how to do it in a productive way). I'd rather centralize the version, and make sure that there aren't too many different and confusing versions around.

I also plan major rewrites and features, so consider this a preview, not a release.

Any other things?

If you do something, or publish stuff, I'd love to be aware, so send me a pointer either to fstark on m68kmla (https://68kmla.org/forums/profile/20641-fstark/), or on my youtube channel (https://www.youtube.com/channel/UCotU6vnCI9H4YUEopzwDjRQ) or my reddit account (https://www.reddit.com/user/frederic_stark/).

Or better, @fredericstark on twitter (https://twitter.com/fredericstark).

Issues
  • Encoder does not compile on MacOS 10.15.3 due to lack of std::popcount

    Encoder does not compile on MacOS 10.15.3 due to lack of std::popcount

    Hi!

    I'm trying to compile the encoder using make on MacOS 10.15.3 (also tried 10.13.1). Make simply errors out with "./framebuffer.hpp:260:27: error: no member named 'popcount' in namespace 'std'; did you mean '__popcount'?".

    I tried updating to Make 4.3 (from the 3.81 shipped with MacOS). Unfortunately it did not help.

    Could you perhaps share a precompiled version of the encoder?

    Thanks (this project is beyond cool!)

    bug fixed encoder 
    opened by Aeroform-se 8
  • Unable to play flims

    Unable to play flims

    The original sound-less MacFlim works without issue on my SE/30.

    I tried two different binaries of the sound-capable version without success.

    1. One version is on the .dsk image at GibHub (the one that supports library view)
    2. The other version was from the website (much simpler version that only has an open flim dialog box).

    The .dsk Github version opens and there is a soundless Matrix flim also on the .dsk file which plays, however when I try to open any of the other sound-enabled flims downloaded from the website (I tried various SE/30 and the Plus flims) the application indicates there are too many streams (max 10) and the cursor disappears (I can still interact with the menus etc. and quit the application).

    The simpler version downloaded from the macflim website just crashes with an unimplemented trap error when I try to open a flim.

    Neither application shows prior flims in the open dialog box (I'm thinking this is by design).

    Pertinent notes: SE/30 has a 50mhz '030 accelerator and 68MB of RAM.

    Love the project and the humour sprinkled through the all elements of MacFlim. I am hoping to get it working so I can make a film about cycling to watch on my SE/30.

    fixed website 
    opened by superjer2000 5
  • Add support for Mac Portable playback of 512x342 flims

    Add support for Mac Portable playback of 512x342 flims

    (original title was: "Version 1 (No Sound) works, but Version 2 (with sound) does not work on Mac Portable")

    Hi there!

    Just wanted to leave a suggestion - though I understand that this project is targeted towards Compact Macs, the original version 1 (soundless) player does seem to work on the Macintosh Portable (68000), however, the second version of the player (with sound) does not work - the image is corrupted. You can slightly make out what is on screen, but its distorted and looks like there are 6 parts of the film overlapping each other. Sound works fine, though which is great!!!

    See attached for the two versions of the player.

    Hope you can implement support for the Macintosh Portable (and early Powerbooks) into the sound version! Would be amazing to watch a show with sound on my Macintosh Portable!!

    Keep up the amazing work!

    Cheers,

    • Retropaq
    • www.retropaq.com

    Version 1.0 with no sound: image0 (1)

    Version with sound: IMG_0117

    low severity fixed player 
    opened by MacPortableFan 5
  • Add support for 720x364 and 608x431 resolutions for MacWorks

    Add support for 720x364 and 608x431 resolutions for MacWorks

    MacWorks is a software package that allows an Apple Lisa to function as a Mac Plus with a larger screen.

    In its stock configuration, the Lisa's screen has a resolution of 720x364 with a 2:3 pixel aspect ratio (pixels are 1.5 times taller than wide; the video would need to be stretched 1.5x horizontally or shrunk 0.666...x vertically to appear correctly).

    There was an after-market modification available that gave the screen a resolution of 608x431 with square pixels. In this configuration the Lisa is called the Macintosh XL.

    enhancement help wanted player 
    opened by RebeccaRGB 3
  • MacFlim Player sometimes leaves buzzing sound behind after quitting

    MacFlim Player sometimes leaves buzzing sound behind after quitting

    At least in mini vMac, I haven't tried on real hardware, quitting the player by clicking results in a buzzing sound that persists until shutdown. Probably need to clear out the audio buffer?

    help wanted player cannot reproduce 
    opened by RebeccaRGB 3
  • Out of memory error

    Out of memory error

    HTR: Launch MacFlim Play a flim Press 'd' to go in debug mode Free memory is displayed Click to abort Play same flim again

    Expected result: Numbers are identical

    Result: A few hundred bytes are missing

    opened by fstark 1
  • Playback block size needs to be dynamic and configurable

    Playback block size needs to be dynamic and configurable

    Block size needs to be as high as possible for playback. Currently it is set at 10K for "minimal" machines (Mac XL and 128K), but should be dynamic (50% of availaible memory minus some spare, with a max to 300K and a preference to force it).

    enhancement player 
    opened by fstark 1
  • Support silent flims

    Support silent flims

    Audio should not be mandatory, so silent movies / slideshows would get more byterate and a better display quality.

    Player needs to be adapted to skip sound generation.

    enhancement low severity fixed player encoder 
    opened by fstark 1
  • Half-rate option doesn't work

    Half-rate option doesn't work

    Half-rate has been lost in refactoring, making all non-se30 flims worse.

    Need to implement some sort of frame skipping/fps ratio divider so "half" is not the only option.

    bug fixed encoder 
    opened by fstark 1
  • Garbage on screen when flim has small stable black areas on top of mostly white background

    Garbage on screen when flim has small stable black areas on top of mostly white background

    How to reproduce:

    Have a 60fps video that starts with a mostly white image with large black patches, and play on real hardware.

    Result:

    The black patches contain large white patches.

    Expected result:

    Normal black is black

    bug fixed player 
    opened by fstark 1
  • User input passed to printf pattern should be sanitized

    User input passed to printf pattern should be sanitized

    Description:

    Pattern specifications from the command line are passed to printf without any sanitization, leading to crashes.

    How to reproduce:

    ./flimmaker '%s.pgm'
    

    Result:

    Segmentation fault (core dumped)
    

    Expected Result:

    Empty movie or user-friendly error message.

    bug wontfix low severity encoder 
    opened by fstark 1
Releases(v2.0.8)
  • v2.0.8(Apr 8, 2022)

  • v2.0.7(Mar 8, 2022)

    Pre-release of MacFlim 2.0

    Fixes since 2.0.6:

    • Added debug menu (use option-preferences)
    • Cleaned up flim names when added (removal of suffixes, etc)
    • 128k flims are now correctly identified (after being re-added to library)
    • Success in checking flim checksum is confirmed by a panel
    • Success in creation of self-play flims is confirmed by a panel

    Format: 800K dsk file

    Source code(tar.gz)
    Source code(zip)
    Mac.Flim.2.0.7.dsk(800.00 KB)
  • v2.0.6(Mar 6, 2022)

  • v2.0.5(Mar 3, 2022)

    Pre-release of MacFlim 2.0

    Fixes since 2.0.4:

    • fixed infine loop in playback when no selected flims are playable
    • fixed nasty random memory crash (frequent on larger displays)
    • prevented rendering large films on small screen
    • fixed line codec
    • proper use of "se" tag in library
    • better error messages when flim can't play

    Format: 800K dsk file

    Source code(tar.gz)
    Source code(zip)
    Mac.Flim.2.0.5.dsk(800.00 KB)
  • v2.0.4(Mar 2, 2022)

Owner
Fred Stark
Fred Stark
cavi is an open-source library that aims to provide performant utilities for closed hierarchies (i.e. all class types of the hierarchy are known at compile time).

cavi cavi is an open-source library that aims to provide performant utilities for closed hierarchies (i.e. all class types of the hierarchy are known

Baber Nawaz 5 Mar 9, 2022
mpiFileUtils - File utilities designed for scalability and performance.

mpiFileUtils provides both a library called libmfu and a suite of MPI-based tools to manage large datasets, which may vary from large directory trees to large files.

High-Performance Computing 126 Jun 1, 2022
Isaac ROS common utilities and scripts for use in conjunction with the Isaac ROS suite of packages.

Isaac ROS Common Isaac ROS common utilities and scripts for use in conjunction with the Isaac ROS suite of packages. Docker Scripts run_dev.sh creates

NVIDIA Isaac ROS 40 Jun 10, 2022
Panda - is a set of utilities used to research how PsExec encrypts its traffic.

Panda Panda - is a set of utilities used to research how PsExec encrypts its traffic. Shared library used to inject into lsass.exe process to log NTLM

Pavel 10 Dec 28, 2021
Dead by Daylight utilities created while researching

DeadByDaylight Research material and PoC for bugs found during the reversal of the game Dead by Daylight. All information provided is for educational

Layle | Luca 11 May 1, 2022
Utilities to extract secrets from 1Password

1PasswordSuite Blog https://posts.specterops.io/1password-secret-retrieval-methodology-and-implementation-6a9db3f3c709 1PasswordExtract This .NET appl

Dwight Hohnstein 94 Jun 17, 2022
personal organization utilities

orgutils: Personal Organization Utilities orgutils are a set of utilities for personal and project organization. Each program has

Seninha 5 Dec 8, 2021
A combined suite of utilities for manipulating binary data files.

BinaryTools A combined suite of utilities for manipulating binary data files. It was developed for use on Windows but might compile on other systems.

David Walters 3 Sep 29, 2021
Utilities for use in a DPP based discord bot

DPPUtils NOTE: This repo is in development, use these utilities at your own risk Numerous utilities for use in your DPP bot. List of Utilities Youtube

Daniel Wykerd 6 Apr 3, 2022
Header-only lock-free synchronization utilities (one writer, many readers).

stupid Header-only lock-free synchronization utilities (one writer, many readers). No queues Base functionality The base functionality of this library

Colugo 13 Jun 9, 2022
provide SFML Time utilities in pure C++20, no dependencies

SFML-Time-utilities-without-SFML provide SFML Time utilities in pure C++20, no dependencies Example int main() { Clock clock; Sleep(1000);

null 1 Apr 28, 2022
Source code for Amiga intro Planet Disco Balls

Planet Jazz - Planet Disco Balls (Amiga A500 Intro Source) What is it? This is the 68000 assembler source code for the Planet Jazz "Planet Disco Balls

Jonathan Bennett 20 Jun 17, 2022
vs herobrine fnf source code

Friday Night Funkin' - Psych Engine Engine originally used on Mind Games Mod, intended to be a fix for the vanilla version's many issues while keeping

indigoUan 3 Jun 21, 2022
Translates binary information (images, fonts, shaders) into C++ source code.

Binary bakery ?? Translates binary files (images, fonts etc.) into C++ source code and gives access to that data at compile- or runtime. There are dif

Sebastian Werhausen 126 May 28, 2022
Fast regular expression grep for source code with incremental index updates

Fast regular expression grep for source code with incremental index updates

Arseny Kapoulkine 247 Jun 19, 2022
runsc loads 32/64 bit shellcode (depending on how runsc is compiled) in a way that makes it easy to load in a debugger. This code is based on the code from https://github.com/Kdr0x/Kd_Shellcode_Loader by Gary "kd" Contreras.

runsc This code is based on the code from https://github.com/Kdr0x/Kd_Shellcode_Loader by Gary "kd" Contreras and contains additional functionality. T

null 23 Jun 15, 2022
A tool for use with clang to analyze #includes in C and C++ source files

Include What You Use For more in-depth documentation, see docs. Instructions for Users "Include what you use" means this: for every symbol (type, func

null 2.8k Jun 21, 2022
WinMerge is an Open Source differencing and merging tool for Windows.

WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.

null 3k Jun 26, 2022
An attempt to restore and adapt to modern Win10 version the Rootkit Arsenal original code samples

rootkit-arsenal-guacamole An attempt to restore and adapt to modern Win10 version the Rootkit Arsenal original code samples All projects have been por

Matteo Malvica 44 Apr 12, 2022