google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.75k stars 6.03k forks source link

Arabic subtitles alignment #2194

Open bluemix opened 7 years ago

bluemix commented 7 years ago

As shown in the screenshot from ExoPlayer 2.0.4, screenshot_1481657400

In Arabic (RTL), the dashes ("-") and the parenthesis, should start from the same direction as the Arabic language, i.e., from the right to the left, as shown below. screenshot_1481657400_corrected

Can you provide a solution to fix this? or is it already being fixed?

Thanks a lot :)

ojw28 commented 7 years ago

We'd definitely like to make sure RTL captions work properly :). Please could you provide some sample media so that we can investigate the issue? It would be helpful if you could provide some information about a particular point in the video where the issue occurs, and the expected output at that position (similar to the example you provide above). This will help us verify a fix.

bluemix commented 7 years ago

Yes, sure. The srt file: 69D8D411-3CFC-6E92-6CE6-0DDB43A62921_ar_transfile.txt

The mentioned caption was at line 4317 (or caption number 936 at time 01:27:35,270 --> 01:27:38,489).

The correct formatting should be as shown in the second screenshot of my first comment above.

ojw28 commented 5 years ago

This can likely be solved using Android's BidiFormatter class prior to painting the subtitle.

bluemix commented 5 years ago

@MurtadhaS i think you might get benefit of this

Furystorm commented 2 years ago

Hello! Many years passed and this problem seems not fixed yet. I tested in exoplayer 2.14.2, the Arabic comma "،" , should stay at left, but appears at right. At the same time, the Arabic question mark "؟" appears at the correct place. Example subtitle text: ،في الحياة اليومية أو العمل فكيف نسأل عن أسمائهم؟

If I use the webview by subView.setViewType(SubtitleView.VIEW_TYPE_WEB) , the Arabic comma appears at the correct place. But in this mode, the subtitle's style is unruly. For example, CaptionStyleCompat.EDGE_TYPE_OUTLINE the outline is oddly, CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW the shadow is truncated at bottom. How to make correct style without embedded styles?

As mentioned above, how does BidiFormatter works? Or should it be used in exoplayer's code?

icbaker commented 2 years ago

If I use the webview by subView.setViewType(SubtitleView.VIEW_TYPE_WEB) , the Arabic comma appears at the correct place

That's great that the webview works well for this - but sorry to hear about your styling issues. I've dug down in more detail below, but I think we should continue further discussion on WebView styling in separate issues in order to keep this one focussed on the alignment problem in the canvas-based subtitle output.

If I use the webview by subView.setViewType(SubtitleView.VIEW_TYPE_WEB) , the Arabic comma appears at the correct place. But in this mode, the subtitle's style is unruly. For example, CaptionStyleCompat.EDGE_TYPE_OUTLINE the outline is oddly,

I can reproduce this in 2.17.1 (screenshots below), using the "TTML positioning" sample and the following patch to the demo app in PlayerActivity#onCreate:

    playerView.getSubtitleView().setViewType(SubtitleView.VIEW_TYPE_WEB);
    playerView.getSubtitleView().setStyle(new CaptionStyleCompat(
        /* foregroundColor= */ Color.RED,
        /* backgroundColor= */ Color.GREEN,
        /* windowColor= */ Color.CYAN,
        CaptionStyleCompat.EDGE_TYPE_OUTLINE,
        /* edgeColor= */ Color.BLACK,
        /* typeface= */ null
    ));

I've filed https://github.com/google/ExoPlayer/issues/10137 to track this specifically (so that we can keep this issue focussed on the alignment problems).

Outline screenshots **Canvas** ![Canvas with outline](https://user-images.githubusercontent.com/1279752/161011358-574e3f38-8f10-42c9-8015-80c3e05a229b.png) ----- **WebView** ![WebView with outline](https://user-images.githubusercontent.com/1279752/161011372-08f6e8c2-0180-4801-92b3-9cd55b6d6ed3.png)

CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW the shadow is truncated at bottom.

I wasn't able to reproduce this using the dropshadow version of the patch above. The WebView and Canvas based outputs do look different, but I think the WebView output actually more closely reflects the sample shown in the Android system caption style settings window. Please can you file a new bug with clear repro steps (can be based on the demo app) and screenshots showing what you see (similar to what I've included here).

dropshadow screenshots **Canvas** ![Canvas with dropshadow](https://user-images.githubusercontent.com/1279752/161012663-c9099c45-2084-475d-b364-5c7f2115484a.png) **WebView** ![Webview with dropshadow](https://user-images.githubusercontent.com/1279752/161012653-56e36882-598c-4a5d-8300-63bdb463ab4c.png)
sajjadshahbazi commented 1 year ago

I lose focus when using subView.setViewType(SubtitleView.VIEW_TYPE_WEB). I think the subtitle widget keeps focus. how to handle the problem?

icbaker commented 1 year ago

@sajjadshahbazi Please file a new issue in https://github.com/androidx/media with full details and repro instructions, and we can take a look.