Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Fast Forward and Rewind during Timeshifting and playing back of Recorded Shows #239

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

TheDiamondPicks
Copy link
Contributor

Title says all

I have tested this, and it seems to work well although it does cause low memory warnings on the Mi Box.

mDataSource.setSpeed(translatedSpeed);
mExoPlayer.setPlaybackParameters(new PlaybackParameters(translatedSpeed, 0));
mDataSource.setSpeed(speed);
mExoPlayer.setPlaybackParameters(new PlaybackParameters(speed, 1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this works out?

mDataSource.setSpeed(speed); passes the speed value over to TVheadend, which expects:

speed              u32   required   Specify speed (0=pause, 100=1x fwd, -100=1x backward)

http://tvheadend.org/projects/tvheadend/wiki/Htsp#subscriptionSpeed-Added-in-version-9

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-added the translated speed in ed1dcf9 and 3284969

Copy link
Owner

@kiall kiall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The high memory usage might be related to my comment inline re passing of the speed through to the TVHeadend, without passing it through, TVHeadend will as far as I know keep sending you video data as soon as it has it - rather than letting it buffer server side. Will test this out tomorrow.

@TheDiamondPicks
Copy link
Contributor Author

It seems that rewind is not working - it doesn't seem like HtspSession#onTimeShiftSetPlaybackParams is being called at all when rewinding, at least not in my testing.

@kiall kiall mentioned this pull request Mar 11, 2018
@kiall
Copy link
Owner

kiall commented Mar 11, 2018

I've been refreshing my memory... Rewind is significantly harder, as ExoPlayer doesn't support playing in reverse (as media codecs in general don't really support that either). I've created PR #243 with your code, and a few extra changes - but it still doesn't seem to be quite reliable yet - specifically, if you pause, wait a bit, and then fast-forward through the buffer - the audio will get way out of sync.

@TheDiamondPicks
Copy link
Contributor Author

Much tidier now, thanks!

With regards to rewind support, is it possible to simply skip back frames, it wouldn't be as nice as changing the speed obviously, but it's better than nothing. Although this might not be practical, my understanding of ExoPlayer is rather limited at this stage.

I will see if I can reproduce the audio sync issue as well, because it sounds like it could be quite tricky to sort out.

(a little offtopic but I would appreciate your input in #242)

@kiall
Copy link
Owner

kiall commented Mar 11, 2018

With regards to rewind support, is it possible to simply skip back frames, it wouldn't be as nice as changing the speed obviously, but it's better than nothing. Although this might not be practical, my understanding of ExoPlayer is rather limited at this stage.

I've been playing with that - the code is messy as hell but works - I've pushed that commit to the other PR.

I will see if I can reproduce the audio sync issue as well, because it sounds like it could be quite tricky to sort out.

What I don't quite get is, ExoPlayer should be handling that for us. All the different tracks -audio, video, text come with presentation timestamps - and the audio tracks timestamp is used to synchronise the playback rates and positions of each. If there is a mismatch, ExoPlayer should pause the video - line things back up - and resume. So, I'm quite confused as to how the delay exists :)

re the translated speeds - So - there doesn't seem to be a fixed mapping from the UI display (2x, 3x, 4x, 5x) to the value we receive! Playing with this for the last little while, I keep getting different values passed in. I've not quite figured out what's happening here, but I suspect Android TV's UI is "lying" - and when it says for example "2x Rewind" on the UI, it's giving us totally different numbers.

speed: increases or decreases the time to play back a set of audio or video frames. It is expressed as a multiplicative factor, where normal speed is 1.0f.

However - the UI doesn't even go below -5x rewind, yet we get much lower numbers than -5.0f in. Humm.

@TheDiamondPicks
Copy link
Contributor Author

TheDiamondPicks commented Mar 11, 2018

With regards to the audio sync issue, are we able to print timestamps of the audio / video every second or so, so we can see when it becomes out of sync?

With the speed factors, from what I saw in my testing it was 2, 8, 32 etc, do the numbers match this pattern?

@michaelarnauts
Copy link

@TheDiamondPicks have you given up on tvheadend in Android TV, or did you switch to another TV backend service?

@TheDiamondPicks
Copy link
Contributor Author

@michaelarnauts yeah, I've switch to Plex now, which unfortunately doesn't have a live channels backend, but the integration into the rest of Plex outweighed those downsides for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants