-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Android] Selecting a subtitle track when decoding to surfaceview freezes video #284
Comments
what about not decode to surfaceview? if decode to surfaceview, subtitle will not be rendered, you have to draw subtitle yourself |
doc says I tried this because I wasn't able to get the HDMI device (television) turn ON dolby vision or HDR mode automatically when playing dovi files or HDR By the way if you know how to achieve it please let me know |
decode to surfaceview can support hdr, but not dolby vision. dolby vision requires decoder support, for example using decoder |
Can you share your example so I can test the freeze? |
I can confirm decode to surface view is the only way I found to get Dolby Vision to toggle on on TV (I am using a Google Streamer with LG C4 OLED tv, both DV compatible) without this, the television never toggles Dolby vision. Same thing on MPV (vo:mediacodec_embed,hwdec:mediacodec) and setting "wid" (same behavior as decode to surface) This is not an issue for me to use decode to surfaceview, but I can't disable subtitles rendering (setting "subtitle" or "cc" to 0 has no effect) |
Do you mean video file or code ? file is https://github.com/ietf-wg-cellar/matroska-test-files/raw/master/test_files/test5.mkv I you want code, I need to create a small repro, project is quite large |
dolby vision profile 5 or 8? decode to surfaceview can't display dolby vision on my phone. my example can toggle hdr10, and i render dolby vision as hdr10. i need the code |
private val surfaceCallback = object : SurfaceHolder.Callback {
private var currentRef: Long = 0L
set(value) {
field = value
if (mdkConfig.decodeToSurfaceView) {
LibMdkJni.setProperty(handle, "video.decoder", "surface=$value")
}
}
override fun surfaceCreated(holder: SurfaceHolder) {
currentRef = LibJni.deleteGlobalRef(currentRef)
currentRef = LibJni.createGlobalRef(holder.surface)
if (mdkConfig.decodeToSurfaceView) return
LibMdkJni.updateNativeSurface(handle, 0, 0, 0, 0)
LibMdkJni.updateNativeSurface(handle, currentRef, -1, -1, 0)
}
override fun surfaceDestroyed(holder: SurfaceHolder) {
currentRef = LibJni.deleteGlobalRef(currentRef)
if (mdkConfig.decodeToSurfaceView) return
LibMdkJni.updateNativeSurface(handle, 0, 0, 0, 0)
}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
if (mdkConfig.decodeToSurfaceView) return
LibMdkJni.updateNativeSurface(handle, currentRef, width, height, 0)
}
} dv 5, 8.4, 8.1 They all work with MPV even 5 (it should not work on google streamer O_o) video decoders:
so when mdkConfig.decodeToSurfaceView == true Tried to change colorspace without effect |
By the way dolby vision is not an issue anymore, the main issue is subtitle rendering. I can use new api to get subs as text and display them in an Android view, but calling player->setTracks causes the video freeze
No effect, video still freezes after track selection |
i don't think dv can be turned on if decode to surfaceview but without additional settings. no effect on my phone. can you show me mpv and mdk log? AMediaVodec:dv=1 will output sdr image iirc. i also need the log with set(colorspaceunknown) can you modify my android example so i can test the freeze soon. i'm not familiar with ui. |
Will fork project tomorrow and update it |
Are you using AMediaFormat in your internal mdk code ? |
yes |
If the TV does not enable DV mode automatically, maybe there is missing info in MediaFormat? Exoplayer's implementation does this in case of DV video: MediaCodecUtil.java MediaFormatUtil.maybeSetColorInfo(mediaFormat, format.colorInfo);
if (MimeTypes.VIDEO_DOLBY_VISION.equals(format.sampleMimeType)) {
// Some phones require the profile to be set on the codec.
// See https://github.com/google/ExoPlayer/pull/5438.
Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(format);
if (codecProfileAndLevel != null) {
MediaFormatUtil.maybeSetInteger(
mediaFormat, MediaFormat.KEY_PROFILE, codecProfileAndLevel.first);
}
} @Nullable
public static Pair<Integer, Integer> getCodecProfileAndLevel(Format format) {
if (format.codecs == null) {
return null;
}
String[] parts = format.codecs.split("\\.");
// Dolby Vision can use DV, AVC or HEVC codec IDs, so check the MIME type first.
if (MimeTypes.VIDEO_DOLBY_VISION.equals(format.sampleMimeType)) {
return getDolbyVisionProfileAndLevel(format.codecs, parts);
}
switch (parts[0]) {
case CODEC_ID_AVC1:
case CODEC_ID_AVC2:
return getAvcProfileAndLevel(format.codecs, parts);
case CODEC_ID_VP09:
return getVp9ProfileAndLevel(format.codecs, parts);
case CODEC_ID_HEV1:
case CODEC_ID_HVC1:
return getHevcProfileAndLevel(format.codecs, parts, format.colorInfo);
case CODEC_ID_AV01:
return getAv1ProfileAndLevel(format.codecs, parts, format.colorInfo);
case CODEC_ID_MP4A:
return getAacCodecProfileAndLevel(format.codecs, parts);
default:
return null;
}
}
@Nullable
private static Pair<Integer, Integer> getDolbyVisionProfileAndLevel(
String codec, String[] parts) {
if (parts.length < 3) {
// The codec has fewer parts than required by the Dolby Vision codec string format.
Log.w(TAG, "Ignoring malformed Dolby Vision codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed Dolby Vision codec string: " + codec);
return null;
}
@Nullable String profileString = matcher.group(1);
@Nullable Integer profile = dolbyVisionStringToProfile(profileString);
if (profile == null) {
Log.w(TAG, "Unknown Dolby Vision profile string: " + profileString);
return null;
}
String levelString = parts[2];
@Nullable Integer level = dolbyVisionStringToLevel(levelString);
if (level == null) {
Log.w(TAG, "Unknown Dolby Vision level string: " + levelString);
return null;
}
return new Pair<>(profile, level);
} |
Updated sample to latest android dev practices (UI is pretty similar to flutter) By the way I find something
Enregistrement.de.l.ecran.2025-01-31.a.11.26.42.mov |
Describe the bug
if "decode to surfaceview", and select a subtitle track then video freezes (audio is still running fine)
player::updateNativeSurface
instead ofplayer::setProperty
To Reproduce
Expected behavior
No freeze
Environment:
Logs
Enregistrement.de.l.ecran.2025-01-30.a.11.00.07.mov
The text was updated successfully, but these errors were encountered: