We have an Android player that plays an m3u8 stream. This m3u8 stream contains numerous transport segments of video that are played sequentially. Usually the player buffers a few transport segments.
If the user clicks a button, I would like to store the existing buffer of transport segments in an array (or other data structure) and immediately merge them to be an mp4. So, if the buffer has:
chunk123.ts chunk124.ts chunk125.ts
I would like to merge them to be a chunks.mp4
The second part of the task - the merging is something I am acquainted with. However, I am not sure how I can retrieve the transport segments in the video player buffer on Android (the video player handles the download). I supposed one would need an open source video player for this? What part of the code would I need to modify to make it accessible from within my app?
Thank you!
Check the ExoPlayer. It handle m3u8 stream and persisten caching. You can easily add your custom logic because app is notified every time a chunck (ts file) is downloaded by the class ChunkSampleSource.