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 PGM
  • TUPLTYPE "RGB" as PPM
  • TUPLTYPE "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. use 0 to specify all frames. (default: 0)
  • -B β€” interpret data as being BGR rather than RGB. (not me flipping your channels πŸ™ˆ)
  • -r β€” repeat last input frame until output is complete. if -n 0 is 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-field
    • b β€” 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 film
    • 24:1 β€” native film
    • 25:1 β€” PAL/SECAM
    • 30000:1001 β€” NTSC video
    • 50:1 β€” PAL field rate
    • 60000: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 NTSC
    • 59:54 β€” CCIR-601 PAL
  • -I x β€” set the output interlacing mode, encoded in the output stream. (default is to match -D if given, or p if not.)
    • p β€” progressive, non-interlaced
    • t β€” top/upper-field-first interlaced
    • b β€” 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 🫢