Animated JPG for video snaps
-
Hi
I love video snaps but they can take up quite a bit of space, usually way more than the actual roms themselves. I have a few Pi0 handhelds, which dont support snaps very well either due to the low speed.
I have a RS97 handheld with a launcher that supports animated JPG files. I converted all my AVI video snaps to animated jpg (fairly easy task) and the files are between 100-500k each, saving loads of space and far less resource hungry.
Heres a clip:
Anyone clever enough to add this to Emulation Station, way above my ability.
-
Is the convertion from AVI to MJPEG ? At the same bitrate and resolution, I doubt MJPEG is more efficient (smaller size) than a MP4 video, plus you loose the audio.
-
The converted file is massively reduced in terms of quality and has no sound. Probably wouldnt want to view it on a 60" TV but looks extremely passable on a handheld (as you can see from the clip above)
The file itself: https://imgur.com/a/KCpAHoG
834 'video' clips take up just 266MB, same with proper video snaps would be a few GB or more depending on quality
-
I remember sometime ago someone posted a tutorial on how to 'shrink your videos', which consisted of running
ffmpeg
and cutting the video to the first 10 seconds. This looks similar - take a 10 sec video and reduce it to 150 frames and no sound.
Either way, if the file format is MJPEG, you can play it already in EmulationStation -omxplayer
knows how to play them. Have you tried using it ? -
I've checked the files, they are not actually MJPEG, they are JPG. I've looked at what the converter tool does, it uses FFMPEG to extract frames from video, then uses a program called Magick to convert to 128x128 then essentially creates a montage of all the frames into one picture.
The launcher then somehow displays each 128x128 segment to show it as a video.
-
@DynaMight AFAIK the jpeg format ain't supporting animated images (1), so my bet would be that those are either animated gifs, or like mitu suggested videos encoded with motionJPEG. As the extention of a file has nothing to do with its content, what media information do you get from a picture/media viewer for those files?
Edit: If this here is the Magick you used, the the Featurlist states: "Animation - create a GIF animation sequence from a group of images.", so most probably that's what you got.
[1]: And I doubt that it is something like this: JPEG_XL
-
@Ashpool said in Animated JPG for video snaps:
Animation - create a GIF animation sequence from a group of images.",
I think it's actually what's pictured in the image posted - a larger JPEG stitched from individual video frames extracted from the movie. It's like the front-end's author(s) wanted to make their own GIF format, but in a single JPEG.
-
@mitu Well, you are right -> hadn't taken a look at the source file linked 'till now and haven't understood the part about "montage"... astonishing...
And maybe there is a niche for such usecases (as the OP has shown), I can't say.P.S.: There is one thing I am still curious about -> how much difference in filesize between that jpg and an animated PNG, and various Videoformats (h264/h265/MJPEG) created from those 128x128frames (as that would be lossy to lossy in all cases, such a comparision should IMHO be made with/from the (losslessly) extracted image sequence from the source video) there may be? But thats just my curiousity and slightly over the edge of being OT...
-
@Ashpool Here's a little ad-hoc experiment.
I have a 506x480 video (with sound) stored as an MP4, 30 seconds at 30 fps. The size is 1.7M. If I useffmpeg
and- remove sound
- resize to 320x240
- remove video frames so it plays at 5fps
then the resulting video is approx 680 KB. My guess is that using a proper - compressed - video format would yield a size comparable to what this ad-hoc format would produce.
EDIT: Further optimization is definitely possible. Same video, but using a different approach:
- include only the initial 10 seconds (out of 30)
- remove audio
- resize to 320x240
reduces the size to approx 400 KB. If I reduce the fps to half (15fps), it would gain about 70 KB, reducing it to 10 fps makes the video about 300 KB.
-
Yeah I agree with the above. I've been playing also and you can get similar results by re-encoding.
I didnt realise previously how bespoke that animated JPG snap method was, probably not something worth investing in, in most cases! Does yield some pretty good results on an underpowered handheld tho!
Any ideas what the most optimised settings for the Pi0 are? Whenever I've ran video snaps in the past, its really struggled, which is what made my think about the animated JPG method. My original snaps are not excessive, 320x240, sound, files range between 1-2MB each.
-
@DynaMight Did you use the hardware accelerated video player (
omxplayer
) in EmulationStation ? It should be pretty fast with MPEG4 videos. -
Been playing around and yes it does play quite nicely these days. Its been a while since I tried snaps on Pi0's, I think last time I did try it omxplayer caused some weird overlapping issues.
I've managed to get the size down quite a bit. I could probably increase a little as the video file sizes are typically smaller than the boxart! I've settled on 320x240, no sound and 10 seconds. Looks fine on the small screen, usually 10 seconds is enough to get an idea of what the game is like, and the sound can sometimes be a little rough so not an issue losing that. Also limited to 30fps as a lot were 60.
I used ffmpeg with commands: -i input.mp4 -r 30 -s 320x240 -ss 0 -to 10 -an output.mp4
mkdir trimmed for %%a in ("*.mp4") do "d:\ffmpeg\ffmpeg" -i "%%a" -r 30 -s 320x240 -ss 0 -to 10 -an "trimmed\%%a" pause
Created a little batch file and it does them pretty quickly.
Filesizes massively reduced, one collection was 572 games. scraped videos took 1.99GB! trimmed versions took just 137MB
I'm glad I asked a silly question now :)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.