androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.74k stars 416 forks source link

Handle frame which has negative presentationTimeUs value #1370

Closed YumengNevix closed 6 months ago

YumengNevix commented 6 months ago

I have a sentry report about an Export exception, the device is: SM-N960F(running Android 10), the stack trace is:

ExportException
Muxer error
androidx.media3.transformer.SampleExporter in feedMuxer at line 137
androidx.media3.transformer.SampleExporter in processData at line 77
androidx.media3.transformer.TransformerInternal in drainExportersInternal at line 348
androidx.media3.transformer.TransformerInternal in handleMessage at line 316
androidx.media3.transformer.TransformerInternal in $r8$lambda$0Eq5y0bhoOvqh9wEU99UtqZE5oc
… al$$InternalSyntheticLambda$1$e6d92c817f70718de02efd1e93bd574562a8301ebee0cb4e3708c231c629a3a6$0 in handleMessage
android.os.Handler in dispatchMessage at line 103
android.os.Looper in loop at line 237
android.os.HandlerThread in run at line 67

Muxer$MuxerException
Failed to write sample for trackIndex=1, presentationTimeUs=-21815, size=59
androidx.media3.transformer.FrameworkMuxer in writeSampleData at line 180
androidx.media3.transformer.DefaultMuxer in writeSampleData at line 92
androidx.media3.transformer.MuxerWrapper in writeSample at line 369
androidx.media3.transformer.SampleExporter in feedMuxer at line 129
androidx.media3.transformer.SampleExporter in processData at line 77
androidx.media3.transformer.TransformerInternal in drainExportersInternal at line 348
androidx.media3.transformer.TransformerInternal in handleMessage at line 316
androidx.media3.transformer.TransformerInternal in $r8$lambda$0Eq5y0bhoOvqh9wEU99UtqZE5oc
… al$$InternalSyntheticLambda$1$e6d92c817f70718de02efd1e93bd574562a8301ebee0cb4e3708c231c629a3a6$0 in handleMessage
android.os.Handler in dispatchMessage at line 103
android.os.Looper in loop at line 237
android.os.HandlerThread in run at line 67

IllegalArgumentException
bufferInfo must specify a valid buffer offset, size and presentation time
android.media.MediaMuxer in writeSampleData at line 682
androidx.media3.transformer.FrameworkMuxer in writeSampleData at line 178
androidx.media3.transformer.DefaultMuxer in writeSampleData at line 92
androidx.media3.transformer.MuxerWrapper in writeSample at line 369
androidx.media3.transformer.SampleExporter in feedMuxer at line 129
androidx.media3.transformer.SampleExporter in processData at line 77
androidx.media3.transformer.TransformerInternal in drainExportersInternal at line 348
androidx.media3.transformer.TransformerInternal in handleMessage at line 316
androidx.media3.transformer.TransformerInternal in $r8$lambda$0Eq5y0bhoOvqh9wEU99UtqZE5oc
… al$$InternalSyntheticLambda$1$e6d92c817f70718de02efd1e93bd574562a8301ebee0cb4e3708c231c629a3a6$0 in handleMessage
android.os.Handler in dispatchMessage at line 103
android.os.Looper in loop at line 237
android.os.HandlerThread in run at line 67

It seems that presentationTimeUs's value is negative, and it may cause this issue. Also, I find that another video transform library has this problem: https://github.com/linkedin/LiTr/pull/92

They choose to ignore frame which has negative presentationTimeUs value. Hope for your reply!

YumengNevix commented 6 months ago

Additional info: My media3 library version is 1.3.0

SheenaChhabra commented 6 months ago

@ychaparov You worked on a similar issue before?

ychaparov commented 6 months ago

I believe this issue is already fixed in the latest Transformer release, 1.3.1 with this commit https://github.com/androidx/media/commit/04ce83691e6d19e1c73cc4810e30c1505403eec1

Please reopen this issue if you see similar problems after updating!