create videos?

A forum about the Hatari ST/STE emulator - the current version is v1.4.0

Moderators: simonsunnyboy, thothy, Moderator Team

create videos?

Postby Gunstick » Thu Jul 30, 2009 4:09 pm

Hi
running linux here.

I try to create videos but hatari only has single frame save which creates a gigantic amount of files (I had to patch the source to allow for more then 1000 pictures)
And it does not guarantee that each and every frame is saved.
What I'm looking for is a mode where the emulator primaly saves a video with synchronized sound and every frame equals a picture in the video.
So that should render 50 or 60 or even 72 fps
There is no need to do fancy compression, a simple mjpeg with wav would be nice.

I could not sort out in the source where to hook into to get the right amount of sound bytes going with the current picture and also to put the emulator into a mode where it may run slow but accurately calculates every frame.

Georges
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Thu Jul 30, 2009 9:55 pm

Gunstick wrote:Hi
running linux here.

I try to create videos but hatari only has single frame save which creates a gigantic amount of files (I had to patch the source to allow for more then 1000 pictures)
And it does not guarantee that each and every frame is saved.
What I'm looking for is a mode where the emulator primaly saves a video with synchronized sound and every frame equals a picture in the video.
So that should render 50 or 60 or even 72 fps
There is no need to do fancy compression, a simple mjpeg with wav would be nice.

I could not sort out in the source where to hook into to get the right amount of sound bytes going with the current picture and also to put the emulator into a mode where it may run slow but accurately calculates every frame.

Georges


Hello, still nice to see master coder from ULM, "hidden" screen from Oh Crickey still rocks :)

Well, Hatari doesn't have such a mode for now, and I really missed it when trying to capture video myself (see http://www.vimeo.com/624220).

One easy solution is to use xvidcap, but it will record at your monitor frame rate, which is not the original atari fps.
But you can tell xvidcap/ffmpeg to create a video with raw RGB image, which will give very fast recording and won't alter any pixel.
In my case I used : ffmpeg -r 25 -y -s 448x276 -f x11grab -i :0.0+0,28 -f oss -i /dev/dsp -vcodec bmp /tmp/out.avi

Another more complex solution is to use "capture animation" in the screen menu ; this will save some png images for each frame that you should be able to encode in a video with mplayer/mencoder. By recording sound at the same time from the sound menu, you will get the corresponding wav. Both files can then be multiplexed with mencoder to give a video (in that case, don't use zoom low resolution under hatari, it would create image with 2x2 pixel which is useless/waste space when you want to record the display).
But that's what you use ; I don't know this part of the code, but it's indeed possible that it sometimes skip frames to keep display acceptable instead of dumping each frame.

I agree a simple solution that would create a .avi file with png frame and wav audio directly from hatari would be better. The file would be quite big, but it would be at maximum quality and could be recompressed after if needed.
Certainly something to add for Hatari 1.4 (since 1.3 should be released soon).

Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby thothy » Thu Jul 30, 2009 10:21 pm

Nicolas is right, it's already possible to create videos with Hatari, I've done this in the past, it's just a little bit uncomfortable...

1) Make sure that you've got PNG support enabled in your executable, or it will take a _lot_ of hard disk space
2) In the screen dialog, disable the "Frame skip" and "Capture only when display changes" options
3) Push the "Record animation button", and in the sound dialog push the "Record sound" button to save a WAV file, without leaving the GUI intbetween, so that sound and screen recording starts at the same time.
4) After you've finished recording, encode the PNG files into an AVI file with the "mencoder" tool from the mplayer package, something like:

mencoder "mf://*.png" -mf fps=50 -o output.avi -ovc lavc -lavcopts vcodec=mjpeg

5) Then use ffmpeg to mux both, video and audio streams, something like:

ffmpeg -i output.avi -i hatari.wav -vcodec copy -acodec copy final.avi

... I'm not sure about the exact parameters anymore, but at least I remember that I had to use both tools, mencoder and ffmpeg to create the final file. And I think I've used frameskip=1 to create a 25 FPS video, but 50 FPS might work fine, too.

I could not sort out in the source where to hook into to get the right amount of sound bytes going with the current picture and also to put the emulator into a mode where it may run slow but accurately calculates every frame.


For getting the samples, you could hook into WAVFormat_Update() in wavFormat.c. And if you need accurate frame calculation, simply disable the frame skip option!
User avatar
thothy
Hatari Developer
Hatari Developer
 
