[GEM-dev] recordPNM plugin for PPM and PGM image stream output

Claude Heiland-Allen claude at mathr.co.uk
Fri Oct 14 16:36:43 CEST 2022


Hi all,

I saw there is a ticket[1] unfixed since 2014 about adding ffmpeg and/or 
libav support to pix_record.

Meanwhile I needed something today, so I wrote a simple PNM plugin (for 
8bit PPM (RGB) and PGM (gray) formats), that I can use with named pipes 
and encode video with ffmpeg command line tool.

Using this plugin I can record 1024x1024p60 at 60fps with AMD RX 580 GPU 
and AMD Ryzen 2700X CPU with pd -batch; probably this is limited by my 
monitor refresh rate.  Output file in my test case was 200MB for 10mins, 
good quality.  Compared with my previous method using temporary TIFF 
files with pix_write, this new recordPNM with a FIFO (created with 
mkfifo) is 10x faster and uses around 0.3% of the disk space.

There may be bugs:
- upside down or not images (my test video was symmetrical enough that I 
could not notice)
- pgm (gray) mode is not tested thoroughly
- changing size mid stream might be possible for special purposes (e.g. 
mipmap chains) (untested)
- file is opened relative to Pd's current working directory, instead of 
relative to the patch containing pix_record
- PNM has (big-endian) 16bit formats, but afaict Gem pixes are only 
8bit, so this is for the future
- PNM has a 1bit format too (PBM), this is not supported by this plugin
- PNM has plain text variants of PPM, PGM, and PBM, which are not 
supported by this plugin
- reading is not implemented yet (parsing the ASCII header is a bit 
subtle with comments possible in the middle of tokens...)

Code attached as git patch against recent git.iem.at master (if you 
prefer I could do a github pull request dance for your
entertainment).

[1] https://github.com/umlaeute/Gem/issues/73

Thanks,


Claude
-- 
https://mathr.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-recordPNM-plugin-for-PPM-and-PGM-image-stream-output.patch
Type: text/x-patch
Size: 12138 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/gem-dev/attachments/20221014/cf5baf6e/attachment.bin>


More information about the GEM-dev mailing list