122 Commits

Author SHA1 Message Date
sheenachhabra
4b7c5100f1 Move moov box generation to Boxes.java
This is a no-op change.
Like all other boxes, moov box creation can also be in
Boxes.java class.

PiperOrigin-RevId: 665359529
2024-08-20 07:47:58 -07:00
sheenachhabra
bb3948aa98 Implement interleaving of editable video tracks
The CL adds another way of writing editable video
tracks where the samples will be interleaved with the
primary track samples in the "mdat" box.

PiperOrigin-RevId: 665313751
2024-08-20 05:28:29 -07:00
sheenachhabra
ed905a6498 Refactor pending sample writing logic in Mp4Writer
The refactored method can be reused when implementing depth/editing format
interleave mode.

PiperOrigin-RevId: 663774290
2024-08-16 10:29:32 -07:00
Googler
afac17bef0 Mp4Muxer: Add support for Vp9 codec
Implement vpcCBox to provide support for muxing video encoded using the VP9 codec.

PiperOrigin-RevId: 663603654
2024-08-15 22:34:56 -07:00
sheenachhabra
7a1f3629ff Extract method to find minimum presentation timestamp across tracks
This is a ground work of implementing depth/editing format interleave mode.

PiperOrigin-RevId: 663301670
2024-08-15 07:40:27 -07:00
sheenachhabra
4df5ecb045 Rename flushPending() to writePendingTrackSamples()
The new name is more readable

PiperOrigin-RevId: 663264188
2024-08-15 04:54:19 -07:00
sheenachhabra
68eaa061e0 Add support for depth/editing file format in Mp4Extractor
PiperOrigin-RevId: 662956209
2024-08-14 09:55:01 -07:00
sheenachhabra
dbc9f5e0d1 Add EditablevideoParameter class
The parameter class will allow addition of more
parameters (link shouldInterleaveSamples), which are specific to
editable video file format.

PiperOrigin-RevId: 662923844
2024-08-14 08:13:05 -07:00
sheenachhabra
68393832b4 Use Track instead of TrackToken internally
The TrackToken is primarily for public API.
Using Track object internally will remove unnecessary
type casting at various places.

PiperOrigin-RevId: 662564224
2024-08-13 10:24:04 -07:00
sheenachhabra
96f2c7ece7 Refactor editable video track related logic
This is to reuse same logic in depth/edit file format `interleave` mode.

PiperOrigin-RevId: 662117528
2024-08-12 09:32:37 -07:00
sheenachhabra
117ac2e3f4 Create a common constant for large box size header
PiperOrigin-RevId: 661323230
2024-08-09 10:48:46 -07:00
sheenachhabra
94abb9515b Write same timestamp in edit data MP4 as in outer MP4
The exiting code ensured that the timestamp is same only when it is set by the app.

PiperOrigin-RevId: 661283124
2024-08-09 09:05:33 -07:00
kak
2202397758 Automated Code Change
PiperOrigin-RevId: 660491742
2024-08-07 12:28:25 -07:00
sheenachhabra
0530d663bc Rename muxer/Mp4Utils.java to muxer/Mp4MuxerUtil.java
PiperOrigin-RevId: 660417092
2024-08-07 09:23:53 -07:00
sheenachhabra
6a7e9132fd Write sample location key when muxing editable tracks
There are two ways to write editable tracks samples.
1. In the embedded edit data MP4.
2. Interleaved with primary tracks samples.

Initial plan was to support only option 1 but then the
decision is to support both ways. To identify between these two
an additional key will be required.

Option 2 is yet to be implemented in Mp4Muxer.

PiperOrigin-RevId: 658791214
2024-08-02 08:03:35 -07:00
sheenachhabra
86bd1df632 Move editable track type constants to container module
This is to share the constants with the extractor.

PiperOrigin-RevId: 658755661
2024-08-02 05:10:16 -07:00
Googler
aaa6561aa9 Rename tests in Boxestest
Replace the box name with Codec name in the test.

PiperOrigin-RevId: 655915063
2024-07-25 05:09:43 -07:00
Googler
d160aa2520 Modify tests in BoxesTest
Replace the string with the field from MimeType class

PiperOrigin-RevId: 655783812
2024-07-24 19:37:43 -07:00
Googler
b77f1d0f99 Add support for Audio Vorbis codec in Mp4Muxer.
Update esdsBox to support muxing of files encoded with Vorbis audio codec .

