1208 Commits

Author SHA1 Message Date
sheenachhabra
69c555be0a Move retrieveTrackFormat() method to TestUtil
TestUtil class is more appropriate for the given method.
In the next CL, the only method in FileUtil.java will be moved back
into transformer library and the FileUtil class will be removed.

PiperOrigin-RevId: 605648034
2024-02-09 09:18:14 -08:00
sheenachhabra
8a758c2ed7 Replace setModificationTime API with setTimestampData in Mp4Muxer
The new API will take both `creation time` and `modification time`.

Till now, Mp4Muxer wrote `modification time` in both
`creation time` and `modification time` field, which was
incorrect.

PiperOrigin-RevId: 605590623
2024-02-09 04:15:53 -08:00
tofunmi
4d29d8f012 DefaultAssetLoaderFactory: Simplify file extension retrival
Change the file extension retrieval back to how it was before 5488d33da8 to reduce the change of false negatives in `isImage()`

PiperOrigin-RevId: 605281186
2024-02-08 05:01:03 -08:00
tofunmi
2cb9d9b383 Export: Add methods to determine the conversion process of a track
PiperOrigin-RevId: 604754827
2024-02-06 13:58:14 -08:00
sheenachhabra
20053dcdc6 Test output file's metadata using MetadataRetriever
Earlier implementation compared the whole file against a golden
data. The new implementation compares only the metadata being tested.
This will avoid updating the golden data when any unrelated change
(unrelated to scenario being tested) is made.

Added a separate test to compare the whole output file against a golden data.

PiperOrigin-RevId: 604692985
2024-02-06 10:36:47 -08:00
samrobinson
c768e60bf2 Clearer testing of isEnded state of AudioGraphInput.
PiperOrigin-RevId: 604680924
2024-02-06 10:00:24 -08:00
andrewlewis
e683b9a506 Expand encoding operating rate workaround
PiperOrigin-RevId: 604602441
2024-02-06 04:15:49 -08:00
tofunmi
4da576f05f Support transmux when both no op effects and regular rotations are set
PiperOrigin-RevId: 604319412
2024-02-05 08:05:32 -08:00
samrobinson
f8352580cb Add AudioGraphInput tests around getOutput behaviour.
PiperOrigin-RevId: 604297126
2024-02-05 06:18:46 -08:00
tofunmi
49c6d25106 Move setting the muxerWrapper rotation out of shouldTranscodeVideo()
Before supporting transmuxing when both no op effects and regular rotations are set, move setting the muxerWrapper rotation out of shouldTranscodeVideo() to ensure the muxerWrapper rotation is only set at the appropriate times.

This cl also ensures the state between the muxerWrapper and the list of video effects is consistent by clearing 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.

PiperOrigin-RevId: 604292052
2024-02-05 05:54:11 -08:00
samrobinson
029071a342 Improve checks around AudioGraphInput configuring with requested format
Also adds extra AudioGraphInputTest cases.

PiperOrigin-RevId: 603690041
2024-02-02 08:13:54 -08:00
samrobinson
2b52c2d74f Add extra documentation to AudioGraphInput.
PiperOrigin-RevId: 603663084
2024-02-02 05:47:05 -08:00
sheenachhabra
30b60f6c60 Refactor assertFileHasColorTransfer method
PiperOrigin-RevId: 603662313
2024-02-02 05:42:28 -08:00
huangdarwin
d87179b463 Effect: Remove stale TODO.
PiperOrigin-RevId: 603632255
2024-02-02 02:55:13 -08:00
huangdarwin
a27511cc50 Effect: Remove inputColorInfo from create() methods.
Transformer export and ExoPlayer previewing both read inputColorInfo from
registerInputStream now, instead of maintaining a consistent input color
throughout multiple streams in a sequence.

Therefore, we can remove inputColor-related arguments and methods now.

PiperOrigin-RevId: 603423509
2024-02-01 11:09:57 -08:00
sheenachhabra
198e3fb166 Assert Export output mime type by retrieving output file metadata
PiperOrigin-RevId: 603333340
2024-02-01 04:49:02 -08:00
huangdarwin
554530a426 Effect: Remove unused setOutputSurfaceInfo method
This hasn't been used, since b466b06ace

PiperOrigin-RevId: 603097097
2024-01-31 10:49:42 -08:00
huangdarwin
1163660918 Test: Save test bitmaps in a separate loop from assertions.
This means all bitmaps will save even if an assertion fails somewhere in the test
method

PiperOrigin-RevId: 603067528
2024-01-31 09:12:56 -08:00
samrobinson
65c354029a Add TODO around using improved buffer assignment logic.
PiperOrigin-RevId: 603019987
2024-01-31 05:36:09 -08:00
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