Posts: 381
Joined: Fri Jul 25, 2003 9:36 am
Location: Germany

Re: create videos?

Postby Gunstick » Fri Jul 31, 2009 5:49 pm

I should try a music-sound synced demo. An Cool's M-DEMO comes to mind. If that turns out ok then this is not a nice but a working possibility.
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Wed Oct 07, 2009 10:04 pm

Hello,
well finally avi support is included in Hatari !
Get the latest devel version from http://hg.berlios.de/repos/hatari/summary and you will get realtime encoding, with no frame skip and full frame rate at 50 or 60 Hz (don't forget to turn off "zoom low res" to avoid recording unneeded zoomed pixels)

Frames are saved as motion PNG and sound as 16 bits stereo PCM, but you can process the file later with mencoder or ffmpeg to use h264 or mp3 for a smaller file size.

Seems you will be able to complete the png/javascript version of Dark Side Of The Spoon on your page with a complete avi :-)

Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby Desty » Fri Oct 09, 2009 2:14 pm

npomarede wrote:Hello,
well finally avi support is included in Hatari !
Get the latest devel version from http://hg.berlios.de/repos/hatari/summary and you will get realtime encoding, with no frame skip and full frame rate at 50 or 60 Hz (don't forget to turn off "zoom low res" to avoid recording unneeded zoomed pixels)

Frames are saved as motion PNG and sound as 16 bits stereo PCM, but you can process the file later with mencoder or ffmpeg to use h264 or mp3 for a smaller file size.

Seems you will be able to complete the png/javascript version of Dark Side Of The Spoon on your page with a complete avi :-)

Nicolas

That's great news! Does it slow down the emulation noticeably when this is happening, or are modern machines fast enough to handle it?
tá'n poc ar buile!
User avatar
Desty
Atari God
Atari God
 
Posts: 1794
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W

Re: create videos?

Postby npomarede » Fri Oct 09, 2009 2:24 pm

Desty wrote:That's great news! Does it slow down the emulation noticeably when this is happening, or are modern machines fast enough to handle it?


Depends on your case and your machine. My 3 years athlon 64 3200 can record png movie at 50 Hz without slow down
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

encode videos

Postby Gunstick » Mon Oct 12, 2009 5:07 am

Hi

now that I can create videos (thanks!) I want to compress them without loosing too much quality.
As candidate I use my parallax distorter fullscreen.
The 12 minute video uses 1.3GB
A good quality mp4 still is 900MB big.
Compressing to reasonable 200MB results in the background pattern really being messed up.
Too much movement on the screen.
Very frustrating.

Anyone has a good parameter set for compressing demo-videos?
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: encode videos

Postby npomarede » Mon Oct 12, 2009 8:17 am

Gunstick wrote:Hi

now that I can create videos (thanks!) I want to compress them without loosing too much quality.
As candidate I use my parallax distorter fullscreen.
The 12 minute video uses 1.3GB
A good quality mp4 still is 900MB big.
Compressing to reasonable 200MB results in the background pattern really being messed up.
Too much movement on the screen.
Very frustrating.

Anyone has a good parameter set for compressing demo-videos?


Well, I'm not sure h264 / mpeg2 are good candidates to compress low resolution computer images,but I don't know if there're codecs that will reduce the file size as much.

Perhaps you can try to compress using motion jpeg with different jpeg quality, this should give you a control of the final file size and find a tradeoff between quality/size.
Or have you tried multipass h264 encoding ? Much longer, but gives better result than "simple" h264.

By the way, I don't understand how you get 1.3 GB ? 12 minutes is 36000 frames and from my tests, one PNG frame was roughly 14 kB, sthis would be more like 500 MB of video. Did you turn off the "zoom low res" option ? Else, you can try to modify "compression_level" in avi_record.c and use 9 instead of the default 4. This will create much smaller png files (but with big slowdown in Hatari).

Nicolas

Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby Gunstick » Mon Oct 12, 2009 11:37 pm

well, it's 1.3GB
-rw-r--r-- 2 georges georges 1319555846 2009-10-11 15:11 paradist.avi

Which is maybe reasonable as a normal ST screen has 32K but this is a fullscreen which has 64K so that's the double of pixels giving you the double of size.

Here are the first 60 seconds of the video for your pleasure and encoding trials. Look especially at the moving background. As soon as the scroller goes over it, the slight color errors are enhanced into an ultimate pixel smudge.
http://www.storage.to/get/BLJ19luG/paradist_1min_c.avi
http://www.storage.to/get/oj9jmCr6/para ... n_orig.avi