PiperOrigin-RevId: 655159074
2024-07-23 07:39:26 -07:00
Googler
3c5c81fc3e BoxesTest: Add default format builders
Move the common initialization code for format builder into separate methods to reduce code duplication.

PiperOrigin-RevId: 655118764
2024-07-23 04:54:32 -07:00
sheenachhabra
a52df6d29e Make Mp4MoovStructure.moov() method static
Creating a moov box is same as creating any other box so
there is no particular need to have a separate class for this.
In a follow up CL the method will be moved into Boxes.java along with
other box creation methods.

Made nit changes in the final fields ordering to match with
constructor parameter ordering.

PiperOrigin-RevId: 653602558
2024-07-18 06:50:42 -07:00
sheenachhabra
51d27d7575 Merge Boxes.moov() into Mp4MoovStucture.moov()
Boxes.moov() simply wraps the subboxes and this logic can be
put into main method which has all the logic of creating moov box.
This is to eventually move Mp4MoovStucture.moov() into
Boxes.java where all other box creation methods are already present.

PiperOrigin-RevId: 653319292
2024-07-17 12:15:44 -07:00
Googler
01dda6d3e5 Add support for Opus audio codec.
Implement dOpsBox to provide support for Opus audio codec

PiperOrigin-RevId: 653288049
2024-07-17 10:51:43 -07:00
Googler
951f296851 Add support for 3gpp h263 codec in Mp4Muxer.
Implement d263Box to provide support for muxing video encoded with the h263 codec.

PiperOrigin-RevId: 653188633
2024-07-17 04:53:28 -07:00
Googler
11ca78761e Add support for 3gpp amr-nb audio codec.
To support AMR audio codec(audio/3gpp) add `0x81FF` mode to create damrBox.

Add unit test and an Android end to end test.

PiperOrigin-RevId: 652438693
2024-07-15 04:48:28 -07:00
ibaker
6a9ff95bf0 Bump minSdk to 21 and remove resulting simple dead code
All other AndroidX libraries have already increased their min SDK to
21.

This change renames private symbols to remove `V21` suffixes and
similar, but doesn't change public or protected symbols with similar
names, to avoid needless breakages/churn on users of the library.

Some of the dead code removal is more complex, so I've split it out
into follow-up changes to make it easier to review.

PiperOrigin-RevId: 651776556
2024-07-12 08:11:01 -07:00
Googler
34a802ef38 Add support to MPEG4 codec in Mp4Muxer.
Add support for MPEG4 codec to enable muxing video encoded with the mp4v-es codec. Use esdsBox method to generate esds box required for Mp4v box.

PiperOrigin-RevId: 651000744
2024-07-10 06:55:00 -07:00
Googler
cf90d2624d Support for Large CodecSpecificData in ESDS box
Some external media files have CodecSpecificData greater than 128 bytes. Currently, that size
isn't fitting in one byte. Hence, added support to store large CodecSpecificDataSize, as per
ISO standard, by extending to more than one byte as required.

PiperOrigin-RevId: 650972472
2024-07-10 05:16:01 -07:00
Googler
6e18cb0053 Add support for amr-wb audio codec.
Implement damrBox to provide support for amr-wb audio codec.

Add unit test and an Android end to end test.

PiperOrigin-RevId: 650210732
2024-07-08 05:13:18 -07:00
Googler
a269355369 Refactor audioEsdsBox to esdsBox
Since the muxer supported only AAC audio codec, the esdsBox was unconditionally created within the audioSampleEntry. This CL refactors the box creation logic by moving it to the codecSpecificBox method. This is to make adding support for new audio codecs easier.

PiperOrigin-RevId: 650130935
2024-07-07 23:13:29 -07:00
sheenachhabra
3793a06bdd Add support for file format for depth/editing in Mp4Muxer
PiperOrigin-RevId: 648747038
2024-07-02 09:42:36 -07:00
Googler
3da63eeaa7 Add NAL unit parsing needed for stereo MV-HEVC playback.
Add the following NAL unit parsing utility functions that will be needed for the MV-HEVC support as proposed in Apple's HEVC stereo video interoperability profile:
- NAL unit header parsing to get the layer information needed for MV-HEVC support.
- VPS parsing, including vps_extension() needed for MV-HEVC support.
- SPS parsing modifications to support MV-HEVC.

