{"action":"created","issue":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/4076","repository_url":"https://api.github.com/repos/google/ExoPlayer","labels_url":"https://api.github.com/repos/google/ExoPlayer/issues/4076/labels{/name}","comments_url":"https://api.github.com/repos/google/ExoPlayer/issues/4076/comments","events_url":"https://api.github.com/repos/google/ExoPlayer/issues/4076/events","html_url":"https://github.com/google/ExoPlayer/pull/4076","id":310872388,"node_id":"MDExOlB1bGxSZXF1ZXN0MTc5MTI1NDY1","number":4076,"title":"Add duration calculation and seeking support for TS files","user":{"login":"FD-","id":3320822,"node_id":"MDQ6VXNlcjMzMjA4MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/3320822?v=4","gravatar_id":"","url":"https://api.github.com/users/FD-","html_url":"https://github.com/FD-","followers_url":"https://api.github.com/users/FD-/followers","following_url":"https://api.github.com/users/FD-/following{/other_user}","gists_url":"https://api.github.com/users/FD-/gists{/gist_id}","starred_url":"https://api.github.com/users/FD-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FD-/subscriptions","organizations_url":"https://api.github.com/users/FD-/orgs","repos_url":"https://api.github.com/users/FD-/repos","events_url":"https://api.github.com/users/FD-/events{/privacy}","received_events_url":"https://api.github.com/users/FD-/received_events","type":"User","site_admin":false},"labels":[{"id":278711100,"node_id":"MDU6TGFiZWwyNzg3MTExMDA=","url":"https://api.github.com/repos/google/ExoPlayer/labels/cla:%20yes","name":"cla: yes","color":"159818","default":false}],"state":"closed","locked":false,"assignee":{"login":"botaydotcom","id":690139,"node_id":"MDQ6VXNlcjY5MDEzOQ==","avatar_url":"https://avatars0.githubusercontent.com/u/690139?v=4","gravatar_id":"","url":"https://api.github.com/users/botaydotcom","html_url":"https://github.com/botaydotcom","followers_url":"https://api.github.com/users/botaydotcom/followers","following_url":"https://api.github.com/users/botaydotcom/following{/other_user}","gists_url":"https://api.github.com/users/botaydotcom/gists{/gist_id}","starred_url":"https://api.github.com/users/botaydotcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/botaydotcom/subscriptions","organizations_url":"https://api.github.com/users/botaydotcom/orgs","repos_url":"https://api.github.com/users/botaydotcom/repos","events_url":"https://api.github.com/users/botaydotcom/events{/privacy}","received_events_url":"https://api.github.com/users/botaydotcom/received_events","type":"User","site_admin":false},"assignees":[{"login":"botaydotcom","id":690139,"node_id":"MDQ6VXNlcjY5MDEzOQ==","avatar_url":"https://avatars0.githubusercontent.com/u/690139?v=4","gravatar_id":"","url":"https://api.github.com/users/botaydotcom","html_url":"https://github.com/botaydotcom","followers_url":"https://api.github.com/users/botaydotcom/followers","following_url":"https://api.github.com/users/botaydotcom/following{/other_user}","gists_url":"https://api.github.com/users/botaydotcom/gists{/gist_id}","starred_url":"https://api.github.com/users/botaydotcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/botaydotcom/subscriptions","organizations_url":"https://api.github.com/users/botaydotcom/orgs","repos_url":"https://api.github.com/users/botaydotcom/repos","events_url":"https://api.github.com/users/botaydotcom/events{/privacy}","received_events_url":"https://api.github.com/users/botaydotcom/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-04-03T14:55:52Z","updated_at":"2018-08-06T13:50:57Z","closed_at":"2018-08-06T13:38:41Z","author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/google/ExoPlayer/pulls/4076","html_url":"https://github.com/google/ExoPlayer/pull/4076","diff_url":"https://github.com/google/ExoPlayer/pull/4076.diff","patch_url":"https://github.com/google/ExoPlayer/pull/4076.patch"},"body":"This adds seek capabilities and duration calculation for ts files, based on pcr values.\r\n\r\nThe original idea came from Pull Request #1274, but:\r\n\r\n- Updated to newest ExoPlayer structure\r\n- Refactored to match ExoPlayer's code style\r\n- Improved seek speed by skipping irrelevant payloads while seeking\r\n- Added ts duration calculation (By comparing pcr values from the start and end of the stream)\r\n\r\n**Please Note:**\r\n\r\n- As ts files do not include a real index structure, all seek information has to be collected as it passes the extractor. This means seeking to a stream section that has not been visited yet is slow. I have improved the performance by skipping irrelevant ts packet payloads while seeking, but it's still slower than seeking in a format that has an index structure (and it's still slower than ts seeking in VLC).\r\n\r\n- For calculating the duration of a ts file, this implementation reads a few packets from the start and from the end of the stream to get the maximal difference between the pcr time stamps in the stream. In order to read packets from the end of the stream, the `TsExtractor` gets access to the `DataSource` and `DataSpec`, which it uses to create a new `DataSource` from the end of the stream. This should work faster than skipping through the `ExtractorInput`. The original `DataSource` is then restored.\r\n\r\n- The implementation is thought and has been tested for local ts files. It might not work for other use cases.\r\n\r\nI have read your stance on supporting ts seeking (Issue #966), so don't know if you'll merge this into the library. I personally consider it a far better user experience to support a (somewhat slow) seeking capability than to not support seeking at all. This is particularly annoying when you wish to resume playback from where you stopped previously.\r\nAdditionally,  it would be great to get rid of all these local modifications that make it more effort to migrate whenever there are changes to the ExoPlayer library.\r\n\r\nAnyway, this should provide a good starting point for anyone who'd like to use ts seeking in a recent version of the ExoPlayer library.\r\n"},"comment":{"url":"https://api.github.com/repos/google/ExoPlayer/issues/comments/410714700","html_url":"https://github.com/google/ExoPlayer/pull/4076#issuecomment-410714700","issue_url":"https://api.github.com/repos/google/ExoPlayer/issues/4076","id":410714700,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDcxNDcwMA==","user":{"login":"ojw28","id":7881572,"node_id":"MDQ6VXNlcjc4ODE1NzI=","avatar_url":"https://avatars1.githubusercontent.com/u/7881572?v=4","gravatar_id":"","url":"https://api.github.com/users/ojw28","html_url":"https://github.com/ojw28","followers_url":"https://api.github.com/users/ojw28/followers","following_url":"https://api.github.com/users/ojw28/following{/other_user}","gists_url":"https://api.github.com/users/ojw28/gists{/gist_id}","starred_url":"https://api.github.com/users/ojw28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ojw28/subscriptions","organizations_url":"https://api.github.com/users/ojw28/orgs","repos_url":"https://api.github.com/users/ojw28/repos","events_url":"https://api.github.com/users/ojw28/events{/privacy}","received_events_url":"https://api.github.com/users/ojw28/received_events","type":"User","site_admin":false},"created_at":"2018-08-06T13:50:57Z","updated_at":"2018-08-06T13:50:57Z","author_association":"CONTRIBUTOR","body":"It's using a type of binary search. Performance should be relatively good, but the best way to check is to try it for yourself!"}}
{"actor":{"display_login":"ojw28"}}