1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2024-05-20 09:18:16 +00:00
Commit graph

13 commits

Author SHA1 Message Date
emkman99 19e4eaa3c8
Extract esds box from wave box (#96)
* Extract esds from wave box

* Allow empty, multi-byte, and arbitrary NUL terminated strings

* Skip unsupported avc1 sub-boxes

* Fixed non-integer framerates

* Fixed bitrate calculation

* Fixed format issue

* Public read sample offset

* Fix lint warning.

---------

Co-authored-by: Alfred Gutierrez <alfg@users.noreply.github.com>
2023-08-02 21:13:58 -07:00
oftheforest 7cfdffbd71
Fix several overflows in box and track processing (#94)
* Fix several overflows in box and track processing

* Use size_of::<Type>() instead of magic numbers

* Fix a panic in Mp4Track::read_sample() for one-past-the-end

This appears to be a bug unmasked by other changes. read_sample() calls
sample_offset() then sample_size(), and assumes that if the former returns Ok
then the latter does as well. However, if the sample_id is one past the end,
sample_offset() might succeed (it only checks samples _up to_ the given
sample_id but not _including_ it) while sample_size() fails (because the sample
doesn't exist). read_sample() will then panic.

Fix this by duplicating the error propagation (that is currently done for
sample_offset) for sample_size, instead of unwrapping. This is a cautious
change that fixes the bug; alternatively, having sample_offset() call
sample_size() on the given sample_id and propagate any error might also work.

* Account for header size in box processing overflow fixes

* Ensure that boxes aren't bigger than their containers

Together with the entry_count checks, this eliminates several OOMs when reading
incorrect mp4 files.

* Fix order of arithmetic operations

This was due to an incorrect transcription when switching to checked
arithmetic, and fixes a bug that could cause attempted lookups of the wrong
chunk_id.
2023-02-18 11:46:51 -08:00
rolleifx c26bdcab59
fix "mdat size too large" (#80)
* fix "mdat size too large"

* fix clippy

* Fix clippy::derive-partial-eq-without-eq
2023-01-05 18:19:47 -08:00
Ririsoft 5d648f1a72
fix clippy & enhance CI/CD (#78)
* fix clippy::unused_io_amount

See related clippy documentation,
but in short some partial reads can occur
in particular with io on the networl.
read_exact/write_all transparently handle such errors.

The fix actually revealed a bug
in 'mp4a' atom parsing, but this is a dangerous change:
Parsing bugs that were transparently ignored
are now failing with error (unattended io eof).

* fix trivial clippy errors

* fix clippy error with always 0 value

* run ci/cd with clippy and latest rust version
2022-07-07 20:02:00 -07:00
Data Retriever 3ecfd0cc9d
Cargo fmt and clippy (#73)
* Run cargo clippy --fix

* Run cargo fmt --all
2022-05-31 20:50:49 -07:00
Nathan Fiedler 56cc260a5c
fix: minimize assertions in non-test code (#56)
Initial effort to reduce or eliminate the use of assertions in the
production code (i.e. not test code). See issue 43 for an example of how
this can cause an application (thread) to panic when reading an unusual
file. Not all of the changes were as simple as returning an Err, since some
functions did not return a Result. Also, the error type used (InvalidData)
is just a catch-all with a message, and in some cases a more refined error
type may be in order.

cargo test passes
2021-07-12 17:28:39 -07:00
John-John Tedro 8fd133eccf
Store 4 bytes in FourCC instead of a String (#45) 2021-01-27 18:51:03 -08:00
Alfred Gutierrez 0f373b03db
Box summary and to_json traits. (#29)
* Add Mp4Box traits for getting json or text summary for each box.

* fix test and serde version.

* skip serializing entries

* skip serializing sample_sizes

* Add custom serializer for FixedPoint types.
2020-09-08 22:24:34 -07:00
Alf 71f0f78ae6 remove duplicated code. 2020-08-24 22:00:48 -07:00
Alf 4df1097948 Update mp4dump example and update box_size to method in all boxes. 2020-08-24 21:49:58 -07:00
Alf d51a193272 Add mp4dump example and update all mp4boxes with get_type and get_size methods. 2020-08-23 22:11:59 -07:00
Ian Jun 0abb242037
Refactoring (#17)
* Add ReadBox trait

* Add boxtype macro

* Remove offset in BoxHeader

* Fix parsing error when box has largesize

* Remove duplicated codes reading version and flags

* Update examples

* Fix test failure

* Rename I/O position moving functions

* skip_read() to skip_bytes()
* skip_read_to() to skip_bytes_to()
* skip_write() to write_zeros()

* Rename I/O position moving functions

* skip_read() to skip_bytes()
* skip_read_to() to skip_bytes_to()

* Ensure skip_bytes() does not go back.

Co-authored-by: Byungwan Jun <unipro.kr@gmail.com>
2020-08-06 20:35:08 -07:00
Ian Jun 3104a2d95b
Feature/mp4copy (#14)
* Add ReadBox trait

* Add boxtype macro

* Remove offset in BoxHeader

* Fix parsing error when box has largesize

* Remove duplicated codes reading version and flags

* Add avc1 box

* Add mp4a box

* Add mp4a box

* Add DecoderSpecificDescriptor in esds box

* Add necessary sub-boxes to stbl box

* Improve ReadBox::read_box()

* Add smhd box

* Refactor BoxHeader

* Refactor BMFF

* Refactor

* Add some functions to get offset and size of sample

* Add Mp4Reader::read_sample() that read media samples

* Move Mp4Reader to reader.rs

* Add mandatory check when reading boxes

Add some methods to Mp4Reader, TrackReader
Format codes

* Update mp4info

* Refactor common types

* Add FixedPointX types

* Add media configuration, profile, ...

* Add initial Mp4Writer

* Run cargo fmt

* Add Mp4Writer and examples/mp4copy

* Add test codes for Avc1Box and Mp4aBox

* Remove prefix "get_" from method names

* Rename atoms to mp4box

* Fix some bugs

Co-authored-by: Byungwan Jun <unipro.kr@gmail.com>
2020-08-04 16:56:59 -07:00
Renamed from src/atoms/hdlr.rs (Browse further)