PiperOrigin-RevId: 647329211
2024-06-27 08:39:12 -07:00
sheenachhabra
6fc0243106 Use Set instead of a List for metadata collection
All metadata entries are supposed to be unique, so Set is more appropriate.

PiperOrigin-RevId: 646907916
2024-06-26 05:29:47 -07:00
sheenachhabra
be2d68c2b3 Improve method names in Mp4Writer
PiperOrigin-RevId: 646465516
2024-06-25 07:09:12 -07:00
sheenachhabra
babc9c69c6 Remove unnecessary FileChannel from Mp4Muxer
As per the documentation, closing a `FileOutputStream`
automatically closes the associated `FileChannel`.

PiperOrigin-RevId: 646152280
2024-06-24 10:58:30 -07:00
sheenachhabra
327f728010 Move muxer closing logic from Mp4Writer to Mp4Muxer
PiperOrigin-RevId: 646134522
2024-06-24 10:11:52 -07:00
sheenachhabra
307655f6d5 Move component initialization from Mp4Muxer.Builder to Mp4Muxer
PiperOrigin-RevId: 645004885
2024-06-20 06:18:13 -07:00
kimvde
d27549d29a Skip 4K export test on Pixel 3a
PiperOrigin-RevId: 644659699
2024-06-19 01:18:05 -07:00
sheenachhabra
ded1adc092 Change sample duration type from Long to Integer
In muxer only 32-bit sample duration is supported. Earlier the duration was type
casted at different places.

PiperOrigin-RevId: 643954226
2024-06-17 04:13:00 -07:00
sheenachhabra
aeb8fd134b Write moov box at the start of the file if possible
This is done by reserving some space for moov box at the start of the file and writing it there if it fits. If it doesn't fit, then it is written at the end of the file.

PiperOrigin-RevId: 643944698
2024-06-17 03:38:11 -07:00
sheenachhabra
a39a7f06cf Remove the code to restore current output position
Muxer never uses latest output position but always writes to
a specific location, so restoring its position does not add any
value.

PiperOrigin-RevId: 642996941
2024-06-13 08:07:16 -07:00
sheenachhabra
94dff1f349 Split muxer android tests between parameterized and non parameterized
This will be helpful for adding more tests which need not to
be parameterized.

PiperOrigin-RevId: 642638702
2024-06-12 09:29:22 -07:00
sheenachhabra
0b2bca02ca Make nit improvements in muxer code
PiperOrigin-RevId: 642599475
2024-06-12 06:46:28 -07:00
sheenachhabra
d598eb064d Remove unnecessary sortKey from Mp4Muxer.addTrack()
PiperOrigin-RevId: 638647112
2024-05-30 07:37:26 -07:00
andrewlewis
174d452bf7 Add missing module registrations
PiperOrigin-RevId: 636506860
2024-05-23 04:50:01 -07:00
Googler
37c2d9957e Fragmented Mp4Muxer: add support to B-frame Muxing
Add composition time offset parameter to TRUN box to
support muxing of videos containing B-frames by FragmentedMp4Muxer.
Update TRUN box version from 0 to 1 in order to manage signed
composition time offset.

PiperOrigin-RevId: 636426397
2024-05-22 23:07:35 -07:00
Googler
55b9c391e8 Box: Implement ctts box
Add ctts box implementation to handle muxing B-frame videos.
Add method convertPresentationTimestampsToCompositionOffset to
provide sample offsets. Return empty ctts box in case of video
does not contain B-frame. Add ctts box to MoovStructure to handle
muxing the video containing B-frames.

PiperOrigin-RevId: 633537106
2024-05-14 04:32:04 -07:00
sheenachhabra
3a3145521b Replace Transformer.Muxer interface with Muxer.Muxer
PiperOrigin-RevId: 633193701
2024-05-13 06:54:19 -07:00
sheenachhabra
10e29be8b6 Allocate correct size for keys and ilst boxes in Mp4Muxer
The keys and ilst boxes in the MP4 muxer were allocated
with a fixed size of 200 bytes. This was not enough to
store the keys and values of large metadata entries, which
could cause the muxer to throw an exception. This CL allocates
the correct size for the keys and ilst boxes based on the size of the metadata entries.

PiperOrigin-RevId: 630331680
2024-05-03 02:47:14 -07:00
sheenachhabra
72013446c4 Update error message to be more specific
PiperOrigin-RevId: 629405290
2024-04-30 07:28:35 -07:00