Upscaling recorded DOSBox video captures - GUI

This is where you can post your Commander Keen related stories, artwork, or other stuff that is related to Commander Keen but otherwise doesn't belong in another forum.
Post Reply
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Upscaling recorded DOSBox video captures - GUI

Post by Nisaba »

Some time ago I posted a short script on how to upscale recorded dosbox video captures for youtube & co.
link: https://pckf.rigeltechnical.com/viewtop ... ght=#81136

the goal was to create a pixel perfect output (for eg. a solution of 1280px800p) without any artifacts plus some fine interpolation.

for those of you who prefer a graphical user interface instead of fireing up the CMD, the Terminal or a writen script, I'd love build a simple / dirty little tool.
The only problem:
I can only script, not code.
So I'm asking for the help of you guys! Can someone please help me out building this simple little tool, which allows to choose an input file, choose a resolution and write a pixel perfect output file?!
(yes I know there is VirtualDub, Handbrake & Co... but a simple KeenScale solution is missing on the wiki).

Examples:
a) lossy encoding
b) Lossless compression
Image Image

Kisses
Last edited by Nisaba on Sun May 27, 2018 7:57, edited 1 time in total.
out now (link) : Image
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 781
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

Did you ever give the BlitzMax demo a try? The demo includes the MaxGUI package, which allows you to create GUI applications for Windows, Linux and MacOS. I could probably help you with that if you can give me a mockup of what the GUI should look like.


As far as re-encoding DOSBox recordings goes, I would consider scaling the entire video to 1600x1200. That would give you a perfect 4:3 representation of the original 320x200 pixels (a.k.a. the way the graphics were meant to be displayed) where all the "pixels" have the exact same size.

On the other hand, the thought of resizing and re-encoding a lossless DOSBox capture into some hi-res but bloated MP4 file for the sake of uploading it to Youtube is something I would not recommend to people with a slow internet connection.

And some nitpicking: The images you posted are both lossless (in PNG format). I think "filtered" is what you meant to say. Also, the original DOSBox captures are lossless, but MP4 files are usually using lossy compression. That is one reason why I usually prefer the original recordings over re-encoded ones.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Post by Nisaba »

hey there,

thanx for the MaxGUI hint. gonna give it a shot as soon as I have access to a windows machine. and a bit of help 'd be very much appreciated!
mockup will follow soon as well.

