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

Add media segment skipping #6157

Merged
merged 6 commits into from
Oct 13, 2024
Merged

Conversation

thornbill
Copy link
Member

@thornbill thornbill commented Oct 2, 2024

Changes

  • Adds support for skipping media segments

Needs cleanup + testing so marking as a draft for now

Issues
N/A

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

private debouncedOnTimeUpdate = throttle(this.handleSegmentActions, 500, { leading: true });

private async fetchMediaSegments(api: Api, itemId: string, includeSegmentTypes: MediaSegmentType[]) {
// FIXME: Replace with SDK getMediaSegmentsApi function when available in stable
Copy link
Contributor

Choose a reason for hiding this comment

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

Unexpected 'fixme' comment: 'FIXME: Replace with SDK...'. no-warning-comments

Copy link
Member Author

Choose a reason for hiding this comment

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

This is dependent on the media segment api being available in the stable sdk release.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

@viown
Copy link
Member

viown commented Oct 4, 2024

Just some things I noted when testing:

  • If I have "Skip" enabled and seek to a duration between the segment, it'll immediately take me to the end of the segment. If there is something there I wanted to take a look at I wouldn't be able to get to it. Maybe it should only skip when it hits the start time of the segment or perhaps avoid skipping altogether when the user manually seeks?
  • When it's about to skip a segment, it can look like the stream is frozen (this is amplified when transcoding). Having some kind of visual indicator (like the one for syncplay) would probably work well here.

@solidsnake1298
Copy link
Member

From my initial testing, this reliably skips intros, but it has not skipped outros or previews.

I'm going to create some test media so I can test the other segment types.

@viown
Copy link
Member

viown commented Oct 7, 2024

From my initial testing, this reliably skips intros, but it has not skipped outros or previews.

I'm going to create some test media so I can test the other segment types.

It looks like all segments after the first will not be skipped because segment is not updated here:

for (let index = lastIndex, segment = segments[index]; index >= 0 && index < segments.length; index += direction) {

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

@solidsnake1298
Copy link
Member

The latest commit is skipping intro, outro, and preview segments reliably. I haven't gotten a chance to create test media with other segment types, but I don't see why those wouldn't also skip.

@solidsnake1298
Copy link
Member

I created some test media for recap and commercial segments, which were also skipped.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

@thornbill thornbill added this to the v10.10.0 milestone Oct 9, 2024
@thornbill thornbill added the feature New feature or request label Oct 9, 2024
@thornbill thornbill marked this pull request as ready for review October 9, 2024 16:14
@thornbill thornbill requested a review from a team as a code owner October 9, 2024 16:14
@thornbill
Copy link
Member Author

thornbill commented Oct 9, 2024

These are great points.

  • If I have "Skip" enabled and seek to a duration between the segment, it'll immediately take me to the end of the segment. If there is something there I wanted to take a look at I wouldn't be able to get to it. Maybe it should only skip when it hits the start time of the segment or perhaps avoid skipping altogether when the user manually seeks?

Good idea. I think this makes sense as an enhancement. We should align on the desired behavior with other client implementations (Android TV).

  • When it's about to skip a segment, it can look like the stream is frozen (this is amplified when transcoding). Having some kind of visual indicator (like the one for syncplay) would probably work well here.

I can definitely see this on my unstable server where I have assigned very limited resources. I wonder if just a toast message when skipping starts would be good enough for now. 🤔

@nielsvanvelzen
Copy link
Member

  • If I have "Skip" enabled and seek to a duration between the segment, it'll immediately take me to the end of the segment. If there is something there I wanted to take a look at I wouldn't be able to get to it. Maybe it should only skip when it hits the start time of the segment or perhaps avoid skipping altogether when the user manually seeks?

Good idea. I think this makes sense as an enhancement. We should align on the desired behavior with other client implementations (Android TV).

This is how I defined the behavior for the skip action in ATV, from https://github.com/jellyfin/jellyfin-androidtv/blob/master/app/src/main/java/org/jellyfin/androidtv/ui/playback/segment/MediaSegmentAction.kt#L15-L16

	/**
	 * Seek to the end of this segment (endTicks). If the duration of this segment is shorter than 1 second it should do nothing to avoid
	 * lagg. The skip action will only execute when playing over the segment start, not when seeking into the segment block.
	 */
	SKIP,

	/**
	 * Ask the user if they want to skip this segment. When the user agrees this behaves like [SKIP]. Confirmation should only be asked for
	 * segments with a duration of at least 3 seconds to avoid UI flickering.
	 */
	ASK_TO_SKIP,

	/**
	 * Mute the audio volume until the end of this segment. The volume level should be restored to the state when this segment started. If
	 * the volume is manually changed by the user during this segment it should no longer restore volume itself. The mute action will always
	 * execute when the segment block is active.
	 */
	MUTE,

@jellyfin-bot jellyfin-bot added the merge conflict Conflicts prevent merging label Oct 9, 2024
@jellyfin-bot

This comment was marked as outdated.

@jellyfin-bot jellyfin-bot removed the merge conflict Conflicts prevent merging label Oct 9, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

@rlauuzo
Copy link
Contributor

rlauuzo commented Oct 12, 2024

I suggest adding a configurable buffer time (e.g., 2 seconds) at the start and end of segments to prevent accidental content skipping.

Copy link
Contributor

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

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

Haven't tested - just reviewed. 😅

Am I right, it will skip the "outro" even we seek to it?

src/apps/stable/features/playback/utils/mediaSegments.ts Outdated Show resolved Hide resolved
src/apps/stable/features/playback/utils/mediaSegments.ts Outdated Show resolved Hide resolved
src/strings/en-us.json Outdated Show resolved Hide resolved
Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

Copy link

sonarcloud bot commented Oct 13, 2024

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

ESLint doesn't pass. Please fix all ESLint issues.

@jellyfin-bot
Copy link
Collaborator

Cloudflare Pages deployment

Latest commit aef9482824f22efd0e69c72f3ad8112657abd8cc
Status ✅ Deployed!
Preview URL https://cdb680bb.jellyfin-web.pages.dev
Type 🔀 Preview

@thornbill
Copy link
Member Author

Am I right, it will skip the "outro" even we seek to it?

I just pushed a change that should bring the behavior inline with what Niels implemented for Android TV... I hope. 🤞

If you seek forward into a segment it will take the action as normal. If your previous player time is later than the start time of the segment no action is taken.

I made this behavior specific to the skip action because I think for others (prompting) it might still make sense to invoke the action. 🤷‍♂️

@nielsvanvelzen
Copy link
Member

Skipping seems to work mostly as I'd expect except for one issue that I encountered. When I choose to skip outros and manually seek into an outro segment, it will be skipped. My expectation would be that manually seeking into it will not trigger the skip.

Otherwise it doesn't have some bugs that the current ATV implementation has, so that's great. (In ATV skipping to the end of the video will close the player instead of going to the next queue item :p)

@thornbill
Copy link
Member Author

Yeah using the current time base approach we can only detect if we skip back into a segment not forward... I don't think we currently have any better way to detect when we have skipped unless we check if the difference between playtime updates is greater than some threshold. 🤷‍♂️

@viown
Copy link
Member

viown commented Oct 13, 2024

Yeah using the current time base approach we can only detect if we skip back into a segment not forward... I don't think we currently have any better way to detect when we have skipped unless we check if the difference between playtime updates is greater than some threshold. 🤷‍♂️

Perhaps we could only trigger the skip if the current time is close to StartTicks by some difference (<1s), and also possibly checking lastTime < StartTicks?

@dmitrylyzo
Copy link
Contributor

We will probably perform bigger steps with increased playback rate, and difference will depend on that.

The most reliable way is to add some extra flag to the timeupdate event, which is on when we set the current time of the player.

@thornbill
Copy link
Member Author

I was thinking we could add an event on seeking in the playback manager and use that to ignore the segment if the next time update falls in one...

My question is if the current implementation is "good enough" for the initial PR or if this should be added before merging. 🤷‍♂️ I'm hoping to get this in for the next unstable build.

@nielsvanvelzen
Copy link
Member

IMO current state is good enough to merge and we can improve upon it in 10.10.z releases.

@thornbill thornbill merged commit a7185ed into jellyfin:master Oct 13, 2024
12 checks passed
@thornbill thornbill deleted the media-segment-actions branch October 13, 2024 20:38
@pimw1
Copy link

pimw1 commented Oct 14, 2024

I've installed the "Chapter Segments" plugin and succesfully ran the "media segment scan" . For example, it was succesful for the below series episode.

[2024-10-14 15:02:52.631 +02:00] [INF] [24] Jellyfin.Server.Implementations.MediaSegments.MediaSegmentManager: Media Segment provider "Chapter Segments Provider" found 1 for "/data/media/tv/Criminal Minds/Season 03/Criminal Minds (2005) - S03E12 - 3rd Life [DSNP WEBDL-1080p][EAC3 5.1][h264]-playWEB.mkv"

When using https://cdb680bb.jellyfin-web.pages.dev/ to play this episode, i see the intro is recognized in the timeline

image

However, i don't get popup to skip the intro when the series progresses into that segment. How should this look like / behave?

@dmitrylyzo
Copy link
Contributor

How should this look like / behave?

You need to select an action for the segment type in User settings / Playback. The action is applied without a prompt. In the future, there will be "Ask to skip".

@pimw1
Copy link

pimw1 commented Oct 14, 2024

Ah got it, thanks. It works as expected. I also notice that the transcoding is apparently taking it into account, since i don't notice the usual delay (which i would notice when manually skipping through the media). Nice!

@pimw1
Copy link

pimw1 commented Oct 14, 2024

Just a thought: perhaps introduce a global setting for skipping behaviour per segment type, which users can overwrite when they choose to. Reason: i don't see my non-techy family members enabling the skip behaviour.

@pimw1
Copy link

pimw1 commented Oct 14, 2024

Upon further testing, intro skipping sometimes does cause a tempory freeze due to transcoding. For a future update, it would be nice if transcoding would skip the intro anyway if the user setting is set to skip.

@thornbill thornbill added the release-highlight A major new feature for the next release label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request release-highlight A major new feature for the next release
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants