TrimDataSource (#50)
* Add support for trim, related to issue #37 - New component TrimDataSource, wrapping DataSource to be trimmed. - MediaExtractorDataSource is an abstract class to limit visibility of MediaExtractor to package - Updates to Engine to replace selectAudio/transcode/selectVideo/transcode sequence by selectAudio/selectVideo/transcode/transcode * Added support for TrimDataSource into demo app Using 2 editText fields, default value is zero. * TranscoderOptions Builder support for TrimDataSource Builder can add directly trim values for UriDataSource * TrimDataSource updates following PR code review - fixed case where video track is absent - throw exceptions for invalid trim values * Removed unnecessary changes to Engine In the original sequence selectAudio / transcodeAudio / selectVideo / transcodeVideo the first step (selectAudio) is intercepted by selectVideo + seekVideo and the 3rd step (selectVideo) is skipped. So it becomes selectVideo / seekVideo / selectAudio / transcodeAudio / transcodeVideo - Also added throws IllegalArgumentException to TrimDataSource * Moved seekTo() from selectTrack() to canReadTrack() Cleaner simplified code :) The extractor needs a second call to seekTo() after reaching a video keyframe, to obtain better values for audio track. Otherwise, too many audio frames can be lost, causing visible off-sync. * Removed MediaExtractorDataSource Replaced by adding seekTo() to DataSource interface * Removed timestamp adjustment The rest of the lib already assumes that timestamps start from arbitrary values. * Use TrackTypeMap for readyTracks flags replacing two booleans * Handle trimEnd in isDrained() Stop reading when readUs is past duration. This removes the need to manually define KEY_DURATION in the mediaFormat * Fix seek vs canRead order to avoid possible bug where seekTo lands on a different track. Ex: The upstream source might be on AUDIO position, but if you seek later, the next position might VIDEO instead. * Apply seekTo() once per selected track - Updates to Engine to replace selectAudio/transcode/selectVideo/transcode sequence by selectAudio/selectVideo/transcode/transcode - remove unnecessary hasTrack() - seekTo() is applied in canReadTrack(), once per selected track. This now works because all track selection operations are done before the first call to canReadTrack(). - When 2 tracks are selected, seekTo() is called twice and this helps the extractor with Audio sampleTime issues. * seekBy() replaces seekTo(), selecting all tracks - reverted unnecessary changes to Engine class. Previous changes cannot guarantee that all calls to selectTracks() are done before the first canRead(). Latest bug was with merging multiple trimmed files. - use seekBy() to better handle first extractor timestamp - DefaultDataSource makes sure all available tracks are selected by extractor (without adding to mSelectedTracks array). Then seekTo() is called mutlitple times, using the resulting sampletimeUs for the later calls.
M
Mudar Noufal committed
63e6e304165bc31d2ab6087fda15fc11ee57f75b
Parent: d91d6ff
Committed by Mattia Iavarone <mat.iavarone@gmail.com>
on 1/7/2020, 8:02:17 PM