Transcoder icon indicating copy to clipboard operation
Transcoder copied to clipboard

BlankAudioDataSource makes transcoding stuck forever.

Open timcreatedit opened this issue 1 year ago • 8 comments

When adding a BlankAudioDataSource with any duration to a Transcoder, the transcoding process gets stuck forever with the following log:

V/TranscodeEngine( 9241): transcode(): executed step=53 advanced=false completed=false
V/Segment(AUDIO,0)( 9241): canAdvance(): state=State.Wait
V/Pipeline(Audio)( 9241): execute(): starting. head=0 steps=6 remaining=6
I/Decoder(AUDIO,0)( 9241): buffer() failed. dequeuedInputs=0 dequeuedOutputs=4
V/Reader  ( 9241): Returning State.Wait because buffer is null.
V/Pipeline(Audio)( 9241): execute(): step Reader (#0/6) is waiting. headState=State.Ok(kotlin.Unit) headIndex=0
V/Segment(VIDEO,0)( 9241): canAdvance(): state=State.Eos(kotlin.Unit)
V/Segments( 9241): hasNext(VIDEO): segment=com.otaliastudios.transcoder.internal.Segment@c6c217a lastIndex=0 canAdvance=false
V/Segment(VIDEO,0)( 9241): canAdvance(): state=State.Eos(kotlin.Unit)
V/Segment(AUDIO,0)( 9241): canAdvance(): state=State.Wait
V/Segments( 9241): hasNext(AUDIO): segment=com.otaliastudios.transcoder.internal.Segment@5463bad lastIndex=0 canAdvance=true
V/Segment(AUDIO,0)( 9241): canAdvance(): state=State.Wait
V/TranscodeEngine( 9241): transcode(): executed step=53 advanced=false completed=false
V/Segment(AUDIO,0)( 9241): canAdvance(): state=State.Wait
V/Pipeline(Audio)( 9241): execute(): starting. head=0 steps=6 remaining=6
I/Decoder(AUDIO,0)( 9241): buffer() failed. dequeuedInputs=0 dequeuedOutputs=4
V/Reader  ( 9241): Returning State.Wait because buffer is null.
V/Pipeline(Audio)( 9241): execute(): step Reader (#0/6) is waiting. headState=State.Ok(kotlin.Unit) headIndex=0
V/Segment(VIDEO,0)( 9241): canAdvance(): state=State.Eos(kotlin.Unit)
V/Segments( 9241): hasNext(VIDEO): segment=com.otaliastudios.transcoder.internal.Segment@c6c217a lastIndex=0 canAdvance=false

and so on...

I tried to modify the readTrack function in BlankAudioDataSource but to no avail. Not sure if @natario1 is still maintaining this repo, but maybe @mudar can help out as the original author of #64

Thank you so much!

timcreatedit avatar Jan 04 '23 16:01 timcreatedit

Did you add a valid video track along with the blank audio?

mudar avatar Jan 04 '23 16:01 mudar

Hey, thanks for your super quick response!

We are basically doing this:

                val datasource = UriDataSource(context, sourcePathUri)

                datasource.initialize()
                val transcoder = Transcoder.into(destPath)
                    .addDataSource(TrackType.VIDEO, datasource)
                    .addDataSource(TrackType.AUDIO, BlankAudioDataSource(datasource.durationUs))

Without adding the BlankAudioDatasource, this code works fine. Once we add it, it is stuck infinitely as mentioned above.

timcreatedit avatar Jan 04 '23 17:01 timcreatedit

Our main goal is the problem you had originally as well, where we can't concat videos with audio tracks together with videos without audio tracks, although we might be missing something of course

timcreatedit avatar Jan 04 '23 17:01 timcreatedit

It's been a while since I worked on this, so I'm not sure I can help with the code! Looking at the PR, I have the impression that adding the blankAudio is handled internally by the transcoder. You could try concatenating the two videos (with/without audio tracks) and see if that works :crossed_fingers:

mudar avatar Jan 04 '23 17:01 mudar

If we try to concatenate video with audio with video without audio, we run into the same problem as you did in #51 It seems like the audioTracks getter doesn’t do it’s job (anymore), or we're potentially missing something

thanks again for your help, it is really appreciated

timcreatedit avatar Jan 04 '23 20:01 timcreatedit

https://github.com/natario1/Transcoder/blob/ba8f098c9461a12da1c11d26c9f32feb1e69b4d5/lib/src/main/java/com/otaliastudios/transcoder/internal/DataSources.kt#L53

This looks like it should fill missing audio tracks with BlankAudioDataSources automatically

timcreatedit avatar Jan 04 '23 20:01 timcreatedit

@timcreatedit Hi. Any updates about this issue?

VOstopolets avatar Jan 12 '23 15:01 VOstopolets

Experiencing the same thing over here. Hoping for some updates.

jordond avatar Apr 30 '23 17:04 jordond