google / google/ExoPlayer

Transforming HLS Live to MP4 Fails

Open
#10,943 8 comments 0 reactions 1 assignee Claimed by @andrewlewis View on GitHub
enhancement
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

### ExoPlayer Version

2.18.2

### Devices that reproduce the issue

It happens in all different devices and Android Version that we tested

### Devices that do not reproduce the issue

_No response_

### Reproducible in the demo app?

Yes

### Reproduction steps

1. modify `demos/transformer/build.gradle` and add the following line at line 83:
```
implementation project(modulePrefix + 'library-hls'),
```
2. Add an example HLS Live Stream URL to the Transformer Demo.
a) add the following HLS Live Stream URL at aline 91:
```
"https://dh4wkqcyy8768.cloudfront.net/live_500.m3u8",
```
b) Add the title for the above URL at line 107:
```
"Test Record Live Stream - OneTV",
```
Here is a link to our fork of the main repo with the changes: https://github.com/dev-onetv/ExoPlayer/commits/release-v2

Now build and run the demo-transformer app using Android Studio, and transforming the added URL.

The first 1-2 minutes of Live Stream video is saved as MP4, but then it fails.

### Expected result

Our use case to be able to record live stream and the Transformer seems to be ideal for this use case. Thus, we can avoid using FFMEG which takes a large size to record from HLS live Stream.

It appears that Transformer fails because the player speed is higher and when it reaches the end of Live Play list, it fails.

We would be very grateful if you could kindly let us now how we can probably reduces the transform speed and how to gracefully stop the transformation after the desired time, thus the MP4 output file is correctly written and playable.

### Actual result

Transform after 1-2 minutes crashes with the following log:

```
I/MPEG4Writer: MOOV atom was written to the file
D/MPEG4Writer: release()
D/MPEG4Writer: ftruncate mPreAllocateFileEndOffset:6957350 mOffset:6950200 mMdatEndOffset:6938606 diff:7150
D/MPEG4Writer: MP4WtrCtrlHlpLooper stopped
D/MPEG4Writer: Top 5 write durations(microseconds): #1:2620 #2:2697 #3:2912 #4:3245 #5:3305
D/MPEG4Writer: reset()
D/MPEG4Writer: Audio track stopping. Stop source
E/MPEG4Writer: Stop() called but track is not started or stopped
D/MPEG4Writer: Video track stopping. Stop source
E/MPEG4Writer: Stop() called but track is not started or stopped
D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10157; state: ENABLED
E/TransformerActivity: Transformation error
com.google.android.exoplayer2.transformer.TransformationException: Muxer error
at com.google.android.exoplayer2.transformer.MuxerWrapper.lambda$resetAbortTimer$0$com-google-android-exoplayer2-transformer-MuxerWrapper(MuxerWrapper.java:315)
at com.google.android.exoplayer2.transformer.MuxerWrapper$$ExternalSyntheticLambda0.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.IllegalStateException: No output sample written in the last 3000 milliseconds. Aborting transformation.
at com.google.android.exoplayer2.transformer.MuxerWrapper.lambda$resetAbortTimer$0$com-google-android-exoplayer2-transformer-MuxerWrapper(MuxerWrapper.java:314)
at com.google.android.exoplayer2.transformer.MuxerWrapper$$ExternalSyntheticLambda0.run(Unknown Source:4) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:923) 
```

### Media

Here is an example HLS Live Stream URL: https://dh4wkqcyy8768.cloudfront.net/live_500.m3u8

### Bug Report

- [X] You will email the zip file produced by `adb bugreport` to dev.exoplayer@gmail.com after filing this issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.