Schillsaver
Schillsaver copied to clipboard
Usage of color to store more bytes in a frame
Couldn't colored pixels make it possible to store more bytes in a pixel? At the moment, it's just 0 or 1, but a color RGB value consists of 4 bytes. Wouldn't that make more sense?
Yup, it's been a long-time goal to move away from FFMPEG and implement custom en/decoders that handle multi-colored pixels. However, I wasn't able to find any good Java libraries to help handle reading/writing frames to/from an MP4 file when I last checked.
If you have any suggestions, I'm definitely open to trying things out again
What's so bad about FFMPEG? Does it not support colored pixels?
It's not that there's anything wrong with FFMPEG, but Schillsaver's currently written as a GUI wrapper around the FFMPEG executable. There's an encoding, and a decoding, command that handles all of the heavy work at the moment.
ffmpeg.exe -f rawvideo -pix_fmt monob -s 10x10 -r 60 -i inputfile.zip -vf scale=iw*10:-1 -sws_flags neighbor -c:v libx264 -threads 8 -loglevel verbse -preset veryfast -y outputfile.mp4
Note: This encoding command may be a little off, I rewrote it after quickly glancing at the code.
What I'd like to do is read-in the input file bit-by-bit, generate an in-memory frame (e.g. BufferedImage or VolatileImage), pass the in-memory frame to FFMPEG, and have FFMPEG append it to the output file. Those last three read-create-append steps would be run continuously, until all bits have been read.
From what I recall, and this was a year or two ago, the libraries that I tried mostly failed at appending the generated frames to an MP4 file or couldn't read the file frame-by-frame.
I could generate thousands of frames, save them to disk, and use the FFMPEG executable to concatenate them together into an MP4 file (and a similar process in-reverse when decoding), but that would be a considerable amount of HDD/SSD IO and I don't think it's practical for large files
I think it could be worth trying to either change the source code of FFMPEG and recompile it, so that it is accessible with a JNI class and so that you can give it an array of integers or something by adding a function that is similar to the one that reads an input file.
Or you can maybe make another native tool that uses FFMPEG as a library and which calls FFMPEG's functions directly (for example: http://www.ffmpeg.org/doxygen/trunk/api-example_8c-source.html ) and embed it with JNI.
But then I would always recommend to do the calculations in that native tool too, because that could be much faster than Java and its BufferedImage
Wow. I was just about to open an issue about using color for more data and here it is!! LOL