Currently, SkipBox relies on FileChannel-specific behavior to efficiently skip box content.
When the underlying DataSource is not backed by a FileChannel (e.g. streaming sources, in-memory sources, custom DataSource implementations), SkipBox cannot skip data efficiently and may fail or require full reads.
This limitation makes it difficult to use SkipBox in streaming or non-file-based scenarios.
|
throw new RuntimeException("Cannot skip box "+type+" if data source is not seekable"); |
Would the maintainers be open to adding this fallback mechanism to SkipBox to improve support for non-FileChannel data sources?
long remaining = contentSize;
ByteBuffer skipBuffer = ByteBuffer.allocate((int) Math.min(8192, remaining));
while (remaining > 0) {
skipBuffer.clear();
if (remaining < skipBuffer.capacity()) {
skipBuffer.limit((int) remaining);
}
int read = dataSource.read(skipBuffer);
if (read < 0) {
throw new EOFException("Unexpected end of stream while skipping mdat box, remaining: " + remaining);
}
remaining -= read;
}
Currently, SkipBox relies on FileChannel-specific behavior to efficiently skip box content.
When the underlying DataSource is not backed by a FileChannel (e.g. streaming sources, in-memory sources, custom DataSource implementations), SkipBox cannot skip data efficiently and may fail or require full reads.
This limitation makes it difficult to use SkipBox in streaming or non-file-based scenarios.
mp4parser/isoparser/src/main/java/org/mp4parser/SkipBox.java
Line 54 in ff13790
Would the maintainers be open to adding this fallback mechanism to SkipBox to improve support for non-FileChannel data sources?