pnmtoy4m(1)
β¨ pnmtoy4m β bestie edition β¨
okay so you found pnmtoy4m(1), the MJPEG tools manual page, and honestly? it's giving glow-up factory. let's get into it π
π NAME π
pnmtoy4m β Convert PNM/PAM images to YUV4MPEG2 stream
like. it takes your cute little still images and turns them into a video stream. main character energy fr fr π
πΈ SYNOPSIS πΈ
pnmtoy4m [options] [ filename ]
π¦ DESCRIPTION π¦
so pnmtoy4m converts one or more raw PPM, PGM, PBM, or PAM images into a YUV4MPEG2 stream that's ready for further processing by other video tools. these three (or four, ok, four) image formats collectively get called "PNM images". slay.
output goes to stdout, which is highkey the whole point β it makes piping to other MJPEG tools effortless. the size of the output frame(s) is determined from the (first) input image. periodt.
input is a 'raw' format PNM image, read from stdin or from the optional filename. the input may contain multiple PNM images concatenated together; pnmtoy4m will read and process them sequentially. but listen β all images must have identical size and format, no cap. input images can be interpreted as:
- whole progressive frames,
- pairs of interleaved fields,
- or as sequential fields (read in pairs of images) to be output as either interlaced or progressive frames.
PPM and PGM images must have 8 bits per channel (i.e. maxval must be 255). no vibes-checking your way around that one.
PPM input images should be in the usual R'G'B' colorspace. they get converted to the Y'CbCr colorspace (ITU-R BT.601) before being output to a "4:4:4" (non-subsampled) YUV4MPEG2 stream. if chroma subsampling is required (e.g. to 4:2:0 for MPEG), the output should be further piped through a program such as y4mscaler. that's just how it is bestie π«Ά
PGM images should be in the standard full-range ([0,255]) grayscale colorspace. PGM and PBM images will be converted to BT.601 luma and output as "MONO" (luma-only) YUV4MPEG2 streams.
the PAM format is a newer superset of the PNM formats; the precise contents of a PAM image is defined by the TUPLTYPE header tag. pnmtoy4m handles:
TUPLTYPE"GRAYSCALE"as PGMTUPLTYPE"RGB"as PPMTUPLTYPE"RGB_ALPHA"as PPM with an 8-bit alpha channel
(the alpha channel is converted to BT.601 luma as is appropriate for YUV4MPEG2 streams, iconic behavior honestly)
pnmtoy4m and y4mtopnm are inverses of each other β you can pipe the output of one into the other, and vice-versa. π« note that the colorspace operations are lossy in both directions π. and, when converting to PNM, information on interlacing and sample aspect ratio is lost (but can be reconstructed by supplying command-line arguments to pnmtoy4m). iykyk.
π OPTIONS π
pnmtoy4m accepts the following options:
-o numβ frame offset: skip output of the first num frames. (default:0)-n numβ output a total of num output frames. use0to specify all frames. (default:0)-Bβ interpret data as beingBGRrather thanRGB. (not me flipping your channels π)-rβ repeat last input frame until output is complete. if-n 0is also specified, the last input frame will be repeated forever. like, genuinely forever. π-D xβ treat each PNM image as a single (de-interleaved) field instead of a full frame. the argument specifies the interpretation:tβ the first image is a top-fieldbβ the first image is a bottom-field
with this option, two input images will be required per output frame. be careful: mismatched -I and -D options can invert the temporal or spatial order of the fields (or both). β οΈ
-F n:dβ set framerate encoded in output stream, as an exact integer ratio. (default:30000:1001) common rates are:24000:1001β NTSC 3:2 pulldown converted film24:1β native film25:1β PAL/SECAM30000:1001β NTSC video50:1β PAL field rate60000:1001β NTSC field rate
-A n:dβ set pixel aspect ratio encoded in output stream, as an exact integer ratio. (default:1:1) common ratios are:1:1β square pixels (computer graphics)10:11β CCIR-601 NTSC59:54β CCIR-601 PAL
-I xβ set the output interlacing mode, encoded in the output stream. (default is to match-Dif given, orpif not.)pβ progressive, non-interlacedtβ top/upper-field-first interlacedbβ bottom/lower-field-first interlaced
-v [0,1,2]β set verbosity level.0= warnings and errors only.1= add informative messages, too.2= add chatty debugging message, too.
π EXAMPLES π
to convert a file containing a single PPM file into a stream of 15 (identical) frames:
pnmtoy4m -n 15 -r some-image.ppm
to convert a series of Targa format images (in the current directory) to a YUV4MPEG2 stream displayed by yuvplay:
ls *.tga | xargs -n1 tgatoppm | pnmtoy4m | yuvplay
look at that pipeline. the way she pipes. π
π AUTHOR π
this manual page was written by Matt Marjanovic.
if you have questions, remarks, problems or you just want to contact the developers, the main mailing list for the MJPEG-tools is:
mjpeg-users@lists.sourceforge.net
for more info, see our website at
http://mjpeg.sourceforge.net/
π§ SEE ALSO π§
pam(5), pbm(5), pgm(5), pnm(5), ppm(5), y4mtopnm(1), mjpegtools(1), mpeg2enc(1), y4mscaler(1), yuv2lav(1), yuvplay(1)
and that's the whole page, bestie!! πΈ this one's brought to you by the MJPEG Tools Team, dated 28 April 2004 β yeah she's an elder icon but she still ate π β¨ bye luv u π«Ά
π¦ where this page comes from
- arch rolling: mjpegtools 2.2.1-4 Β· GPL-2.0-or-later
- debian bookworm: mjpegtools 1:2.1.0+debian-7
- debian trixie: mjpegtools 1:2.1.0+debian-8.1+b1
- fedora 43: mjpegtools 2.2.1-11.fc43 Β· GPL-2.0-or-later AND GPL-2.0-only AND GPL-1.0-or-later
- fedora 44: mjpegtools 2.2.1-12.fc44 Β· GPL-2.0-or-later AND GPL-2.0-only AND GPL-1.0-or-later
- nixos 26.05: mjpegtools 2.2.1
- nixpkgs unstable: mjpegtools 2.2.1
- opensuse-leap 16.0: mjpegtools 2.2.1-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: mjpegtools 2.2.1-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: mjpegtools 2.2.1-160000.2.2 Β· GPL-2.0-only
- opensuse-leap 16.0: mjpegtools 2.2.1-160000.2.2 Β· GPL-2.0-only
- ubuntu jammy: mjpegtools 1:2.1.0+debian-6build1
- ubuntu noble: mjpegtools 1:2.1.0+debian-8.1build1
- ubuntu questing: mjpegtools 1:2.1.0+debian-8.1build1
- ubuntu resolute: mjpegtools 1:2.2.1-3
- ubuntu stonking: mjpegtools 1:2.2.1-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms