1139 Commits

Author SHA1 Message Date
sheenachhabra
5147eb1a65 Add audio/video sample mime type in ExportResult
PiperOrigin-RevId: 603013441
2024-01-31 05:00:12 -08:00
sheenachhabra
fd2ea22e47 Allow AV1 output mime type in FrameworkMuxer
The `MediaMuxer` (FrameworkMuxer) supports AV1 mime type from API 34.
For this to work track `Format/MediaFormat` must have `CSD`
data.

Change also include providing AV1 option in demo app.

Transmuxing of an AV1 mime type input will not work because
`Extractor` does not extract AV1 CSD data.

Verified changes manually via demo app.

PiperOrigin-RevId: 603002380
2024-01-31 04:02:21 -08:00
sheenachhabra
c6cb6c4922 Move FileUtil.java into test_utils module
FileUtil.java can be extended to add more methods for validating
output file. This will be used in Transformer's robolectric tests and
instrumentation tests hence need to move to a common module.

PiperOrigin-RevId: 602789503
2024-01-30 11:33:10 -08:00
huangdarwin
3e59c113d7 Transformer: Allow single-sequence mixing HDR and SDR input.
Previously, input assets had to be all SDR or all HDR.

After this CL, if tone-mapping is requested, HDR and SDR may mix in any order. If tone-mapping is not requested, SDR may precede HDR, but not vice versa, until SDR to HDR tone-mapping is implemented

Some changes to accomplish this include:
1. Inputting the decoded format's color to VideoFrameProcessor.registerInputStream
for each stream.
2. Calculating the estimated decoded format's color for each stream, by estimating
it based on MediaCodec tone-mapping.

PiperOrigin-RevId: 602747837
2024-01-30 09:20:41 -08:00
samrobinson
7c8a31e2b1 Remove redundant boilerplate in AudioGraphTest & AudioGraphInputTest.
* getPcmFormat Util method already sets the mime type as AUDIO_RAW.
* static final AudioFormat consts improve test case readability.

PiperOrigin-RevId: 602740007
2024-01-30 08:53:10 -08:00
sheenachhabra
03d35e3f43 Reset transformer state after resume finishes
PiperOrigin-RevId: 602467396
2024-01-29 12:32:42 -08:00
Googler
994e2fc317 Rollback of f9eb8626eb
PiperOrigin-RevId: 601912101
2024-01-26 17:55:30 -08:00
Googler
9e48fcb8fb Rollback of 2e6982be2c
PiperOrigin-RevId: 601911260
2024-01-26 17:50:24 -08:00
Googler
e0be4c2ff4 Rollback of 4d5f844c61
PiperOrigin-RevId: 601910682
2024-01-26 17:45:40 -08:00
tofunmi
4d5f844c61 Clear the list of videoEffects in trim optimization
If trim optimisation is being applied, then `EditedMediItem.effects.videoEffects` only contains no-op effects or regular rotations that get be applied in the muxer wrapper. Therefore, we should clear the list of video effects to ensure that no effect gets applied twice.

This fixes requested rotations being applied twice in trim optimization.

Manually tested to ensure all combinations of trimming+muting+rotating works at intended.

PiperOrigin-RevId: 601853203
2024-01-26 13:33:53 -08:00
tonihei
ed5b7004b4 Replace or suppress deprecated usages
Many usages are needed to support other deprecations and some
can be replaced by the recommended direct alternative.

Also replace links to deprecated/redirected dev site

PiperOrigin-RevId: 601795998
2024-01-26 10:06:18 -08:00
tofunmi
7424cffce1 Support changing input colorinfo for images
since we now can support taking in the inputColor upon registering the stream, there is no need to hardcode the image input color anymore. We should now be able to support switching between texture and image input which we couldn't before, but this is untested and not necessary.

PiperOrigin-RevId: 601784149
2024-01-26 09:17:29 -08:00
huangdarwin
b1c1c2a6dd Transformer: Plumb hdrMode into AssetLoaders instead of forceInterpret.
This allows us to also plumb whether we're doing MediaCodec tone-mapping,
which will be used in a follow-up CL in the ExoAssetLoaderVideoRenderer.

PiperOrigin-RevId: 601774435
2024-01-26 08:36:21 -08:00
tofunmi
2e6982be2c limit transmuxing to regular rotations only
PiperOrigin-RevId: 601710663
2024-01-26 02:46:50 -08:00
tofunmi
f9eb8626eb Support transmuxing when no op effects and regular rotations are set
PiperOrigin-RevId: 601419245
2024-01-25 05:34:06 -08:00
christosts
85db94782a Rollback of e364510937
PiperOrigin-RevId: 601187997
2024-01-24 11:50:24 -08:00
tofunmi
b94c7d08c1 MuxerWrapper rotation degree fix
Allow setAdditionalRotationDegrees to be called with same rotation after tracks added. This is needed for processes that mux files partially trim optimization so they don't error out after hitting the check state

Manually tested to ensure trim optimization succeeds, automated test added here as well

PiperOrigin-RevId: 601081778
2024-01-24 04:44:28 -08:00
tofunmi
5863ce7dd5 Trim optimization fix: check if audio is removed when comparing formats
#minor-release

PiperOrigin-RevId: 600493390
2024-01-22 10:14:11 -08:00
andrewlewis
6029521898 Prevent using high profile on problematic devices
[Android best
practices](https://developer.android.com/media/optimize/sharing#android_8_81_and_9)
recommend disabling B-frames on API 27, but some devices output B-frames anyway
when H.264/AVC High profile is selected. Add a workaround to force these
devices not to use high profile, to prevent B-frames being output.

`MediaMuxer` likely handles B-frames on these specific devices, but this change
allows the migration to default to in-app muxing to take place without
introducing errors, and it's a temporary workaround until B-frames are properly
supported in the in-app muxer.

PiperOrigin-RevId: 600422238
2024-01-22 04:55:54 -08:00
andrewlewis
e82393ed41 Skip 1080p test on Nexus 7, API 21
This device doesn't seem to be capable of simultaneous encode/decode at this
resolution. We don't have a good way to check the capability (we are already
checking separate decode/encode capability) so just skip this test to save time
triaging its failures.

PiperOrigin-RevId: 600399564
2024-01-22 02:52:25 -08:00
christosts
d1d03189eb Rollback of e364510937
PiperOrigin-RevId: 600393114
2024-01-22 02:19:01 -08:00
samrobinson
e364510937 Remove thread blocking for TransformerInternal#getProgress.
Thread-safe interactions with state and value.

PiperOrigin-RevId: 599810672
2024-01-19 06:04:27 -08:00
samrobinson
3e3c746368 Add javadoc to the TransformerState's for pause & resume.
Although not public, documenting what happens in each state allows for
better code understanding at a glance.

As part of this, refactored the #getProgress method to highlight that
the other options are "non standard".

PiperOrigin-RevId: 599505369
2024-01-18 07:52:02 -08:00
christosts
0e66197419 Rename TimestampIterator argument name in queueInputBitmap()
#minor-release

PiperOrigin-RevId: 599460771
2024-01-18 04:01:27 -08:00
tofunmi
5eb1f4043b disallow go links in Media3 open source code
PiperOrigin-RevId: 599455204
2024-01-18 03:28:31 -08:00
samrobinson
e41b23d2f4 Add thread-safe information & annotations to necessary fields.
This change is a small incremental step towards better thread-safety.

PiperOrigin-RevId: 598852158
2024-01-16 08:43:15 -08:00
tofunmi
5488d33da8 Transformer: add api to cutomize image loading
PiperOrigin-RevId: 598793134
2024-01-16 03:56:08 -08:00
tofunmi
6879698d7e Move setting bitmapFactory options from interface to implementation
Moves setting bitmapFactory options from BitmapLoader to DatasourceBitmapLoader

BitmapLoader is a general interface for bitmap loading that could use loading implementations other that BitmapFactory, with the rise of Glide being a loader of choice. It's best to correct this interface so that it remains generic

We can't deprecate easily because the other loadBitmap method in that case has a default implementation that relies on the first one, so the change is still breaking. BitmapLoader is public api in common, but it's @UnstableAPI and hasn't been around for very long (be38670391 added it), so it seems this is the best way forward.

PiperOrigin-RevId: 597897098
2024-01-12 11:21:48 -08:00
tofunmi
f2be3fd0cb Trim Opt: Calculate duration based on sample rate from audio format
Calculating the encoded audio buffer duration.

PiperOrigin-RevId: 597591689
2024-01-11 10:28:14 -08:00
Googler
460501fcd1 Log ExportResult information when running transformer demo app
Log elapsed time, in addition to displaying it on screen.
Reuse logging logic between tests and demo.

PiperOrigin-RevId: 597186692
2024-01-10 02:24:31 -08:00
christosts
4198f7e242 Add utility testing Player.Listener in transformer tests
PiperOrigin-RevId: 596891721
2024-01-09 04:36:45 -08:00
ibaker
62f6c64a91 Rename test.mp3 test asset to test-cbr-info-header.mp3
This file is CBR encoded with LAME, so it has an `Info` header (the CBR
equivalent to `Xing`).

A follow-up change will use this file in `Mp3ExtractorTest`.