the scale should be selectable by the user (at least that's the plan). some presets might be given but one should be able to decide which solution fits best. (but always multiples of 320x200 px)

nit nit nit pick pick: they're just some exemplification images for demonstration purpose... so yes, they are PNGs and yes, those results aren't technically lossless compression BUT the main idea is to have a pixel-perfect scaled video as an output. compared to those automated yutube upscales this gives really better and preferable results. besides that one might choose between mp4 and the matroska container format...
out now (link) : Image
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Post by Nisaba »

as promised the mockup.
a little something like this:

Image
Last edited by Nisaba on Mon Oct 22, 2018 23:05, edited 1 time in total.
out now (link) : Image
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 781
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

Okay, I'll try to recreate something like that in BlitzMax. But I can already tell that the progress bar is not going to work. You can create a custom batch file (.BAT or .CMD for Windows) containing the command-line parameters for FFMPEG and run that from your BlitzMax program, but there's no way for the BlitzMax program to know what progress the external FFMPEG program has made so far.

I have seen at least one GUI front-end for FFMPEG that had a progress bar, but the progress bar didn't do anything at all in that tool.

I remember Borland Delphi had an option where you could run "console applications" like FMPEG and have access to the text output it generates, but the latest version of Delphi I have is about 12 years old now, so I don't even know if that code would still work with current versions of Windows. And even if it worked, you would need to write a parser that analyzes the text output of FFMPEG in order to update the progress bar. I think that would be way too complicated for this little program, especially if you don't have any programming experience.
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Post by Nisaba »

well then, let's skip the progress bar thing. thought it could be a neat little extra but it isn't really necessary at all.
I'm pretty curious what you'll coming up with.

I've sneaked a bit into BlitzMax. and to be honest, I presume it may take too long for me to understand everything in order to get good results. so I count on your skills, if this ok...
thanx in advance for helping out!

and here is the ffmpeg batch script:

Code: Select all

@ECHO OFF
REM FF Prompt 1.2
REM Open a command prompt to run ffmpeg/ffplay/ffprobe

TITLE FF Prompt

IF NOT EXIST bin\ffmpeg.exe (
  CLS
  ECHO bin\ffmpeg.exe could not be found.
  GOTO:error
)

CD bin || GOTO:error
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS
ffmpeg -version
ECHO.
ECHO For help run: ffmpeg -h
ECHO For formats run: ffmpeg -formats ^| more
ECHO For codecs run: ffmpeg -codecs ^| more
ECHO.
ECHO Current directory is now: "%CD%"
ECHO The bin directory has been added to PATH
ECHO.

CMD /Q /K ffmpeg -i %SOURCE-PATH-VARIABLE.avi% -sws_flags neighbor+full_chroma_inp -s %UPSCALLING-VARIBALE.640x400% -r 30 -vcodec libx264 -crf 20 -acodec libmp3lame -aq 2 -f %OUTPUT-CONTAINER-VARIABLE.mkv% %DESTINATION-PATH-VARIBALE.mkv%
GOTO:EOF

:error
ECHO.
ECHO Press any key to exit.
PAUSE >nul
GOTO:EOF
EDIT: think I'm gonna need to write an installer which additionally loads and installs all those needed codex' as well (FFMPEG, LAME, libx264)
out now (link) : Image
User avatar
K1n9_Duk3
Vorticon Elite
Posts: 781
Joined: Mon Aug 25, 2008 9:30
Location: Germany
Contact:

Post by K1n9_Duk3 »

Here is what I've got so far. The program allows you to select input and output filename and the resolution. It doesn't actually run ffmpeg when you click the "Start" button, but I think this might be something that you can modify yourself and play around with. The "system_()" function is what should be used to call ffmpeg. I put the echo command in there so you can see what the resulting text string looks like.

I'm having some trouble with ftp connections, so I'll just post the source code here.

Code: Select all

'KEENSCALE GUI TEST
'by K1n9_Duk3

Framework MaxGUI.Drivers
Import MaxGUI.Win32MaxGUIEx	'GUI driver for Windows
'Import MaxGUI.FLTKMaxGUI	'GUI driver for Linux
'Import MaxGUI.CocoaMaxGUI	'GUI driver for Max OS X

Import BRL.EventQueue

SuperStrict

AppTitle = "KeenScale (Version 0.001)"

Local window:TGadget = CreateWindow(AppTitle, 40, 40, 320, 260, Null, WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_CENTER)

Local groupboxSource:TGadget = CreatePanel(10, 10, 300, 60, window, PANEL_GROUP, "Source")
Local groupboxDestination:TGadget = CreatePanel(10, 80, 300, 60, window, PANEL_GROUP, "Destination")
Local groupboxSettings:TGadget = CreatePanel(10, 150, 300, 60, window, PANEL_GROUP, "Output Settings")

Local labelSource:TGadget = CreateLabel("Source:", 10, 13, 40, 20, groupboxSource)
Local textfieldSource:TGadget = CreateTextField(55, 10, 170, 20, groupboxSource)
SetGadgetText(textfieldSource, "DOSBox capture file")
Local buttonBrowseSource:TGadget = CreateButton("Browse", 230, 10, 60, 20, groupboxSource)

Local labelFile:TGadget = CreateLabel("File:", 10, 13, 40, 20, groupboxDestination)
Local textfieldDestination:TGadget = CreateTextField(55, 10, 170, 20, groupboxDestination)
SetGadgetText(textfieldDestination, "Path + Filename")
Local buttonBrowseDestination:TGadget = CreateButton("Browse", 230, 10, 60, 20, groupboxDestination)

Local labelScaling:TGadget = CreateLabel("Scaling:", 10, 13, 40, 20, groupboxSettings)
Local comboboxScaling:TGadget = CreateComboBox(55, 10, 120, 20, groupboxSettings, COMBOBOX_EDITABLE)	'is editable so the user can type in the desired resolution if it's not in the list
AddGadgetItem(comboboxScaling, "640x400", GADGETITEM_DEFAULT)
AddGadgetItem(comboboxScaling, "960x600")
AddGadgetItem(comboboxScaling, "1280x800")
AddGadgetItem(comboboxScaling, "1600x1000")
AddGadgetItem(comboboxScaling, "1600x1200")

Local buttonStart:TGadget = CreateButton("Start", 10, 220, 300, 30, window)

'this would be the place to load the settings from an external INI file

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_GADGETACTION
			Local event:TEvent = CurrentEvent
			If event.source = buttonStart
				'user clicked on the "Start" button:
				
				Local sourceFileName:String = GadgetText(textfieldSource)
				If FileType(sourceFileName) = FILETYPE_FILE
					'the source file exists, so start re-encoding with ffmpeg
					
					'the GUI application will be suspended while the child process is running, so hide the window to avoid graphical glitches
					HideGadget(window)
					
					'this is what is actually executed:
					system_("CMD /Q /K echo ffmpeg -source="+sourceFileName+" -dest="+GadgetText(textfieldDestination)+" -scaling="+GadgetText(comboboxScaling))
					
					'restore the program window:
					ShowGadget(window)
				Else
					Notify("The source file does not exist:~n~n~q"+sourceFileName+"~q", True)
				EndIf
				
			ElseIf event.source = buttonBrowseDestination
				'user clicked on the "Browse" button in the "Destination" box:
				
				Local filepath:String = RequestFile("Save output as...", , True, GadgetText(textfieldDestination))
				If filepath
					SetGadgetText(textfieldDestination, filepath)
				EndIf
				
			ElseIf event.source = buttonBrowseSource
				'user clicked on the "Browse" button in the "Source" box:
				
				Local filepath:String = RequestFile("Select input file...", , False, GadgetText(textfieldSource))
				If filepath
					SetGadgetText(textfieldSource, filepath)
				EndIf
				
			EndIf
		Case EVENT_WINDOWCLOSE
			'this would be the place to save the current settings to an INI file or something similar
			End
	EndSelect
Forever
(To Do: insert Inspector Gadget joke)
Hail to the K1n9, baby!
http://k1n9duk3.shikadi.net
User avatar
Nisaba
Janitress
Posts: 1597
Joined: Fri Jan 01, 2016 23:34
Location: The Outpost
Contact:

Post by Nisaba »

ah sweet.
that's very kind of you! thanx a lot for that.
as soon as I have the chance of testing things out I'm gonna let you know the results.
out now (link) : Image
Post Reply