ppmtoy4m(1)

πŸ’– ppmtoy4m(1) β€” the MJPEG tools manual, but make it a group chat πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about ppmtoy4m β€” she lives in the MJPEG tools manual and she is THAT girl. she takes your lil PPM pics and turns them into a YUV4MPEG2 stream. it's giving glow-up. it's giving pipeline icon. πŸ¦‹


✨ NAME ✨

ppmtoy4m β€” Convert PPM images to YUV4MPEG2 stream πŸ’…


🌸 SYNOPSIS 🌸

ppmtoy4m [options] [ filename ]

πŸŽ€ DESCRIPTION πŸŽ€

so like, ppmtoy4m converts one or more raw PPM images into a YUV4MPEG2 stream, all ready for further processing by other video tools. no cap. πŸ”₯

output goes to stdout so you can pipe it straight into other MJPEG tools β€” yes queen, the pipeline is the moment. the size of the output frame(s) is determined from the (first) input image. πŸ‘‘

input is a 'raw' format PPM image, read from stdin or from the optional filename. and here's the tea: the input may contain multiple PPM images concatenated together, and ppmtoy4m will read and process them sequentially. all images must have identical size and format β€” no exceptions bestie, she does not do chaos. input images can be interpreted as whole progressive frames, interleaved fields, or (in pairs) as sequential fields. and the input images must have 8 bits per channel (i.e. maxval must be 255). that's the law. πŸ“

input images should be in the usual R'G'B' colorspace. they get converted to the Y'CbCr colorspace (ITU-R BT.601) β€” and chroma subsampled, if that's what you want β€” before output. slay. πŸ’œ

now this is the cute part: ppmtoy4m and y4mtoppm are inverses of each other. you can pipe the output of one into the other, and vice-versa. adorable. matching besties. 🫢 but ngl β€” the subsampling and colorspace operations are lossy in both directions, so don't come crying to me when the pixels aren't pixel-perfect. and when converting to PPM, information on interlacing and sample aspect ratio is lost (but can be reconstructed by supplying command-line arguments to ppmtoy4m). iykyk. 😭


πŸ‘‘ OPTIONS πŸ‘‘

ppmtoy4m accepts the following options, and yes, we're doing all of them:

  • -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)
  • -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
  • -B β€” Interpret data as being BGR rather than RGB. (not me forgetting the channel order πŸ™ˆ)
  • -I x β€” Set interlacing mode, used to interpret the PPM image(s), and also encoded in output stream. (default: 'p')
    • p β€” progressive, non-interlaced
    • t β€” top/upper-field-first interlaced
    • b β€” bottom/lower-field-first interlaced
  • -L β€” For interlaced streams, treat each PPM image as two interleaved fields. (Otherwise, two PPM images will be read for each frame; one per field.)
  • -r β€” Repeat last input frame until output is complete. If -n 0 is also specified, last input frame will be repeated forever. πŸ‘€ infinite loop energy, literally.
  • -S mode β€” Set chroma subsampling mode. (default: 444)
    • 444 β€” 4:4:4 (no subsampling)
    • 420jpeg β€” 4:2:0 JPEG/MPEG-1, interstitial cositing
    • 420mpeg2 β€” 4:2:0 MPEG-2, horizontal cositing
bestie listen. the subsampled modes use a lousy subsampling filter. better results will be achieved by passing the default 4:4:4 output to a scaler which supports subsampling, such as y4mscaler(1). don't say i didn't warn you. πŸ’€
  • -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 β€” yes, 15 whole frames of the same pic, she's committed:

ppmtoy4m -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 β€” the pipeline is genuinely so satisfying:

ls *.tga | xargs -n1 tgatoppm | ppmtoy4m | yuvplay

ate. no crumbs. πŸ”₯


🧚 AUTHOR 🧚

this man 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 ⭐

ppm(5), y4mtoppm(1), mjpegtools(1), mpeg2enc(1), y4mscaler(1), yuv2lav(1), yuvplay(1)

go read them. do it for her. πŸ“šβœ¨


and that's the whole page, bestie!! brought to you by the MJPEG Tools Team, dated 28 April 2004 β€” vintage, iconic, still slaying to this day. mwah. πŸ’‹πŸŽ€πŸ¦‹