712 Commits

Author SHA1 Message Date
kimvde
6d623bfad7 Split TransformerEndToEndTest
Split test/ TransformerEndToEndTest into SingleMediaItemEndToEndTest and
SingleSequenceEndToEndTest to reduce the file size and split the tests
by category.

PiperOrigin-RevId: 515039502
2023-03-14 07:42:55 +00:00
kimvde
bf60302cf2 Make sure errors thrown in the PlayerListener are not swallowed
PiperOrigin-RevId: 515037497
2023-03-14 07:42:10 +00:00
kimvde
d152175e27 Remove VideoSamplePipeline unused param
PiperOrigin-RevId: 515002313
2023-03-14 07:38:10 +00:00
samrobinson
320d9a7ed2 Verify the audio properties being used within Transformer.
Add TransformerAudioEndToEndTest to emulated tests.

PiperOrigin-RevId: 514991434
2023-03-14 07:37:26 +00:00
kimvde
67d15ec575 Fix threading issueis in SequenceAssetLoaderListener
Callbacks onTrackCount and onTrackAdded can be called simultaneously
from different threads.

Before this fix, it was possible for the MuxerWrapper and
FallbackListener track count to never be set, or to be set
with incorrect values.

PiperOrigin-RevId: 514779719
2023-03-14 07:35:25 +00:00
tofunmi
e478d81b52 Update effect to take in and use a GlObjectsProvider
PiperOrigin-RevId: 514744747
2023-03-14 07:33:25 +00:00
samrobinson
f07e6b63ea Fix AudioMixer javadoc.
PiperOrigin-RevId: 514699994
2023-03-07 15:50:33 +00:00
samrobinson
3264cb8271 Pass Metadata to Muxer when adding a track.
PiperOrigin-RevId: 514575400
2023-03-07 11:56:53 +00:00
kimvde
5115df1147 Rename CompositeAssetLoader to SequenceAssetLoader
This clarifies that a SequenceAssetLoader loads data corresponding to an
EditedMediaItemSequence.

PiperOrigin-RevId: 514442681
2023-03-07 11:55:22 +00:00
tofunmi
fe38901028 ImageAssetLoaderTest minor fixes
PiperOrigin-RevId: 514436359
2023-03-07 11:54:36 +00:00
tofunmi
f4b88cd8a2 Add ImageAssetLoader tests.
PiperOrigin-RevId: 514431184
2023-03-07 11:53:36 +00:00
kimvde
0f8b67b875 Make onOutputFormat nullable
- This is to make sure we know about all the tracks before initializing
the SamplePipelines. This allows to set the muxer and the fallback
listener track count before the SamplePipelines are built.
- As a result, the test files had to be updated because the order in
which the tracks are written has changed.
- The ImageAssetLoader also had to be updated to call onOutputFormat
repeatedly until it returns a non-null SampleConsumer.
- Also fix the trackCount sent to the muxer and fallback listener. The
correct track count can be computed now that we know about all the
tracks before building the SamplePipelines.

PiperOrigin-RevId: 514426123
2023-03-07 11:52:52 +00:00
tofunmi
efaf4e3f33 Remove effect/SimpleBitmapLoader & replace with DataSourceBitmapLoader
PiperOrigin-RevId: 513824487
2023-03-07 11:46:58 +00:00
kimvde
71fb4f9a5c Make sure that tracks are transcoded/transmuxed consistently
All audio tracks should either all be transcoded or all be transmuxed.
Same for video tracks.

To achieve this, simplify the behaviour of transmuxAudio/Video.

PiperOrigin-RevId: 513809287
2023-03-07 11:46:07 +00:00
samrobinson
07ba24ab1a Provide TransformerInternal with the AssetLoader output format.
TI can use this Format as part of creating the SamplePipelines.

PiperOrigin-RevId: 513777622
2023-03-07 11:45:16 +00:00
andrewlewis
82119bbbc2 Fix typo
PiperOrigin-RevId: 513529059
2023-03-02 17:20:30 +00:00
samrobinson
ae4471debf Add getNormalizedTrackType, mapping image to video track type.
PiperOrigin-RevId: 513514142
2023-03-02 17:18:39 +00:00
samrobinson
65afd40622 Only init SpeedChangingAudioProcessor if Format.Metadata not null.
If the Metadata passed to SegmentSpeedProvider is null, then the
SegmentSpeedProvider will always return 1f from getSpeed.

Initializing a SpeedChangingAudioProcessor requires a SpeedProvider.
Once configured,this audioProcessor is always active, so buffers are
passed through it. Because getSpeed is always 1, the processor performs
a no-op, but still has to do a buffer copy for each buffer.

By not initializing the audio processor when metadata is null, this
copy can be skipped and the audio pipeline is more performant.

Note: This change does not affect the multiple media-item case, which
is not supported with speed changes, as per Transformer API
documentation.
PiperOrigin-RevId: 513261811
2023-03-02 13:21:41 +00:00
ibaker
c07cf3dc41 Remove @see tags with <a> tags
These are not supported by Dackka

#minor-release

PiperOrigin-RevId: 513176533
2023-03-01 17:25:48 +00:00
andrewlewis
cccc582595 Don't log removed encoders
We shouldn't have this logging unless we really need it to debug
a specific problem, as it can be noisy (even at debug level).

PiperOrigin-RevId: 512904412
2023-03-01 17:25:03 +00:00
kimvde
d2d5174f09 Handle multiple sequences in a Composition
This lays the groundwork for full multi-asset, and more particularly for
adding looping background audio.

PiperOrigin-RevId: 512887888
2023-03-01 17:22:10 +00:00
claincly
c7b4ec4d65 Allow video format change.
Uses the first mediaItem's format as the output format.

If there is `Presentation` supplied in the `Composition.effects`, add it as the
last effect of the first EditedMediaItem.

PiperOrigin-RevId: 512082659
2023-02-27 18:45:32 +00:00
kimvde
0afe5923d8 Clarify some threading requirements.
PiperOrigin-RevId: 512079471
2023-02-27 18:44:26 +00:00
kimvde
0134d7b048 Update experimentalSetForceAudioTrack Javadoc to throw
This is consistent with the code behaviour.

PiperOrigin-RevId: 512073465
2023-02-27 18:43:38 +00:00
kimvde
dd8b64787a Small fixes in CompositeAssetLoader
PiperOrigin-RevId: 512038052
2023-02-27 18:39:57 +00:00
samrobinson
4b09a29082 Fix broken test due to file not found.
PiperOrigin-RevId: 512012099
2023-02-27 18:37:42 +00:00
kimvde
c2fd7339e1 Throw when the video track disappears during export
Throw when the output has a video track but the current MediaItem in
the sequence doesn't have any video.

PiperOrigin-RevId: 512004463
2023-02-27 18:36:51 +00:00
samrobinson
a6932f9bdd Propagate PCM encoding passed to AudioSamplePipeline.
PiperOrigin-RevId: 511810757
2023-02-27 18:33:48 +00:00
huangdarwin
cc1ca860b1 Test: Add format codec info and update HDR10 file to 720p.
Add format codec info, which can make test skipping checks more similar to the
actual Transformer decoder checks.

Also for the test file, the actual format was 720p, but somehow the file name and
media metadata indicated 1080p. This format mismatch led to some decoding errors,
so fix the format (and associated errors). This also allows us to remove the
exception catch in ForceInterpretHdrVideoAsSdrTest, which was included due to
errors from the incorrect format.

PiperOrigin-RevId: 511809507
2023-02-27 18:32:55 +00:00
kimvde
ecf168b359 Clarify slow mo flattening Javadoc
PiperOrigin-RevId: 511778088
2023-02-27 18:31:01 +00:00
kimvde
dd5dd76595 Improve shouldTranscode() logic
PiperOrigin-RevId: 511767953
2023-02-27 18:29:20 +00:00
kimvde
5c54a7dffb Add unit tests for audio track dis(appearing) during export
PiperOrigin-RevId: 511764841
2023-02-27 18:28:14 +00:00
kimvde
01e35ad13b Document that slow mo flattening is only supported for single-asset
PiperOrigin-RevId: 511757712
2023-02-27 18:27:17 +00:00
kimvde
31c44c7061 Split transmux into transmuxAudio/Video
- Split the transmux setting into transmuxAudio and transmuxVideo. This
  is more flexible for apps and will also be useful for unit testing
  (particularly as we can't test video transcoding on Robolectric at the
  moment).
- Move these settings to Composition. It makes sense for these settings
  to be next to forceAudioTrack. Apps may also want to set these
  settings based on the current Composition's MediaItems.
- Add a Composition.Builder because Composition now contains a few
  optional fields.

PiperOrigin-RevId: 511708618
2023-02-27 18:26:30 +00:00
samrobinson
2baa70206c Fix disallowed tag.
If ChannelMixingMatrix is public, this causes code to not build.

PiperOrigin-RevId: 511500694
2023-02-27 18:25:27 +00:00
kimvde
bede06546d Restrict SampleConsumer and OnMediaItemChanged threading
This is more future-proof because it is likely to simplify the upcoming
changes to the sample pipelines.

PiperOrigin-RevId: 511492014
2023-02-27 18:24:22 +00:00
samrobinson
f4d470ac4c Only log list of removed encoders if not empty.
Logcat had the following lines, with no other information.
```
DefaultEncoderFactory: Encoders removed for resolution:
DefaultEncoderFactory: Encoders removed for bitrate:
DefaultEncoderFactory: Encoders removed for bitrate mode:
```
PiperOrigin-RevId: 511470231
2023-02-27 18:23:29 +00:00
kimvde
9771629498 Make sure that VideoSamplePipeline is picked for image input
PiperOrigin-RevId: 511449658
2023-02-27 18:22:28 +00:00
kimvde
2365bbf3db Document that the output file is not deleted in case of error/cancel
PiperOrigin-RevId: 511189130
2023-02-27 18:19:56 +00:00
huangdarwin
465301da7c MediaFormatUtil: Reduce Color API 29 restriction to API 24.
Implement getMediaFormatInteger, a helper method simulating mediaformat.getInteger(name, defaultValue).

This reduces the API 29 restriction from MediaFormatUtil.getColorInfo to API 24, in
particular removing the method-based restriction to a constant-based restriction,
so that we can reduce usage of the API 29 class.

This also allows us to slightly simplify prior use-cases where we'd check
containsKey and getInteger to have a default value.

PiperOrigin-RevId: 511184301
2023-02-27 18:18:53 +00:00
kimvde
faad46318b Fix clipping in AudioSamplePipeline
When clipping a MediaItem with start time > 0, the audio was ending
before the video. This is because:
- Audio timestamps are computed based on the sample sizes, with a start
  time set to streamOffsetUs (i.e. the streamStartPositionUs is not
  taken into account).
- The SamplePipeline was subtracting streamStartPositionUs from the
  timestamps before sending the samples to the muxer.
- As a result, the audio timestamps were shifted by
  streamStartPositionUs, while they should be shifter by streamOffsetUs.

PiperOrigin-RevId: 511175923
2023-02-27 18:18:00 +00:00
samrobinson
37bb432869 Expand and refactor TransformerInternal#shouldTranscode.
* Account for `AssetLoader` output types.
* Consider cases that are not audio/video specific.
* Use `Format#sampleMimeType` for track specific conditions to check.
* Untangle `SamplePipeline` initilization from `AssetLoader` state.

PiperOrigin-RevId: 511020865
2023-02-27 18:14:47 +00:00
kimvde
86dca78845 Support added/removed audio track between MediaItems
- Add silent audio when the output contains an audio track but the
  current MediaItem doesn't have any audio.
- Add an audio track when generateSilentAudio is set to true.

PiperOrigin-RevId: 511005887
2023-02-27 18:13:58 +00:00
huangdarwin
518fe3771a HDR: Fix ForceInterpretHdrVideoAsSdrTest, and expand to all APIs.
Previously, this was limited to API 29. Expand this to all API versions.

Also, update the test to:
(1) skip based on SDR format input instead of HDR format input
(2) Check the exception message in order to disambiguate between the decoder tone
mapping error, and general video format support error.

PiperOrigin-RevId: 511002218
2023-02-27 18:12:06 +00:00
kimvde
ac12b96f11 Fix stuck muxer
Unstuck the muxer if the next timestamp in the track with the minimum
timestamp is larger than this minimum timestamp plus
MAX_TRACK_WRITE_AHEAD_US.

PiperOrigin-RevId: 510977088
2023-02-27 18:09:20 +00:00
huangdarwin
d1df8e21d2 HDR: Remove comment explaining force sdr behavior with assetloaders.
Before, if the upstream AssetLoader provides HDR to the VideoSamplePipeline when
HDR_MODE_EXPERIMENTAL_FORCE_INTERPRET_HDR_AS_SDR is requested, the
VideoSamplePipeline would attempt to tell the AssetLoader to output SDR, which
could be accomplished via MediaCodec tone-mapping in the AssetLoader.

However, this makes an assumption of the AssetLoader implementation, and
AssetLoaders may not all implement support for decoder tone-mapping. Remove javadoc
attempting to explain how AssetLoaders (ex. custom ones) could behave.

PiperOrigin-RevId: 510956820
2023-02-27 18:05:16 +00:00
samrobinson
4a7326a286 Pass AudioFormat to ASP#computeNextEncoderInputBufferTimeUs.
This method uses sampleRate, channelCount and pcmEncoding, so passing
AudioFormat is easier.

This will lead into a future change that builds the
encoderInputAudioFormat from encoder.getConfigurationFormat()

PiperOrigin-RevId: 510956177
2023-02-27 18:04:26 +00:00
huangdarwin
84acfe7867 Effect: Rename to ScaleAndRotateTransformation
Rename ScaleToFitTransformation to ScaleAndRotateTransformation.

This better represents the operations that can be accomplished using this
effect. The name was originally named ScaleToFit* because it's not obvious how
to scale to fit using OpenGL, and this effect handled the scaling to fit in a way that no other MatrixTransformations did.

However, it's hard to discover how to rotate when skimming names of effects, so
it's probably more useful to convey that this effect rotates, than that it
scales to fit.

PiperOrigin-RevId: 510480078
2023-02-27 18:02:45 +00:00
huangdarwin
f295dd4211 HDR: Add colorinfo to exception logs.
Format.toString unfortunately doesn't log colorInfo, and as Format holds a very
large set of values, it's unclear that it should. ColorInfo is useful for codec
exceptions though, so log this in ExportException.createForCodec.

PiperOrigin-RevId: 510475520
2023-02-27 18:01:53 +00:00
andrewlewis
b89b13f16b Align test codec caps check with real implementation
PiperOrigin-RevId: 510437262
2023-02-27 17:57:30 +00:00