I put it in original and encoded versions. The encoded version is mp4 with 300kbit and quality 20. If your player does not play it, well I may have messed up the fourcc as it states xvid instead of mpg4. But we are talking linix here, do we.
Here's my encoding command line

mencoder "$1" -oac mp3lame -lameopts preset=64 -ovc lavc -lavcopts vcodec=mpeg4:vqscale=20:vbitrate=300 -ffourcc XVID -o "$1.mp4"


Have fun :-)
Georges
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Tue Oct 13, 2009 3:23 pm

Gunstick wrote:well, it's 1.3GB
-rw-r--r-- 2 georges georges 1319555846 2009-10-11 15:11 paradist.avi

Which is maybe reasonable as a normal ST screen has 32K but this is a fullscreen which has 64K so that's the double of pixels giving you the double of size.

Here are the first 60 seconds of the video for your pleasure and encoding trials. Look especially at the moving background. As soon as the scroller goes over it, the slight color errors are enhanced into an ultimate pixel smudge.
http://www.storage.to/get/BLJ19luG/paradist_1min_c.avi
http://www.storage.to/get/oj9jmCr6/para ... n_orig.avi

I put it in original and encoded versions. The encoded version is mp4 with 300kbit and quality 20. If your player does not play it, well I may have messed up the fourcc as it states xvid instead of mpg4. But we are talking linix here, do we.
Here's my encoding command line

mencoder "$1" -oac mp3lame -lameopts preset=64 -ovc lavc -lavcopts vcodec=mpeg4:vqscale=20:vbitrate=300 -ffourcc XVID -o "$1.mp4"


Have fun :-)
Georges


For this kind of pixeled-low resolution video, I think h264/mpeg2 are not adapted as they're meant to compress "real" video (and 2000 kbps is not a very high bandwidth for quality video)

