406 Commits

Author SHA1 Message Date
tofunmi
cb4b2ea55c remove degammaing: change setSdrWorkingColorSpace default
The second stage of the changes remove the conversion to linear colors in the SDR effects pipeline by default.

also resolves Issue: androidx/media#1050

PiperOrigin-RevId: 630108296
2024-05-02 10:35:48 -07:00
rohks
e25bd07a81 Parse initialization data from AV1 tracks
Initialization data is not passed to `MediaCodecRenderer` as it is not required for playing AV1 video.

See: https://developer.android.com/reference/android/media/MediaCodec#CSD
PiperOrigin-RevId: 629729301
2024-05-01 08:23:43 -07:00
tonihei
1af86d4c4d Fix issue where subtitles starting before a seek position are skipped
These subtitles were skipped because they are marked as shouldBeSkipped
based on their timestamps. The fix removes this flag entirely in
SimpleSubtitleDecoder because TextRenderer handles potential skipping
if needed.

PiperOrigin-RevId: 629717970
2024-05-01 07:34:40 -07:00
Rohit Singh
247cad934a Update dump files 2024-04-30 16:31:50 +01:00
Daniele Sparano
838083e610 Update dump files 2024-04-30 16:31:50 +01:00
Rohit Singh
3cafb08a32 Fix condition to send dummy end of input and update dump files 2024-04-30 16:31:50 +01:00
Rohit Singh
a7f5c3f5b6 Update dump files 2024-04-30 16:31:50 +01:00
Tofunmi Adigun-Hameed
c002ff6a6f Merge pull request #419 from v-novaltd:vnova-104 2024-04-30 16:31:49 +01:00
sheenachhabra
bc77cef403 Rollback of 08abc964ab
PiperOrigin-RevId: 629382753
2024-04-30 05:41:45 -07:00
Rohit Kumar Singh
43f098da0f Merge Issue: androidx/media#882: Extend MPEG2TS implementation with MPEG-H support
Imported from GitHub PR https://github.com/androidx/media/pull/882

Merge 27a4c43de6294a5482b85ff8e2b4501057f3e946 into a49b625cc585970843f27410b614c6470924e7e5

COPYBARA_INTEGRATE_REVIEW=https://github.com/androidx/media/pull/882 from androidx:ts_mpegh_reader_patch 27a4c43de6294a5482b85ff8e2b4501057f3e946
PiperOrigin-RevId: 629132035
2024-04-29 11:33:38 -07:00
ibaker
96bc9e9652 Propagate ID3 TCON frame to MediaMetada.genre
This change also includes mapping the numeric ID3v1 codes to their
string equivalents before setting them into `MediaMetadata`. This
mapping already existed, but it was previously only used when parsing
MP4 `gnre` atoms.

Issue: androidx/media#1305
PiperOrigin-RevId: 629113480
2024-04-29 10:38:51 -07:00
tianyifeng
e180e263a5 Refresh HlsMediaPlaylist with delivery directives when possible
When refreshing the media playlist, we should try to request via a url with [delivery directives](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-6.2.5). However, when initially loading the media playlist or when the last loading with delivery directives encountered an error, we should not allow using those directives.

