21920 Commits

Author SHA1 Message Date
kimvde
fbf9be2f00 Fix composition player repeat mode
Some checks in SingleInputVideoGraph were causing CompositionPlayer to
throw for a single media item sequence when repeat mode was enabled. The
reason was that, in this case, no new input stream is registered to the
VideoFrameProcessor.

PiperOrigin-RevId: 715409509
2025-01-14 09:20:14 -08:00
michaelkatz
2361624222 Make MediaCodecAudioRenderer.getDurationToProgressUs protected
This method is not intended to be exposed as 'public' as it was meant
to be internal to the class/subclasses.

PiperOrigin-RevId: 715402007
2025-01-14 09:00:37 -08:00
claincly
e9e0569425 Integrate MultiInputVideoGraph in CompositionPlayer
Currently doesn't support image/video transitions

PiperOrigin-RevId: 715393251
2025-01-14 08:33:39 -08:00
dancho
8f17ab84f8 Add API for sample dependency reading to DefaultMediaSourceFactory
PiperOrigin-RevId: 715372196
2025-01-14 07:28:03 -08:00
michaelkatz
2eb8e53f8c Fix getDurationToProgress for audio renderers to reset after seeking
Currently, if a seek occurs when the audio sink was providing back pressure, the audio renderers will provide a durationToProgress based on the last non-writable sample prior to the seek.

Solution is to reset the value used for the `getDurationToProgress` when onPositionReset occurs.

This CL also makes sure to reset the value whenever the audiosink is flushed or reset.

PiperOrigin-RevId: 715361834
2025-01-14 06:49:43 -08:00
tianyifeng
f05e6a7d6e Accurately determine hasPendingData after handling the end of stream
In `AudioTrackPositionTracker.hasPendingData()` method, `sourceEnded=false` is always passed. Thus, if the `AudioTimestampPoller` hasn't entered the `STATE_TIMESTAMP_ADVANCING` before the stream ends, then the current position can be inaccurately calculated in the absence of a correct `sourceEnded` value, and `AudioTrackPositionTracker.hasPendingData` will return a wrong result.

We used to avoid calling `getPlayheadPosition()` too often, which involves expensive binder request. However, here we need to adjust a bit back to compare the `writtenFrames` directly with `getPlayheadPosition()` after handling the end of stream, when not being able to declare `sourceEnded=true` can have significant difference.

PiperOrigin-RevId: 715358137
2025-01-14 06:37:02 -08:00
shahddaghash
adb9306e2d Add format of media item to Transformer's ExportResult.ProcessedInput
This will allow us to collect info from the Format for metrics.

PiperOrigin-RevId: 715336943
2025-01-14 05:16:08 -08:00
ibaker
eefad8cbfa Deprecate mutable static MediaParserChunkExtractor.FACTORY
Follow-up to <unknown commit>

PiperOrigin-RevId: 715329316
2025-01-14 04:46:32 -08:00
ibaker
6300a55eb2 Remove usage of mutable static BundledChunkExtractor.FACTORY
PiperOrigin-RevId: 715328246
2025-01-14 04:42:20 -08:00
dancho
1892435fb3 Parse within GOP sample dependencies in ExtractorsFactory
Add helper methods to Mp4Extractor and FragmentedMp4Extractor
to convert between VideoCodecFlags and *ExtractorFlags

PiperOrigin-RevId: 715307495
2025-01-14 03:16:49 -08:00
shahddaghash
b25d6ef249 Rollback of 72a71e8b9c
PiperOrigin-RevId: 714997645
2025-01-13 09:30:39 -08:00
ibaker
a4d28b4f10 Add PGS test file
Transformed from `sample_with_srt.mkv` and provided in
https://github.com/androidx/media/pull/1979#issuecomment-2574007148

PiperOrigin-RevId: 714955725
2025-01-13 07:14:13 -08:00
jbibik
52387bb975 [ui-compose] Rename showSurface to coverSurface in PresentationState
This renaming helps prevent the consumer from including `PlayerSurface` in a Compose tree based on `state.showSurface`. This field intuitively felt like the default would be not to show the surface (correct), but had an unintended consequence of not initialising `AndroidExternal(Embedded)Surface` (since the PlayerSurface Composable would be omitted).

To avoid this confusion, the `PresentationState` should communicate to the consumer when the Surface is not ready and hence should be covered with some overlay (shutter) to prevent poor UX from observing Surface resizing/freezing/flickering.

