686 Commits

Author SHA1 Message Date
tofunmi
d4db00e51a Update FrameProcessor.create() to accept an input track type.
Based on [this conversation thread](https://chat.google.com/room/AAAA--f88ao/76Rem_cRCK8), I've opted to update the existing FrameProcessor.create() rather than deprecate it, as it is unlikely to be in use by apps outside google3.

PiperOrigin-RevId: 506920930
2023-02-08 14:46:49 +00:00
huangdarwin
557b7dcc71 Demo: Request READ_MEDIA_VIDEO on API 33+
More info in: https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

PiperOrigin-RevId: 506908079
2023-02-08 14:42:52 +00:00
kimvde
87ff3157c9 Update Composition structure to take List instead of ImmutableList
This is more flexible for apps and more consitent with the Player API.

PiperOrigin-RevId: 506901645
2023-02-08 14:38:57 +00:00
samrobinson
73d4b67e46 Expand createNoSupportedMimeTypeException for HDR ColorInfo case.
PiperOrigin-RevId: 506900817
2023-02-08 14:35:02 +00:00
kimvde
90de454e1e Adapt TransformationResult for multi-asset
PiperOrigin-RevId: 506898392
2023-02-08 14:31:02 +00:00
samrobinson
937fcf9c4a Refactor TransformationException.createForCodec method overloads.
* Overload added `(cause, errorCode, isVideo, isDecoder, details)`,
where `details` is a string of values to be added to the error message
of the `TransformationException`.
* Overload with `MediaFormat` and `mediaCodecName` moved to
`DefaultCodec`, because all usages of that overload were from
`DefaultCodec`, and this allows a simplified API because of internally
stored values.
* `mediaCodecName` removed from overload that takes a `Format`.
* Reordered `createForCodec` parameters.

PiperOrigin-RevId: 506895268
2023-02-08 14:27:04 +00:00
kimvde
83074c0dcd Rename Transformer callbacks
PiperOrigin-RevId: 506890459
2023-02-08 14:23:02 +00:00
samrobinson
eb4b6f812c Implement a ChannelMixingAudioProcessor.
PiperOrigin-RevId: 506886903
2023-02-08 14:19:05 +00:00
claincly
c09904e143 Prefer hardware encoders in EncoderSelector.
In encoding small and odd-numbered resolutions, like `316x61` ([this image](https://upload.wikimedia.org/wikipedia/commons/6/65/100winners.png)), the current fallback logic prefers a software encoder to hardware ones. The assumption was, the encoder factory applies the encoder size alignment and changes the resolution to `316x60` for SW encoders and `316x64` for HW ones. SW encoders is selected because the supported resolution 60 is closer to requested 61, than the hardware supported 64.

This change changes the default encoder selection process to only expose hardware encoders if there is any.

PiperOrigin-RevId: 506879983
2023-02-08 14:15:03 +00:00
kimvde
14210d3df3 Rename inputFormat to firstInputFormat in multiple places
With multi-asset, the sample pipelines can process more than one
MediaItem. The renaming makes it clear that the format passed to the
SamplePipeline constructors is the one corresponding to the first
MediaItem. Indeed, the first format is the one used to configure the
SamplePipelines.

PiperOrigin-RevId: 506879260
2023-02-08 14:11:01 +00:00
samrobinson
bfee268e3f Turn off ExoPlayer metrics reporting when used by Transformer.
This avoids affecting ExoPlayer metrics with non-typical usage.

PiperOrigin-RevId: 506878231
2023-02-08 14:06:59 +00:00
tofunmi
8a8fd8dbe5 Update duration & frame rate javadoc in EditedMediaItem
PiperOrigin-RevId: 506874799
2023-02-08 14:03:02 +00:00
kimvde
3635fe7abe Add MediaItem change listener
PiperOrigin-RevId: 506868341
2023-02-08 13:59:03 +00:00
kimvde
23a544025d Use CompositeAssetLoader in Transformer
PiperOrigin-RevId: 506863538
2023-02-08 13:55:01 +00:00
tofunmi
8121709605 Add ImageAssetLoader and ImageConfiguration.
PiperOrigin-RevId: 506619637
2023-02-08 13:46:57 +00:00
samrobinson
83bc474f3c Clarify case where HDR encoder and muxer have no shared mime type.
The prior version (with the call to createEncodingException) could
never occur as select...SupportedMimeType already checks for HDR
editing support. This change ensures we throw before creating an
encoder, gives a better error code and allows future simplifications
around createForCodec (see child CL).

PiperOrigin-RevId: 506308290
2023-02-02 16:05:21 +00:00
kimvde
b8ec982ee3 Pass a Composition to Transformer callbacks
PiperOrigin-RevId: 506304101
2023-02-02 16:01:06 +00:00
kimvde
c67cfbf8ce Undeprecate startTransformation(MediaItem, String)
This overload is helpful to apps transcoding a MediaItem without edits.

PiperOrigin-RevId: 505987852
2023-02-01 15:11:33 +00:00
kimvde
8caf836053 Make Composition fields public
Transformer callbacks will take a Composition instead of a MediaItem.
Apps should be able to see what this Composition contains.

PiperOrigin-RevId: 505976561
2023-02-01 15:07:31 +00:00
huangdarwin
e7ac678ba4 HDR: Add device checks and mh for GL tone mapping PixelTests.
Add checks to GL tone-mapping pixel tests, to ensure the device's decoder, API
version, and OpenGL implementation support GL tone-mapping before attempting it.

These tests should be run on mobile harness, to detect per-device failures, and
so are moved to transforemr/mh. Per b/263395272, these tests should ultimately
be in an effect/mh directory.

PiperOrigin-RevId: 505749974
2023-02-01 14:59:13 +00:00
samrobinson
d7cc12c0da Add check for isIdentity in ChannelMappingMatrix.
Make clearer the intermediate matrix property names.

PiperOrigin-RevId: 505732563
2023-02-01 14:50:46 +00:00
samrobinson
4f61c73df9 Add ChannelMixingMatrix property unit tests.
PiperOrigin-RevId: 505720834
2023-02-01 14:46:24 +00:00
kimvde
e7bc263c4d Pass an EditedMediaItem to AssetLoader.Factory
PiperOrigin-RevId: 505671326
2023-02-01 14:42:11 +00:00
kimvde
47b32594ee Add error message if track is added during transformation
PiperOrigin-RevId: 505670386
2023-02-01 14:38:00 +00:00
kimvde
4a66ad5dd1 Remove ParcelFileDescriptor output from Transformer
ParcelFileDescriptor is quite specific and removing it allows to have
less overloads of startTransformation.

A follow-up CL will undeprecate the overload that takes a MediaItem.

PiperOrigin-RevId: 505670321
2023-02-01 14:33:43 +00:00
huangdarwin
fef3e804a0 Transformer: Make it clear that getExpectedColorInfo is input.
Otherwise, it's not clear if it's the expected output.

Renaming-only change. No functional change intended.

PiperOrigin-RevId: 505103740
2023-02-01 14:25:17 +00:00
samrobinson
f924fcb8b4 Generalise UnhandledAudioFormatException for non-input use cases.
PiperOrigin-RevId: 505084963
2023-02-01 14:12:25 +00:00
kimvde
e5e17d6f2c Add EditedMediaItemSequence and Composition objects
PiperOrigin-RevId: 505047245
2023-02-01 13:59:32 +00:00
kimvde
9759849001 Make setResolution package private
- Usages in 1P apps have been removed.
- setResolution should be removed when refactoring fallback.

PiperOrigin-RevId: 505043425
2023-02-01 13:55:11 +00:00
kimvde
341f2d6b3a Move flattenForSlowMotion to EditedMediaItem
PiperOrigin-RevId: 504867150
2023-02-01 13:50:59 +00:00
samrobinson
728619018b Move audio buffer/array test utility methods to TestUtil.
PiperOrigin-RevId: 504611069
2023-01-25 20:37:34 +00:00
kimvde
5ed72efbe0 Move removeAudio/Video to EditedMediaItem
Also add a Builder to EditedMediaItem to avoid having a constructor with
many optional parameters, or a chain of constructors.

PiperOrigin-RevId: 504588544
2023-01-25 20:25:23 +00:00
samrobinson
7abbd6aa1f Use EMPTY_BUFFER in SpeedChangingAudioProcessorTest.
PiperOrigin-RevId: 504264862
2023-01-25 19:56:51 +00:00
samrobinson
a010ebf7b6 Consolidate TransformationResult.transformationException test usage.
PiperOrigin-RevId: 504257627
2023-01-25 19:48:31 +00:00
samrobinson
f440fea738 Move AudioMixer classes from transformer.audio to transformer package.
Transformer convention has been to avoid splitting into packages unless
necessary.

See https://jlbp.dev/JLBP-2: "Prefer fewer packages over more packages
to avoid unnecessarily publicizing internal details, since any
dependency across package boundaries needs to be public.

PiperOrigin-RevId: 503463294
2023-01-23 13:52:28 +00:00
samrobinson
3055de94ac Don't use transformationResult with timeout/unexpected exceptions.
PiperOrigin-RevId: 503187291
2023-01-23 13:34:51 +00:00
kimvde
4f6b83e2c3 Remove usages of deprecated startTransformation
PiperOrigin-RevId: 503138745
2023-01-23 13:21:42 +00:00
kimvde
45596fcd1e Make startTransformation methods take an EditedMediaItem
Usages of the deprecated methods in Transformer.Builder will be removed
in a follow-up CL.

PiperOrigin-RevId: 502889423
2023-01-23 13:12:54 +00:00
kimvde
a043c8c204 Avoid re-encoding if video effects are no-op
This is to avoid regressions introduced by removing the convenience
methods from TransformationRequest.

PiperOrigin-RevId: 502864512
2023-01-23 13:08:38 +00:00
samrobinson
a44032c59b Add ColorInfo to TransformationResult.
TESTED: Manually verified the ColorInfo is propagated when VSP is used.
PiperOrigin-RevId: 502843773
2023-01-23 12:59:59 +00:00
samrobinson
76af4270a9 Generate silent audio if no audio track is available.
To always generate silent audio, `removeAudio(true)` can be used in conjunction.

PiperOrigin-RevId: 502814315
2023-01-18 13:21:57 +00:00
kimvde
6b6e4993b9 Add EditedMediaItem class
This class will be used in a follow-up CL.

PiperOrigin-RevId: 502615323
2023-01-18 13:16:48 +00:00
samrobinson
2cc64a037c Add resolution fallback for 25% of requested.
If a device only supports 1920x1080 as maximum resolution, then adding
the 25% case ensures 8k is reduced correctly.

PiperOrigin-RevId: 502588364
2023-01-18 13:06:39 +00:00
samrobinson
5da086fe01 Add a unit test to check 2/3 resolution supported.
PiperOrigin-RevId: 502573469
2023-01-18 13:01:35 +00:00
kimvde
55aeb76e0c Add CompositeAssetLoader
This is an AssetLoader that wraps a sequence of AssetLoaders. It will
be used for constrained multi-asset.

This class can currently only concatenate media items with the exact
same format.

PiperOrigin-RevId: 502525796
2023-01-18 12:51:50 +00:00
kimvde
89e14989b3 Remove setScale and setRotationDegrees from TransformationRequest
Also remove usages of TransformationRequest convenience methods
(setScale, setRotationDegrees and setResolution).

Some usages of setResolution can't be removed yet because they are used
for fallback.

PiperOrigin-RevId: 502415748
2023-01-17 03:38:19 +00:00
kimvde
a4f9f9487b Add the possility to shift frame timestamps in SampleConsumer
This is needed for constrained multi-asset to shift the timestamps of
the media items that are not the first in the sequence.

PiperOrigin-RevId: 502409923
2023-01-17 03:30:32 +00:00
claincly
c86d70a98b Allow forcing duration in FrameworkMuxer.
PiperOrigin-RevId: 501865706
2023-01-17 03:02:43 +00:00
huangdarwin
4ade37c48d HDR: Implement PQ to SDR tone-mapping.
Tested manually on the Pixel 7 and Samsung S10.

PiperOrigin-RevId: 501626354
2023-01-17 02:46:59 +00:00
huangdarwin
4f4f28b923 Transformer: Clarify setResolution javadoc.
This class may be removed soon, but in the meantime clarify this method's
javadoc summary fragment to make it marginally clearer that this only affects
the "displayed" height instead of the "encoded" height.

PiperOrigin-RevId: 501582219
2023-01-17 02:39:07 +00:00