MasayukiSuda/Mp4Composer-android

Missing trim in RemixAudioComposer

Roberto7588 opened this issue · 0 comments

When using the option to Trim, some videos are processed incorrectly and show a static frame for the duration of the not trimmed audio.
This happens because the class RemixAudioComposer does not trim audio at all. The functionality is incomplete.
In this class the variables trimStartUs, trimEndUs, addPrimingDelay, frameCounter and primingDelay are doing nothing.

As a workaround I'm doing next in the RemixAudioComposer, but I'm not sure if is a terrible solution:

if (muxCount == 1){
	boolean write = (bufferInfo.presentationTimeUs >= trimStartUs)
			&& ((bufferInfo.presentationTimeUs <= trimEndUs) || (trimEndUs <= 0L));

	if (write){
		muxer.writeSampleData(SAMPLE_TYPE, encoder.getOutputBuffer(result), bufferInfo);
	}
}