This is a simple CD+G and CD+EG decoder with some oddities for my own use.
cdg-decode disc.img disc.cdg disc.toc out.raw out.apng start_track end_track mode
-
disc.imgis the audio data (16-bit stereo) for the CD in a single file disc image, part of this will be copied out toout.raw. -
disc.cdgis a single file with all the CD+G data, decoded and in logical pack order, as would be output by redumper-extract-rw. -
disc.tocis the table of contents from the disc, as recorded by redumper. -
start_track end_trackthe first and last tracks to include in the output, inclusive (e.g.3 3to only output track 3).Note: Decoding will start at index 1 of
start_track. If the graphics were encoded assuming playback proceeds from the previous track, there may be unwanted artifacts such as flashing. -
mode(optional) selects the graphics mode,cdgfor CD+G (ignoring the EG commands),cdegfor CD+EG. For a non-EG disc this should have no effect. This is optional, if missing it will default to CD+G mode.
If the output files exist already they will not be overwritten and the conversion will fail.
out.rawis the audio data, this is just a range copied fromdisc.imgout.apngis the decoded video as a 25 FPS APNG
Colors are currently converted with a .5 bias then scaled by 16, instead of being scaled to a full 8 bit range (x17) as in some other decoders. This may be a mistake.
My usual workflow is to feed the output into ffmpeg, using the recommended encoding specs for streaming mp4 on the Internet Archive:
ffmpeg -r 25 -i out.apng -f s16le -ar 44100 -ac 2 -i out.raw -vcodec libx264 -vf "format=yuv420p" -movflags +faststart out.mp4
With 2x scale (to reduce artifacts from subsampling, useful with sharp pixel art):
ffmpeg -r 25 -i out.apng -f s16le -ar 44100 -ac 2 -i out.raw -vcodec libx264 -vf "scale=624:432:flags=neighbor,format=yuv420p" -movflags +faststart out-2x.mp4