Issue: androidx/media#878
PiperOrigin-RevId: 595938327
2024-01-05 02:31:20 -08:00
samrobinson
c230414bd3 Set the default audio encoder bitrate in DefaultEncoderFactory.
Matches the approach for video frame rate.

PiperOrigin-RevId: 595385930
2024-01-03 06:37:16 -08:00
sheenachhabra
27ae6d974e Allow creating fragmented MP4 file via InAppMuxer
PiperOrigin-RevId: 594431665
2023-12-29 04:15:01 -08:00
sheenachhabra
1609928242 Throw exception when B-frames are written to Mp4Muxer
Mp4Muxer does not support out of order B-frames. Currently it
silently writes out of order B-frames, producing an invalid file (with
negative sample durations).

Although `Mp4Extractor` is somehow able to process this invalid file and
`Exoplayer` is able to play it but that is unexpected.

The `sample.mp4` test file contains B frames. Other test files does not
contain `H264 video + AAC audio` format hence created a new test file by
running `sample.mp4` via `Transformer` after applying some effects.

PiperOrigin-RevId: 594016144
2023-12-27 08:32:36 -08:00
tofunmi
e3056dacac Rename Mp4MetadataInfo to mp4Info
PiperOrigin-RevId: 593143940
2023-12-22 11:10:30 -08:00
tofunmi
4fc11a98a1 ignore dropSamplesBeforeFirstVideoSample in audio-only streams
PiperOrigin-RevId: 593126632
2023-12-22 08:54:29 -08:00
tofunmi
7e12b9e15f Add rough progress updates in trim optimization
PiperOrigin-RevId: 593116025
2023-12-22 07:37:23 -08:00
tofunmi
1632f37d70 Transformer: Add api to drop audio samples before the first video frame
fix for Issue: androidx/media#829

Manual Testing: Viewed the transformer output file of previously problematic case in Exoplayer, Chrome, VLC, Quicktime and Safari and all showed the issue not to occur anymore. The newly produced output file can be found at https://github.com/androidx/media/assets/42352357/fdf105c1-9550-422f-b088-7900f655ac78

PiperOrigin-RevId: 593104752
2023-12-22 06:18:07 -08:00
simakova
09bde8053d Update method description for setEffects in Composition
PiperOrigin-RevId: 593071081
2023-12-22 02:51:52 -08:00
andrewlewis
ef7842dd88 Fix typo
PiperOrigin-RevId: 593061829
2023-12-22 02:04:30 -08:00
andrewlewis
1845a4ae69 Expand operating rate workaround to T612 chipset
PiperOrigin-RevId: 592916187
2023-12-21 11:52:35 -08:00
huangdarwin
0ed19937d3 Test: Remove setInputColorInfo from VFP test runner.
Instead, for input videos, use the colorInfo provided by the extractor. Similarly, for input images, use sRGB, the only color currently in use.

Textures do still need the input ColorInfo provided though.

PiperOrigin-RevId: 592875967
2023-12-21 09:06:55 -08:00
tofunmi
57d00fcca0 Rename crow_emulator_transformer_output
PiperOrigin-RevId: 592873355
2023-12-21 08:56:48 -08:00
andrewlewis
7d11ee7538 Optionally notify codec init in default decoder factory
Replace the event for notifying fallback to cover codec initialization in
general (but keeping the list of errors).

Add a flag to control whether to try non-primary codecs, with the same
documentation as the similar flag in ExoPlayer's renderer.

Make the class final as it shouldn't be necessary to subclass it.

PiperOrigin-RevId: 592869868
2023-12-21 08:42:44 -08:00
tofunmi
3081ceb179 Remove the matchInitializationData option from TransformerInternal
Essentially a manual revert of ba0724ca78

PiperOrigin-RevId: 592869049
2023-12-21 08:38:58 -08:00
huangdarwin
4774fa1a60 Test: Update tone mapping capabilities check output format.
Checking the output format's mime type may skip tests more often than we'd like,
because we may desire using a lower-spec output mimetype than what's passed in, if
based on the input's HDR mimetype value.

Therefore, update this output format to null, for tone-mapping tests

PiperOrigin-RevId: 592855713
2023-12-21 07:30:07 -08:00
Googler
e25e497227 Make DefaultDecoderFactory try multiple formats before giving up
PiperOrigin-RevId: 592622544
2023-12-20 12:07:19 -08:00
tofunmi
4ce47ccdd3 MuxerWrapper: remove unnecessary volatiles
PiperOrigin-RevId: 592569012
2023-12-20 08:37:03 -08:00
tofunmi
087c07e596 Rename OptimizationResult options
Rename options to be more accurate of what they capture

PiperOrigin-RevId: 592155563
2023-12-19 01:50:40 -08:00