Class Y4mWriter
Y4mDecoder
verifiable, and the only way to get a real video file out of this project without shipping one.
It exists because no media may be committed to this repository. A test that needs a file writes one first, from a source whose every sample it can predict, and reads it back; the assertion is then about the reader and the writer rather than about a blob someone downloaded once. It is also how a picture leaves the process for a human to look at, since the format is what every video tool reads.
Two things do not survive the trip, and both are the container's limits rather than this
writer's. YUV4MPEG2 has no way to say which luma/chroma matrix a stream was encoded with, so a
BT.601 stream written here reads back as unsignalled; only the range is carried, through FFmpeg's
XCOLORRANGE extension, and only when the source signalled one. And there is no tag for a
two-plane layout, so PixelFormat.NV12 is refused rather than silently de-interleaved into
something whose samples would no longer be the source's.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intwrite(Path file, VideoStreamSource source, int maxFrames) Drainssourceintofile, creating or truncating it.
-
Method Details
-
write
Drainssourceintofile, creating or truncating it.Every picture is released as soon as it is written, so a source with a single slot works.
VideoStreamSource.Read.PENDINGis answered by asking again (the caller holds nothing), and a source that only ever answers that is abandoned rather than spun on forever.- Parameters:
maxFrames- most pictures to write, at least 1. A source that never ends needs this; a finite one stops at its own end, whichever comes first.- Returns:
- pictures written
- Throws:
UnsupportedOperationException- if the source's layout has no YUV4MPEG2 tagIllegalStateException- if the source answersPENDINGindefinitelyUncheckedIOException- if the file cannot be writtenNullPointerException- iffileorsourceis nullIllegalArgumentException- ifmaxFramesis below 1
-