The blur you get is exactly the same I got when I uploaded an Hatari video on vimeo :(

Have you tried some ffmpeg/mencoder lossless codecs such as ffv1 or huffyuv ? They're supposed to compress much more than simple png, and this could give you perfect quality (but with a required bandwidth still higher than 2000 kbps though). Or motion jpeg maybe ?

Have a look at http://compression.ru/video/codec_compa ... 07_en.html to see if some of the proposed lossless codecs give small enough files in your case.

For this kind of video input, there's no direct answer, you will need to experiment a few codecs/settings and see what's best.
But if you do such tests, I would be interested to include the results in Hatari's manual.


Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby Gunstick » Sun Oct 18, 2009 10:30 am

On a coll C64 demo on youtube I did read that I should go see the better quality video on capped.tv
Oh and it was really batter.
So I uploaded my test file
And it compressed to a nice 22MB which is streamable.

Then I dug through that guy's blog until I came across a link which he used to write the encoder.
http://blog.massanti.com/2008/01/01/enc ... for-flash/

Which in short says to encode with a variation of these parameters:
mencoder "$filename" -o "${filename%.*}_temp-crf=${crf}.264" -passlogfile "${filename%.*}"_temp.log $rsize -ovc x264 -x264encopts bitrate=$bitrate:frameref=8:bframes=3:b_adapt:b_pyramid:weight_b:partitions=all:8x8dct:me=umh:subq=6:trellis=2:brdo:threads=auto:pass=1:analyse=all -of rawvideo -nosound

I'm now working with that to get a nice demovideo compressor parameter set.
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Sun Oct 18, 2009 10:48 am

Gunstick wrote:On a coll C64 demo on youtube I did read that I should go see the better quality video on capped.tv
Oh and it was really batter.
So I uploaded my test file
And it compressed to a nice 22MB which is streamable.

Then I dug through that guy's blog until I came across a link which he used to write the encoder.
http://blog.massanti.com/2008/01/01/enc ... for-flash/

Which in short says to encode with a variation of these parameters:
mencoder "$filename" -o "${filename%.*}_temp-crf=${crf}.264" -passlogfile "${filename%.*}"_temp.log $rsize -ovc x264 -x264encopts bitrate=$bitrate:frameref=8:bframes=3:b_adapt:b_pyramid:weight_b:partitions=all:8x8dct:me=umh:subq=6:trellis=2:brdo:threads=auto:pass=1:analyse=all -of rawvideo -nosound

I'm now working with that to get a nice demovideo compressor parameter set.


By the way, I forgot to add that mencoder/ffmpeg will by default first transform RGB images to YUV with a possible compression of V. This will immediatly result in shorter files, but the color will be altered (slightly darker), so you may try to use the "format" parameter in mencoder to use YUV or to keep the data as RGB (as captured under Hatari).
h264 compression is certainly a complicated things to get the most of it.

Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby Gunstick » Sun Oct 18, 2009 5:40 pm

npomarede wrote:
By the way, I forgot to add that mencoder/ffmpeg will by default first transform RGB images to YUV with a possible compression of V. This will immediatly result in shorter files, but the color will be altered (slightly darker), so you may try to use the "format" parameter in mencoder to use YUV or to keep the data as RGB (as captured under Hatari).
h264 compression is certainly a complicated things to get the most of it.

Nicolas


If you can come up with a command line using RGB I would be please to have that. Currently mencoder just says:
"The selected video_out device is incompatible with this codec."
if I attempt to use -vf format=rgb24

Georges
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Sun Oct 18, 2009 5:52 pm

Gunstick wrote:If you can come up with a command line using RGB I would be please to have that. Currently mencoder just says:
"The selected video_out device is incompatible with this codec."
if I attempt to use -vf format=rgb24

Georges


You should use the lavc alternative to select the ffmpeg codec and its parameters. For example :
-ovc lavc -lavcopts vcodec=libx264:format=BGR32
(it works for jpeg, I haven't tried with h264)
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby Gunstick » Mon Oct 19, 2009 10:26 pm

before I try other encodings, I have put up the first video into the DSOTS online demo.
Have fun!

yes it's the parallax distorter.
http://www.ulm.lu/ulm/DSOTS.html

Georges
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Tue Oct 20, 2009 8:25 am

Gunstick wrote:before I try other encodings, I have put up the first video into the DSOTS online demo.
Have fun!

yes it's the parallax distorter.
http://www.ulm.lu/ulm/DSOTS.html

Georges



I like the way you recoded the main menu in a html page, very funny to use (a little hard to click on a door sometimes)

By the way, regarding the parallax distorter, will you ever publish the revolutionary technique you used with the keyboard processor if I recall correctly ? ;-)

Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: create videos?

Postby Gunstick » Tue Oct 20, 2009 11:45 pm

npomarede wrote:I like the way you recoded the main menu in a html page, very funny to use (a little hard to click on a door sometimes)

Thanks. You never seen that page before? It's online since 10 years. You need to get the lion in front of the door, and clicking the lion then should click through to the door (mostly). Advantage compared to the real demo: you have a scrollbar for fast moving through the menu. I will put more flash in there, as not many people do the hassle of installing ym and mod player plugins. So all this will be done with hidden flash players.
I digitized now the playfield screen. So that's the next one going on the site.

npomarede wrote:
By the way, regarding the parallax distorter, will you ever publish the revolutionary technique you used with the keyboard processor if I recall correctly ? ;-)

Nicolas


This is off topic in this thread so I won't discuss it here (you can ask the question on the coding forum, maybe we can get a fun discussion going)
:-D

Georges
Gunstick
Captain Atari
Captain Atari
 
Posts: 205
Joined: Thu Jun 20, 2002 6:49 pm
Location: Luxembourg

Re: create videos?

Postby npomarede » Wed Oct 21, 2009 7:51 am

Gunstick wrote:Thanks. You never seen that page before? It's online since 10 years. You need to get the lion in front of the door, and clicking the lion then should click through to the door (mostly). Advantage compared to the real demo: you have a scrollbar for fast moving through the menu. I will put more flash in there, as not many people do the hassle of installing ym and mod player plugins. So all this will be done with hidden flash players.
I digitized now the playfield screen. So that's the next one going on the site.

No, I saw that page before, but I didn't have the opportunity yet to say it was a nice way to "recode" the demo.

npomarede wrote:
By the way, regarding the parallax distorter, will you ever publish the revolutionary technique you used with the keyboard processor if I recall correctly ? ;-)

Nicolas


This is off topic in this thread so I won't discuss it here (you can ask the question on the coding forum, maybe we can get a fun discussion going)
:-D

Georges


Could be fun indeed, but I'm not sure there're so many "old timers" that would recognize the joke :)

Nicolas
User avatar
npomarede
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
 
Posts: 100
Joined: Sat Dec 01, 2007 7:38 pm
Location: France


Return to Hatari

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests