android-transcoder
android-transcoder copied to clipboard
Implement media time trim feature.
Add class MediaTrimTime to hold trim duration. Apply start time by invoking seekTo of MediaExtractor. In VideoTrackTranscoder and PassThroughTrackTranscoder, check the sample time and make it not pass the trim end time.
@ypresto, Can you consider this feature?
Perhaps some kind of interface to pass multiple, optional parameter is necessary. I think builder pattern suits this.
I'm afraid of device compatibility because of flush() bug: #8
@ypresto
I have a need for this capability as well. Can you clarify the similarity regarding the seek that is done in this PR vs the flush bug that you corrected by queuing output. Am happy to work on this. Obviously we don't want any device compatibility issues.
@selsamman
flush() was used to seek to beginning of video after determining output format. That's why I thought similar issues can happen on some devices. If you have affected device (or one has similar SoC), it can be tested without problems. (Or AWS device farm can be used. Power of money 😎 )
@ypresto
Sorry to be so dense here. If I understand the original problem it was that it was not cool to essentially do an extra partial extraction just to determine the input format and then reset everything and flush. Instead you had to determine the format on-the-fly as you were decoding and queue everything until the decoder ran long enough to provide that format info.
But I don't see any flush being done in this PR. It just does a seek. Is that somehow doing a flush under the covers? I am new to MediaCodec.
BTW thanks for pointing me to the AWS device farm. That could be a game changer :-)
Ah, you're right, flush()ing is different than skipping leading frames (seeking). I'm afraid that just skipping frames can cause another unexpected codec bug or not. I'll test with device farm about it.
@ypresto I think this is a useful feature. Please consider to merge it.
Without a doubt this is an interesting feature. Are there any plans of adding it in the future?
@CharlesLin99 , Thank you very much for your code of trim feature, It's useful! @sebadelcampo1 You can change your code according to this pull request , but you should let the function "createAudioOutputFormat" of all classes that implements "MediaFormatStrategy" return null, because "AudioTrackTranscoder" class doesnt have trim feature.
I would also like to have this feature