Skip to content

Commit

Permalink
Add option to always burn in subtitles when transcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
GertSallaerts committed Feb 14, 2025
1 parent bc6336c commit c27be2c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import kotlin.time.Duration.Companion.milliseconds
import org.jellyfin.androidtv.ui.playback.PlaybackManager as LegacyPlaybackManager

val playbackModule = module {
single { LegacyPlaybackManager(get()) }
single { LegacyPlaybackManager(get(), get()) }
single { VideoQueueManager() }
single<MediaManager> { RewriteMediaManager(get(), get(), get(), get()) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
*/
var subtitlesTextSize = floatPreference("subtitles_text_size", 1f)

/**
* Always burn in subtitles when transcoding
*/
var alwaysBurnInSubtitleWhenTranscoding = booleanPreference("always_burn_in_subtitle_when_transcoding", false)

/**
* Show screensaver in app
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,14 @@ public void onResponse(StreamInfo internalResponse) {
if (mVideoManager == null)
return;
mCurrentOptions = internalOptions;
if (internalOptions.getSubtitleStreamIndex() == null) burningSubs = internalResponse.getSubtitleDeliveryMethod() == SubtitleDeliveryMethod.ENCODE;

if (internalOptions.getSubtitleStreamIndex() == null) {
boolean alwaysBurnTranscode = userPreferences.getValue().get(UserPreferences.Companion.getAlwaysBurnInSubtitleWhenTranscoding());
boolean transcoding = internalResponse.getPlayMethod().equals(PlayMethod.TRANSCODE);
boolean encodedSubs =internalResponse.getSubtitleDeliveryMethod() == SubtitleDeliveryMethod.ENCODE;
burningSubs = encodedSubs || (transcoding && alwaysBurnTranscode);
}

startItem(item, position, internalResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.coroutines.launch
import org.jellyfin.androidtv.data.compat.PlaybackException
import org.jellyfin.androidtv.data.compat.StreamInfo
import org.jellyfin.androidtv.data.compat.VideoOptions
import org.jellyfin.androidtv.preference.UserPreferences
import org.jellyfin.androidtv.util.apiclient.Response
import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.hlsSegmentApi
Expand Down Expand Up @@ -52,7 +53,8 @@ private fun createStreamInfo(
}

class PlaybackManager(
private val api: ApiClient
private val api: ApiClient,
private val userPreferences: UserPreferences
) {
fun getVideoStreamInfo(
lifecycleOwner: LifecycleOwner,
Expand Down Expand Up @@ -101,6 +103,7 @@ class PlaybackManager(
allowVideoStreamCopy = true,
allowAudioStreamCopy = true,
autoOpenLiveStream = true,
alwaysBurnInSubtitleWhenTranscoding = userPreferences[UserPreferences.alwaysBurnInSubtitleWhenTranscoding]
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class PlaybackPreferencesScreen : OptionsFragment() {
default { (UserPreferences.subtitlesTextSize.defaultValue * 100f).roundToInt() }
}
}

checkbox {
setTitle(R.string.lbl_always_burn_in_subtitle_when_transcoding)
setContent(R.string.sum_always_burn_in_subtitle_when_transcoding)
bind(userPreferences, UserPreferences.alwaysBurnInSubtitleWhenTranscoding)
}
}

category {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@
<string name="segment_type_unknown">Unknown segments</string>
<string name="skip_forward_length">Skip forward length</string>
<string name="preference_enable_trickplay">Enable trickplay in video player</string>
<string name="lbl_always_burn_in_subtitle_when_transcoding">Always burn in subtitle when transcoding</string>
<string name="sum_always_burn_in_subtitle_when_transcoding">Burn in all subtitles when transcoding is triggered. This ensures subtitle synchronisation after transcoding at the cost of reduced transcoding speed.</string>
<plurals name="seconds">
<item quantity="one">%1$s second</item>
<item quantity="other">%1$s seconds</item>
Expand Down

0 comments on commit c27be2c

Please sign in to comment.