You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Video length not handled for TS videos longer than 13 hr 16 min #855
Play the 14 hour TS with the demo app
Try to skip forward
Expected result
Display the video length as 14 hours
Skip forward as requested
Actual result
Video length does not show
Skip forward does not do anything
The bug is in the TimestampAdjuster.adjustTsTimestamp method. At the beginning of playback the code determines the length of the video by using this to get the end time stamp. When the length of the video is more than 13 hrs 16 minutes, this returns a large negative number and the result is a negative value for video length. Without a video length, skipping is disabled.
In my case the video starts with a zero pts. I am concerned that if the pts started at a higher value, say 13 hours, that it may fail if the video length is more than 16 minutes. ALternatively it may fail if the video has a PTS wrap around point.
I tried to understand the logic in order to provide a fix but I was unsuccessful. I had difficulty with the logic around the wrap around.
Thanks for reporting! I'll submit a fix for this problem. Note that the duration estimation will still be broken for files longer than 26.5 hours, but this duration is increasingly unlikely to occur in practice.
I have upgraded to version 1.2.1. The fix has made things worse. On a 14 hour ts file the video length is shown correctly, but seeks are extremely slow. Seek forward 1 minute takes 30 seconds or more while the screen shows a spinning progress bar. A seek 1 hour into the 14 hour video showed a spinning progress bar for 5 minutes before I gave up waiting.
With a 13 hour ts file, seeks are fine. Seek forward 1 minute takes 1 second and seek forward 1 hour takes about 1.5 seconds.
When I test this with the 14 hour file I created, seeking behaves normally. Are you able to share the file you have? You can send a Google Drive link or similar to android-media-github@google.com and report back here if you've done that.
To create the 13 hr ts file run this ffmpeg -f concat -safe 0 -i 13_hr.txt -c copy TS_13_hr.ts
To create the 14 hr ts file run this ffmpeg -f concat -safe 0 -i 14_hr.txt -c copy TS_14_hr.ts
Everything works with the 13 hr file, but with the 14 hr file seeks do not work.
When attempting seek with the 14 hr file, logcat shows an unending stream of messages "Target buffer size reached with less than 500ms of buffered media data.".
2024-01-31 09:07:57.235 22506-22650 DefaultLoadControl org.mythtv.leanfront W Target buffer size reached with less than 500ms of buffered media data.
2024-01-31 09:07:57.246 22506-22650 DefaultLoadControl org.mythtv.leanfront W Target buffer size reached with less than 500ms of buffered media data.
2024-01-31 09:07:57.257 22506-22650 DefaultLoadControl org.mythtv.leanfront W Target buffer size reached with less than 500ms of buffered media data.
I can't reproduce this problem I'm afraid. And I also don't see the mentioned Target buffer size reached with less than 500ms of buffered media data. error message while playing the 14 hour file.
Given the error message, could it be related to how your DefaultLoadControl is configured? This usually only happens with a large back buffer and a very small configured maximum buffer size that isn't sufficient to hold enough data.
This is not an important bug to me. Recordings of longer than 6 hours are not normally supported, so I am happy to leave this as is. If you want to pursue it further I can give you any assistance you need.
I tried the demo application of media with the latest version from main. It shows the length of all of the TS files as 0, even the 1 hour file, and does not allow seeking on any of them. I don't understand this, it was working before on files up to 13 hours.
I'm also testing on the main branch and everything seems to work just fine, both for files below and above 13 h duration... Are you sure this is an unmodified checkout of the library demo app? Or is there is anything else that is special about how you built the demo app for testing?
I cloned from github the androidx/media repository. I did a pull of the main branch and I made 2 changes to make it work. One change to add my sample videos to the list, and one change to allow Clear Text Traffic, as I do not have https on my server. I an using Android Studio Giraffe 2022.3.1. I am testing with an "onn 4K streaming Box", latest version with Google TV.
I also tried with checking out the 1.2.1 tag (that is the version I am using in my app). I have attached a screenshot that shows where it has zero length and forward and back skip disabled, with the 1 hour ts file.
The reason that skips work on my application and not the demo application may be that I have implemented my own Extractors factory so that I can supply a larger value to the timestampSearchBytes parameter of the TsExtractor constructor. I am using a value of 488800 instead of the default 112800.
I checked again on a clean checkout of the main branch that the 1 hour TS file you provided plays perfectly fine and has a known duration. The only difference I see is that I copied the file to a local path instead of loading it from a remote server, but that shouldn't change any of the parsing logic.
I found what is causing the problem with the demo application. The demo is now working correctly, as you have said, on 1 hour, 13 hour and 14 hour files. Clearly the problem is on my side with the web server. Sorry for the trouble.
Activity
tonihei commentedon Dec 11, 2023
Thanks for reporting! I'll submit a fix for this problem. Note that the duration estimation will still be broken for files longer than 26.5 hours, but this duration is increasingly unlikely to occur in practice.
Use different wraparound assumptions for duration readers
Use different wraparound assumptions for duration readers
Use different wraparound assumptions for duration readers
bennettpeter commentedon Jan 30, 2024
I have upgraded to version 1.2.1. The fix has made things worse. On a 14 hour ts file the video length is shown correctly, but seeks are extremely slow. Seek forward 1 minute takes 30 seconds or more while the screen shows a spinning progress bar. A seek 1 hour into the 14 hour video showed a spinning progress bar for 5 minutes before I gave up waiting.
With a 13 hour ts file, seeks are fine. Seek forward 1 minute takes 1 second and seek forward 1 hour takes about 1.5 seconds.
tonihei commentedon Jan 31, 2024
When I test this with the 14 hour file I created, seeking behaves normally. Are you able to share the file you have? You can send a Google Drive link or similar to android-media-github@google.com and report back here if you've done that.
bennettpeter commentedon Jan 31, 2024
I sent the email.
To create the 13 hr ts file run this
ffmpeg -f concat -safe 0 -i 13_hr.txt -c copy TS_13_hr.tsTo create the 14 hr ts file run this
ffmpeg -f concat -safe 0 -i 14_hr.txt -c copy TS_14_hr.tsEverything works with the 13 hr file, but with the 14 hr file seeks do not work.
When attempting seek with the 14 hr file, logcat shows an unending stream of messages "Target buffer size reached with less than 500ms of buffered media data.".
tonihei commentedon Feb 5, 2024
I can't reproduce this problem I'm afraid. And I also don't see the mentioned
Target buffer size reached with less than 500ms of buffered media data.error message while playing the 14 hour file.Given the error message, could it be related to how your
DefaultLoadControlis configured? This usually only happens with a large back buffer and a very small configured maximum buffer size that isn't sufficient to hold enough data.4 remaining items
bennettpeter commentedon Feb 5, 2024
This is not an important bug to me. Recordings of longer than 6 hours are not normally supported, so I am happy to leave this as is. If you want to pursue it further I can give you any assistance you need.
tonihei commentedon Feb 5, 2024
I'm also testing on the main branch and everything seems to work just fine, both for files below and above 13 h duration... Are you sure this is an unmodified checkout of the library demo app? Or is there is anything else that is special about how you built the demo app for testing?
bennettpeter commentedon Feb 6, 2024
I cloned from github the androidx/media repository. I did a pull of the main branch and I made 2 changes to make it work. One change to add my sample videos to the list, and one change to allow Clear Text Traffic, as I do not have https on my server. I an using Android Studio Giraffe 2022.3.1. I am testing with an "onn 4K streaming Box", latest version with Google TV.
I also tried with checking out the 1.2.1 tag (that is the version I am using in my app). I have attached a screenshot that shows where it has zero length and forward and back skip disabled, with the 1 hour ts file.
bennettpeter commentedon Feb 6, 2024
The reason that skips work on my application and not the demo application may be that I have implemented my own Extractors factory so that I can supply a larger value to the timestampSearchBytes parameter of the TsExtractor constructor. I am using a value of 488800 instead of the default 112800.
tonihei commentedon Feb 6, 2024
I checked again on a clean checkout of the main branch that the 1 hour TS file you provided plays perfectly fine and has a known duration. The only difference I see is that I copied the file to a local path instead of loading it from a remote server, but that shouldn't change any of the parsing logic.
bennettpeter commentedon Feb 6, 2024
I found what is causing the problem with the demo application. The demo is now working correctly, as you have said, on 1 hour, 13 hour and 14 hour files. Clearly the problem is on my side with the web server. Sorry for the trouble.
tonihei commentedon Feb 6, 2024
Thanks for the confirmation!