327 posts
Location
Julfander Squad Studio
Posted 14 October 2018 - 01:57 PM
This is a project I always wanted to do, and now its finished: a way to convert mp4 files into something I could play in Minecraft. Here is how I did it:
- Convert the mp4 file to a bunch of downscaled pngs using ffmpeg
- Use a lua program to convert these pngs into a big text file containing the images with indexed colors
- Build the biggest monitor, set the text scale to the minimum and change the palette to grayscale.
- Put the big file into computercraft and play it!
This is something you could do in a computercraft cinema, nothing that is fast and easy to do.
I converted the beginning of Coraline because its my favorite movie, just don't tell Focus. This showcase is a bit stuttery because I was recording it. It is nearly two hours long, and it can play it with 5 or so fps.
If you have any interest going through the trouble of creating something like this yourself, just tell me.
Edited on 14 October 2018 - 12:02 PM
6 posts
Posted 16 October 2018 - 09:25 PM
This looks like an amazing project!
I've been thinking for a long time about creating a project like this myself. I just completed a decent note block media player, and my next step was creating a video player with sound support. If you have any guidelines or tips to guide me along my path, that would be highly appreciated.
327 posts
Location
Julfander Squad Studio
Posted 17 October 2018 - 08:36 AM
This looks like an amazing project!
I've been thinking for a long time about creating a project like this myself. I just completed a decent note block media player, and my next step was creating a video player with sound support. If you have any guidelines or tips to guide me along my path, that would be highly appreciated.
I am thinking of adding sound support if I find software that gives me the information I need (Pitch, volume, maybe sound type). Tips on making something like this? Use third party software for anything you can. I used
PngLua to read pngs,
ffmpeg to convert the mp4 into images (this takes some time to find out which parameters you need to change) and so on. Just search the things you need. The only thing you need to write is the a png->your movie format converter and something that plays this file. I recommend doing only the movie player in Computercraft, the rest is easier to do in 'real' lua. Don't try to use a binary format for the movie file, because CCs character set is different it wont work (learnt this the hard way). Just use one character for every pixel and you're good. I didn't worry about performance (at first), and I had no issues. Use a screen buffer (the window api is pretty solid at buffering) so it doesn't flicker. Thats pretty much it! Good luck!
EDIT: I think I will be using
https://www.sonicvisualiser.org/ to get the pitch and volume of the sound of the movie.
Edited on 17 October 2018 - 06:47 AM
7083 posts
Location
Tasmania (AU)
Posted 18 October 2018 - 02:32 AM
There are various programs about the place which can adapt wave-based audio formats (eg WAV, MP3, OGG, etc) to MIDI. From there, it's a relatively simple jump to rudimentary audio playback within ComputerCraft.
Actual wave-based playback isn't possible in the base mod, and I don't believe anyone's made a peripheral mod that could do it, either: closest I can think of would be
OpenFM. That sort of thing doesn't really fit in with the style of the mod.
Don't try to use a binary format for the movie file, because CCs character set is different it wont work (learnt this the hard way).
It sounds a lot like you're using text-mode handles to work with non-text files, in which case you should be using a
binary-to-text encoding method such as base64. Note that the only time it's worth doing something like that is when you're dealing with web handles through older versions of the mod (which only support text mode): the rest of the time, you should simply be using
binary handles instead.
Edited on 18 October 2018 - 12:34 AM
1426 posts
Location
Does anyone put something serious here?
Posted 18 October 2018 - 08:23 AM
Actual wave-based playback isn't possible in the base mod, and I don't believe anyone's made a peripheral mod that could do it, either: closest I can think of would be
OpenFM. That sort of thing doesn't really fit in with the style of the mod.
Computronics' tape drives use a format called "DFPWM", which you can convert .wav files to. We've used this quite a lot on SwitchCraft to
pipe music out.
I believe the speaker/sound card also allow playing arbitrary waves, but the documentation is pretty much only
composed of this gist, so that's a much harder route to go down.
6 posts
Posted 18 October 2018 - 10:23 AM
Actual wave-based playback isn't possible in the base mod, and I don't believe anyone's made a peripheral mod that could do it, either: closest I can think of would be
OpenFM. That sort of thing doesn't really fit in with the style of the mod.
Computronics' tape drives use a format called "DFPWM", which you can convert .wav files to. We've used this quite a lot on SwitchCraft to
pipe music out.
I believe the speaker/sound card also allow playing arbitrary waves, but the documentation is pretty much only
composed of this gist, so that's a much harder route to go down.
I did a bunch of research about this route yesterday. After a long talk on discord with Justyn he helped me demystify the tape drive.
https://forums.compu...4.msg264#msg264Sample code for a downloader (Note it downloads in binary, else you get a white noise)
tape = peripheral.find("tape_drive")
url = "http://DirectLinkToFile.dfpwm")
local response = http.get(url, nil, true) -- THIS IS IMPORTANT
tape.seek(-tape.getPosition()) --Rewind to start
tape.write(response.readAll())
response.close()
tape.seek(-tape.getPosition()
How to easily create a good file:1. Convert ANY type of music to WAV (Sound quality might get decreased depending on format used)
2. Use
LionRay Wav Converter for DFPWM file. (Can be downloaded as a binary and have a user friendly UI)
3. Upload file to file provider (Github, Dropbox, Google Drive)
4. Use the code above where the URL is a direct link.
5. Enjoy!
327 posts
Location
Julfander Squad Studio
Posted 23 October 2018 - 10:17 AM
There are various programs about the place which can adapt wave-based audio formats (eg WAV, MP3, OGG, etc) to MIDI. From there, it's a relatively simple jump to rudimentary audio playback within ComputerCraft.
Actual wave-based playback isn't possible in the base mod, and I don't believe anyone's made a peripheral mod that could do it, either: closest I can think of would be
OpenFM. That sort of thing doesn't really fit in with the style of the mod.
Don't try to use a binary format for the movie file, because CCs character set is different it wont work (learnt this the hard way).
It sounds a lot like you're using text-mode handles to work with non-text files, in which case you should be using a
binary-to-text encoding method such as base64. Note that the only time it's worth doing something like that is when you're dealing with web handles through older versions of the mod (which only support text mode): the rest of the time, you should simply be using
binary handles instead.
I tried it in binary mode and it gave me different numbers for the same character. Why is that?
7083 posts
Location
Tasmania (AU)
Posted 23 October 2018 - 01:38 PM
I don't know, you haven't shown me the input/output/code.
9 posts
Location
Czech Republic , Prague
Posted 12 November 2018 - 12:35 AM
I'm trying to do something like this
Can you write me on discord ? DanyGames2014#9409