PiperOrigin-RevId: 714951607
2025-01-13 06:59:44 -08:00
Copybara-Service
d18ad57e30 Merge pull request #1979 from wischnow:main
PiperOrigin-RevId: 714911017
2025-01-13 04:09:58 -08:00
dancho
8b33a0a50f Add a ChunkExtractor API to select codecs for sample dependency parsing
Deprecate BundledChunkExtractor.experimentalParseWithinGopSampleDependencies
in favour of
ChunkExtractor.experimentalSetCodecsToParseWithinGopSampleDependencies
which takes a VideoCodecFlags IntDef flags that represent a set of codecs.

Add a DASH test using the new API with an H.265 video.

PiperOrigin-RevId: 714901602
2025-01-13 03:30:10 -08:00
andrewlewis
0a27e7946f When reregistering frames automatically, drop after signaling EOS
In this mode there isn't an explicit signal from upstream that an input frame
is going to arrive at the `SurfaceTexture`. This means that when end-of-stream
is signaled we don't know when there won't be any more input frames.

Reject new frames in `onFrameAvailable` after input EOS is handled for the case
of reregistering frames automatically. This avoids those frames entering the
pipeline and causing us to unexpectedly handle frames after EOS.

PiperOrigin-RevId: 714858039
2025-01-13 00:43:45 -08:00
kimvde
b183bfb0cb CompositionPlayerTest: use correct video duration
PiperOrigin-RevId: 714847208
2025-01-13 00:01:42 -08:00
sheenachhabra
36be62ee8c Skip duplicate chunks in stsc box writing
Earlier muxer wrote a different entry for every chunk but as
per the spec (ISO 14496-12) exact same chunks can be combined
and only the first chunk number can be written.

PiperOrigin-RevId: 714154531
2025-01-10 13:27:02 -08:00
jbibik
28027c64fd [ui-compose] Add aspect ratio to PresentationState
It captures the information needed for the UI logic related to rendering of the video track (and later images) to the surface.

The video size will be correct only after the Player decoded the video onto the surface and can't be reliably extracted from MediaItem's metadata. The information about the video's true aspect ratio helps inform the UI elements (such as PlayerSurface Composable) how to customize the Modifiers.

Use this state in demo-compose to show off functionality of changing `PlayerSurface`'s aspectRatio

PiperOrigin-RevId: 714104260
2025-01-10 10:50:53 -08:00
sheenachhabra
33c3d5140e Rollback of 750baf2c05
PiperOrigin-RevId: 714097260
2025-01-10 10:34:56 -08:00
dancho
93f9e6574c Add missing Mp4Extractor.Flags to IntDef
PiperOrigin-RevId: 714084405
2025-01-10 09:54:19 -08:00
ibaker
e61b521b4a Clear SEI reordering queue when seeking in MPEG-TS files
This avoids outputting spurious samples after the seek.

PiperOrigin-RevId: 714082343
2025-01-10 09:45:21 -08:00
Ian Baker
6291cfda86 Fix dump file to match @GraphicsMode(NATIVE) 2025-01-10 17:35:56 +00:00
Ian Baker
77790df5a2 Plumb palette through as a method parameter to satisfy nullness checker 2025-01-10 17:17:28 +00:00
shahddaghash
30c5c66db4 Pass input MediaItemInfo list with duration
Added the creation of `MediaItemInfo` for each MediaItem and passed the duration of the MediaItem to it. This is done for export operations that complete with success or with error.

PiperOrigin-RevId: 714056270
2025-01-10 08:11:45 -08:00
Googler
d9b61b060f Disable sample rate fallback tests.
In some cases encoders include a sample rate in their AudioCapabilities but do not support encoding at that sample rate. This breaks the assumption used to write these tests, so disable them for now until the fallback logic is updated to handle this limitation.

PiperOrigin-RevId: 714055556
2025-01-10 08:08:57 -08:00
Ian Baker
4744f082af Add release note 2025-01-10 16:04:04 +00:00
Ian Baker
b2f9c1e252 Reformat with google-java-format 2025-01-10 16:02:24 +00:00
Ian Baker
ce0512845f Fix lint/style issues, and log exception 2025-01-10 16:02:24 +00:00
Ian Baker
6658dc097b Rename new fixed test file to old name, and add output dump 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
90c91fa5d7 Fixed subtitle track length. 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
47a5166a1d Small fix for an off-by-two error. 2025-01-10 16:02:24 +00:00
Ian Baker
671810235f Assorted nullness and control flow clean-ups 2025-01-10 16:02:24 +00:00
Ian Baker
8520c66fd8 Add some nullness annotations, re-jig some logic and reformat 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
391b72e257 Various cleanup and improvements as suggested by mainainer. 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
f52d98eafd Use Util.maybeInflate() 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
3cd0e1ad3d Add maybeInflate() which inflates only if the source buffer starts with the INFLATE_HEADER 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
0254b2d16e Add Vobsub sample file 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
250bc86669 Add comments about needing the size in the IDX file. 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
27a6883768 Another small fix 2025-01-10 16:02:24 +00:00
Sven Wischnowsky
7fbf511d30 Small fix 2025-01-10 16:02:23 +00:00
Sven Wischnowsky
721776c30e Support for Vobsub subtitles 2025-01-10 16:02:23 +00:00
dancho
c26a633d83 Read sample dependencies for H.265 in FragmentedMp4
Add a new flag to FragmentedMp4Extractor
FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES_H265
Read two bytes from H.265 videos to determine NAL unit type and
temporal layer id.

PiperOrigin-RevId: 714046987
2025-01-10 07:39:37 -08:00
tonihei
71cb246913 Fix bug where changing index does not reevaluate derived metadata
When the current MediaMetadata is automatically derived from the
MediaItem and Tracks, the result may change when state.buildUpon()
is used and new input data is provided (e.g. new current index).
To avoid reusing the previously derived MediaMetadata, we need to
reset it to null and re-evaluate it on every call to build()

Issue: androidx/media#1940
PiperOrigin-RevId: 714021424
2025-01-10 05:59:45 -08:00
tonihei
c3b13a60a3 Mark internal BasePlayer.seekTo method as @ForOverride
This method is not meant to be called directly, it only needs to
be implemented by subclasses.

PiperOrigin-RevId: 714000806
2025-01-10 04:32:32 -08:00
shahddaghash
72a71e8b9c Report exporter and muxer names metrics to EditingEndedEvent
Added reporting 2 values from Transformer:

- `exporterName`: name of the package calling for export. Example: "androidx.media3.transformer".
- `muxerName`: name of the muxer used for the export operation. Example: "androidx.media3.muxer".

PiperOrigin-RevId: 714000672
2025-01-10 04:29:25 -08:00
tonihei
f6eb2e6dd5 Fix discontinuity reporting in ClippingMediaPeriod
The initial discontinuity is currently only reported if
the period is prepared at the clip start position. However,
we need the discontinuity whenever we prepare at a non-zero
position (unless we know all samples are sync samples).

PiperOrigin-RevId: 713994155
2025-01-10 04:04:03 -08:00
ibaker
d0b757886e Fix handling of length-delimited NAL units with 1 or 2 byte length
ExoPlayer assumed 4-bytes for length in two places (by assuming the
length is the same as the 4-byte NAL start code):

1. In `AvcConfig` we transform length-delimited to start-delimited
   before writing into `initializationData`, and then skip
   'nal unit length field' bytes when parsing from `initializationData`
   (when we should skip 'start code length' bytes instead).

2. In `Mp4Extractor.readSample` we modify the local variable
   `sampleSize` to fix the difference between length field length and
   start code length, but **only on the first attempt to read a
   sample**. If we are resuming in the middle of reading a sample (after
   a recoverable I/O error), this fix for `sampleSize` is not done,
   which means we end up missing the last 2-3 bytes of the sample when
   the NAL length is 1-2 bytes.
     * This is fixed by moving the `sampleSize` 'fixing' code to outside
       the `if (sampleCurrentNalBytesRemaining == 0)` block.
     * `FragmentedMp4Extractor` has very similar code, but uses a
       field for `sampleSize`, rather than a local, so doesn't look
       vulnerable to the same problem (though I haven't totally
       tested this).

This change adds a test file with 2-byte NAL lengths, generated by
hacking the media3 muxer to emit 2-byte NAL lengths and transforming
`sample.mp4` using the transformer demo app.

PiperOrigin-RevId: 713709203
2025-01-09 10:06:13 -08:00
shahddaghash
64462b99fc Add mediaItem durationUs to Transformer's ExportResult.ProcessedInput
This will allow us to access the duration of the input media items and collect them for metrics.

PiperOrigin-RevId: 713686613
2025-01-09 08:51:00 -08:00
tonihei
b225383958 Don't force discontinuity when clipping a merged source duration
We only care about the duration and don't want to force an initial
discontinuity.

The problem is not currently visible due to a bug in
ClippingMediaPeriod that ignores all dicontinuities if they don't
happen at the clip start position.

PiperOrigin-RevId: 713686333
2025-01-09 08:47:33 -08:00