Transcoder icon indicating copy to clipboard operation
Transcoder copied to clipboard

Fix when it is not buffer.hasRemaining(refs #144 #153)

Open jumperson opened this issue 2 years ago • 5 comments

There was a case where buffer.isremining() was false when used with AudioEngine. When I debugged, the capacity of buffer was 0.

スクリーンショット 2021-12-22 20 49 19

refs: #144 #153

jumperson avatar Dec 23 '21 07:12 jumperson

@natario1 Thank you for developing a great library. I would appreciate it if you could review the fix.

jumperson avatar Feb 01 '22 13:02 jumperson

I also need this fix please and thank you @jumperson. However, will putting an if statement have an impact on the audio or not?

Tom3652 avatar Feb 02 '22 18:02 Tom3652

Thanks! I would prefer if we understand why buffer is empty. Where is it coming from? Seems like a bug upstream (either in Transcoder code, or in device decoders) that we should fix. Also with the proposed solution the buffer is never released.

natario1 avatar Mar 12 '22 13:03 natario1

when using com.otaliastudios:transcoder:0.10.4", I have same issue.

java.lang.IllegalArgumentException: bufferInfo must specify a valid buffer offset, size and presentation time at android.media.MediaMuxer.writeSampleData(MediaMuxer.java:682) at mb.b.d(DefaultDataSink.java:2) at ib.d.d(eos.kt:6) at eb.f.c(Writer.kt:11) at gb.d.a(Pipeline.kt:1) at ab.c.a(Segment.kt:7) at hb.a.b(DefaultTranscodeEngine.kt:14) at ya.a.call(Transcoder.java:25) at java.util.concurrent.FutureTask.run(FutureTask.java:266)

LiTr had same issue and it was fixed. https://github.com/linkedin/LiTr/issues/78 https://github.com/linkedin/LiTr/pull/92

Last audio frame (with EOS flag) has a presentation time of -1, which causes an IllegalArgumentException on MediaMuxer when we try to write it. This was not happening on newer devices, because buffer size was zero, which prevents AudioTrackTranscoder from writing. But on some older devices (such as Samsung Galaxy S5) buffer size would be non-zero, which would make transcoding fail.

oyama202107 avatar Apr 05 '22 07:04 oyama202107

@jumperson, @natario1 this fixes the issue for me, specifically any videos recorded on iOS seems to have this issue (using this fork https://github.com/StudistCorporation/Transcoder)

jonandersen avatar Sep 06 '22 15:09 jonandersen

@natario1 is there anything I can help with so that this would get merged and a new version would be published?

vanniktech avatar Feb 18 '23 21:02 vanniktech

As I said before, ideally we should understand where this buffer is coming from, it seems like we are patching a bug that is somewhere upstream in the pipeline.

But if no one has time to do so, at least the buffer should be released in an else branch, otherwise it's leaked (I think). I can merge the PR after this, and could also use some help with publishing a new version.

natario1 avatar Feb 19 '23 17:02 natario1

@natario1 there you go: https://github.com/natario1/Transcoder/pull/182

vanniktech avatar Feb 19 '23 21:02 vanniktech

Looks like sonatype is down now https://status.maven.org/incidents/pplp3ln3vs81 - when they fix it you'll be able to use the snapshot version.

For a real release I would appreciate if someone made a simple version bump PR like this, listing the fixes since previous version.

natario1 avatar Feb 20 '23 10:02 natario1

There you go @natario1: https://github.com/natario1/Transcoder/pull/183

vanniktech avatar Feb 20 '23 14:02 vanniktech