PiperOrigin-RevId: 629060177
2024-04-29 07:24:35 -07:00
ibaker
b0e48175f0 Add ID3 TCON genre to MP3 test samples
This change adds a 'free-form' text genre to the existing
`bear-id3.mp3` sample, and adds a new sample with a 'numeric' genre ([9
is Metal](https://mutagen-specs.readthedocs.io/en/latest/id3/id3v2.4.0-frames.html#appendix-a-genre-list-from-id3v1)).

The samples were modified with:

```shell
$ id3edit --set-genre "Gorpcore" bear-id3.mp3
$ id3edit --set-genre "9" bear-id3-numeric-genre.mp3
```

Reading the numeric genre with `exiftool` shows the mapping back to
'Metal':

```
$ exiftool bear-id3-numeric-genre.mp3 | grep Genre
Genre                           : Metal
```

The playback dumps don't contain the genre because it's not yet
propagated to `MediaMetadata.genre`. That is done in a follow-up
change.

Issue: androidx/media#1305
PiperOrigin-RevId: 629043506
2024-04-29 06:03:39 -07:00
ibaker
e194225b32 Fix parsing some MP4 metadata fields we wrongly assumed were 1 byte
This fixes parsing the `gnre` and `tmpo` values, as seen in the test
dump changes in this CL.

Issue: androidx/media#1305
PiperOrigin-RevId: 628352773
2024-04-26 03:30:14 -07:00
Googler
08abc964ab Box: Implement ctts box
Add ctts box implementation to handle muxing B-frame videos.
Add method convertPresentationTimestampsToCompositionOffset to
provide sample offsets. Return empty ctts box in case of video
does not contain B-frame. Add ctts box to MoovStructure to handle
muxing the video containing B-frames.

PiperOrigin-RevId: 628346257
2024-04-26 02:57:53 -07:00
ibaker
d76ee54ca6 Add two MP4 samples with metadata
The first has a string genre, and various other values set, generated
from `sample.mp4` with the command below [1].

The second has a numeric genre, to test `gnre` atom parsing. This
parsing is currently broken, the fix is in a follow-up change. This
file was also generated from `sample.mp4` with the command below [2].

This change also includes `CommentFrame.text` in its `toString`
representation, otherwise there's no difference between e.g. different
levels of `ITUNESADVISORY` in the extractor dump files.

Issue: androidx/media#1305

-----

[1]

```shell
$ AP_PADDING="DEFAULT_PAD=0" \
    AtomicParsley sample.mp4 \
    --artist "Test Artist" \
    --album "Test Album" \
    --tracknum 2/12 \
    --disk 2/3 \
    --year 2024  \
    --genre "Gorpcore" \
    --bpm 120 \
    --compilation true \
    --advisory clean \
    --gapless true \
    --sortOrder artist "Sorting Artist" \
    --sortOrder album "Sorting Album" \
    --preventOptimizing \
    -o sample_with_metadata.mp4
```

[2]
```shell
$ AP_PADDING="DEFAULT_PAD=0" \
    AtomicParsley sample.mp4 \
    --genre "Metal" \
    --preventOptimizing \
    -o sample_with_numeric_genre.mp4
```

PiperOrigin-RevId: 628345458
2024-04-26 02:53:33 -07:00
ibaker
acb3a54dee Add MediaMetadata to playback test dump files
This change also adds some runtime redirection of calls to
`Dumper.add(String, Object)` to `add(String, byte[])` if
`value instanceof byte[]`. This simplifies the implementation of
`PlaybackOutput.dumpIfNotEqual` and seems like a reasonable amound of
'magic' for a test utility.

Issue: androidx/media#1305
PiperOrigin-RevId: 628119473
2024-04-25 10:35:18 -07:00
kimvde
c87940eb27 AudioGraph refactoring: configure mixer and add sources in one place
PiperOrigin-RevId: 628076773
2024-04-25 08:02:00 -07:00
rohks
8ff9e4a838 Add test for H.264 I-frames only track in TsExtractorTest
Sample is created by re-encoding the existing H.264 sample with `ffmpeg`.

PiperOrigin-RevId: 627470063
2024-04-23 12:30:11 -07:00
tofunmi
fb037b9847 TimestampWrapper: fix signaling input capacity
fixes https://github.com/androidx/media/issues/821

PiperOrigin-RevId: 626407880
2024-04-19 10:40:59 -07:00
tianyifeng
50fefe698d Avoid non-primary playlists continuously reloading for LL-HLS streams
For LL-HLS, the non-primary playlists originally keep reloading even after the primary playlist has been changed to another one. The reason being this is to check if the hinted(#EXT-X-PRELOAD-HINT) resource has been published or removed. If removed, the loading of it should be canceled, per the suggestion in the HLS spec:

"A Client SHOULD cancel a request for a hinted resource if it is not present in a subsequent Playlist update, such as in an EXT-X-PRELOAD-HINT tag or as part of another tag such as EXT-X-PART.  The client SHOULD ignore the results of such requests."

However, keeping the non-primary playlists reloading is not optimal. As a solution, we trigger the playlist reloading only when there is a preload chunk loading instead of every time after we have processed the playlist. Compared to the original implementation, this will save the requests of reloading non-primary playlist after we have taken action upon the preload chunk being published or removed.

Issue: androidx/media#1240
PiperOrigin-RevId: 626038032
2024-04-18 08:11:19 -07:00
sheenachhabra
794900bfb8 Update addMetadata method in Transformer/Muxer.java
This is to align the interface with Muxer/Muxer.java and
then finally replace it.

PiperOrigin-RevId: 625283725
2024-04-16 04:40:13 -07:00
kimvde
fa0fb38ca6 Handle clip start position equal to end position in Transformer
After this CL, Transformer will throw if the clipping start and end
positions are the same because MediaMuxer doesn't support writing a
file with no samples. This should work once we default to the in-app
muxer.

Issue: androidx/media#1242
PiperOrigin-RevId: 624861950
2024-04-15 00:53:38 -07:00
samrobinson
81b9739bda Consolidate dump files for item effect vs composition effect.
PiperOrigin-RevId: 623161140
2024-04-09 07:33:38 -07:00
samrobinson
24b86e73cb Group together PCM audio samples by fixed size in CapturingMuxer dumps.
Reduces flakiness of tests that assert on PCM audio. Tests now have to
clearly choose how they want the capturing muxer to handle pcm audio.

Note that the only dump files that have changed are those that deal
with PCM audio (.wav, sowt, twos, silence). Because of the continuous
nature of PCM, timestamps are not part of the dump.

PiperOrigin-RevId: 623155302
2024-04-09 07:04:49 -07:00
ibaker
59710a5f81 Remove internal instructions from test-generated-goldens/README.md
PiperOrigin-RevId: 621163748
2024-04-02 07:15:35 -07:00
ibaker
b60cd2c033 Rollback of e665e2aee8
PiperOrigin-RevId: 619871653
2024-03-28 04:04:01 -07:00
Copybara-Service
8fe70332ee Merge pull request #1054 from jekopena:main
PiperOrigin-RevId: 619573181
2024-03-27 10:24:32 -07:00
kimvde
98dac54816 Fix negative position for clipped media
With this CL:
- The large timestamp offset added by ExoPlayer so that decoders
don't see any negative timestamps is removed before passing the
timestamp to the AudioGraph.
- Clipped media timestamps are offset by the clipping start position
before being passed to the AudioGraph.
- The offset added to the audio buffer timestamps is removed when
computing the audio sink position, to convert them back to the
timestamps passed by the player.

PiperOrigin-RevId: 619225990
2024-03-26 10:05:11 -07:00
tofunmi
f4fefd19f7 Document and test multi asset ultraHDR support
PiperOrigin-RevId: 619200688
2024-03-26 08:39:44 -07:00
ibaker
d00ca1e343 Plumb MP3 average bitrate from metadata frames into Format
Issue: androidx/media#1081

#minor-release

PiperOrigin-RevId: 619185083
2024-03-26 07:40:08 -07:00
tofunmi
65e94480f4 Transformer: add single-asset ultraHDR image to HLG HDR vid transcoding
PiperOrigin-RevId: 619138202
2024-03-26 04:06:41 -07:00
Juan Carlos Penalver
e9e47f4fe6 Removing id from Label and ensuring label/labels consistency in Format.Builder. 2024-03-25 12:00:14 +00:00
Juan Carlos Penalver
63fb68e99e Reverting breaking changes by keeping label and adding labels. 2024-03-25 12:00:14 +00:00
sheenachhabra
16aac07bce Add support for processing 3 byte NAL start code in Mp4Muxer
Issue: androidx/media#725

Ideally the test to transmux a `ts` file (having 3 bytes NAL start code)
should go into `Mp4MuxerEndToEndTest`but `Mp4MuxerEndToEndTest` uses `MediaExtractor` and `MediaExtractor` is returning samples with `4 byte NAL start code` which will not exercise the newly added code path.
Hence the test is added in `TransformerWithInAppMuxerEndToEndTest` which
internally uses `media3 extractor` and feeds samples with `3 bytes NAL start code`
only.

PiperOrigin-RevId: 617985866
2024-03-21 15:49:12 -07:00
tofunmi
c0ffc94d15 Add GlEffect that asynchronously adjusts input presentation times
Single asset export only effect.

PiperOrigin-RevId: 616114153
2024-03-15 06:56:25 -07:00
ibaker
e9ed874e51 Don't emit a CuesWithTiming for zero-duration Subtitle events
It's a bit arguable whether the `Subtitle` implementation supports
zero-duration events, since `getEventTimeCount` is documented as
effectively "the number of times the cues returns by `getCues(long)`
changes", and zero-duration events violate that. However, the current
`WebvttSubtitle` impl **does** produce zero-duration events, so it
seems safer to handle them gracefully here and then, as a possible
follow-up, fix the `WebvttSubtitle` impl (or remove it completely).

Issue: androidx/media#1177

#minor-release

PiperOrigin-RevId: 616095798
2024-03-15 05:26:21 -07:00
tofunmi
f39fe82bba Support ultra HDR in effect
adding sending gainmap to shader program and applying gainmap to base in shader

PiperOrigin-RevId: 616070582
2024-03-15 03:22:54 -07:00
Copybara-Service
e9a28beb44 Merge pull request #1117 from loliball:dev_wav_align_fix
PiperOrigin-RevId: 615820438
2024-03-14 10:17:49 -07:00
Rohit Singh
c84a3279d3 Add unit test 2024-03-14 16:12:40 +00:00
christosts
9f9d955f0d Preview clipped media in composition preview
PiperOrigin-RevId: 613609878
2024-03-07 09:32:11 -08:00
ibaker
afacf2cdb7 Set Format.frameRate for single-frame MP4 tracks
Issue: androidx/media#1051
PiperOrigin-RevId: 613516802
2024-03-07 02:53:05 -08:00
michaelkatz
638b2a3c86 Start early-enabled renderers only after advancing the playing period
Renderers may be enabled for subsequent media items as soon as the current media item's renderer's isEnded() returns true. When a renderer is being enabled and the player is 'playing', that renderer is also started. When playing a mixed playlist of images and content with audio & video, the player may skip some image items because the early-starting of the audio renderer causes a clock update.

A solution is to only start the "early-enabled" renderers at the point of media transition and add a condition on DefaultMediaClock to use the standalone clock when reading-ahead and the renderer clock source is not in a started state.

Issue: androidx/media#1017
PiperOrigin-RevId: 613231227
2024-03-06 08:50:42 -08:00
Googler
08993b6fb1 Have VideoSampleExporter output orientation match input
This should enable trim optimization to work correctly in more cases.

PiperOrigin-RevId: 611096958
2024-02-28 07:40:53 -08:00
ibaker
19cd156a8c Add Mp4ExtractorTest case for pixel-motion-photo-2-hevc-tracks.mp4
A follow-up change will add the frame rate to the single-frame track.

Issue: androidx/media#1051
PiperOrigin-RevId: 611018319
2024-02-28 01:23:01 -08:00
ibaker
c7e00b12b4 Add fps-awareness to DefaultTrackSelector
This change aims to prioritise tracks that have a 'smooth enough for
video' frame rate, without always selecting the track with the highest
frame rate.

In particular MP4 files extracted from motion photos sometimes have two
HEVC tracks, with the higher-res one having a very low frame rate (not
intended for use in video playback). Before this change
`DefaultTrackSelector` would pick the low-fps, high-res track.

This change adds a somewhat arbitrary 10fps threshold for "smooth video
playback", meaning any tracks above this threshold are selected in
preference to tracks below it. Within the tracks above the threshold
other attributes are used to select the preferred track. We deliberately
don't pick the highest-fps track (over pixel count and bitrate), because
most users would prefer to see a 30fps 4k track over a 60fps 720p track.

This change also includes a test MP4 file, extracted from the existing
`jpeg/pixel-motion-photo-2-hevc-tracks.jpg` file by logging
`mp4StartPosition` in
[`MotionPhotoDescription.getMotionPhotoMetadata`](b930b40a16/libraries/extractor/src/main/java/androidx/media3/extractor/jpeg/MotionPhotoDescription.java (L123))
and then using `dd`:

```
mp4StartPosition=2603594

$ dd if=jpeg/pixel-motion-photo-2-hevc-tracks.jpg \
    of=mp4/pixel-motion-photo-2-hevc-tracks.mp4 \
    bs=1 \
    skip=2603594
```

----

This solution is in addition to the `JpegMotionPhotoExtractor` change
made specifically for these two-track motion photos in
5266c71b3a.
We will keep both changes, even though that change is not strictly
needed after this one, because adding the role flags helps to
communicate more clearly the intended usage of these tracks. This
change to consider FPS seems like a generally useful improvement to
`DefaultTrackSelector`, since it seems unlikely we would prefer a 5fps
video track over a 30fps one.

Issue: androidx/media#1051
PiperOrigin-RevId: 611015459
2024-02-28 01:09:50 -08:00
claincly
626a8adfd8 Test effect-enabled playback
This new test is for `ExoPlayer.setVideoEffects()`. It plays the
one-second-long video, applies an overlay that prints the video frame timestamp
onto the frame, captures the output frame and compares the captured output
frame with golden.

PiperOrigin-RevId: 610781590
2024-02-27 09:44:24 -08:00
Googler
6f28eeff31 Pick max H.264 level when trim optimizing
Instead of always starting with the transcoded H.264 level, take the maximum
from transcoded and transmuxed levels

PiperOrigin-RevId: 610759438
2024-02-27 08:27:38 -08:00
Googler
0e0e1c4f1a Tests for composition audio effects
Add tests for the changes to AudioGraph that support composition audio effects

PiperOrigin-RevId: 610691768
2024-02-27 03:04:20 -08:00
tofunmi
0480bc31a8 Rename media/bitmap out of media and rename
PiperOrigin-RevId: 610418418
2024-02-26 08:40:19 -08:00