Skip to content

Conversation

@nicomiguelino
Copy link
Contributor

@nicomiguelino nicomiguelino commented Nov 12, 2025

Issues Fixed

Description

  • Add support for rotating content (videos, images, web pages)
  • I still need to add a setting in the web interface that lets them control the rotation angle.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

@nicomiguelino nicomiguelino self-assigned this Nov 12, 2025
@github-project-automation github-project-automation bot moved this to In progress in Anthias Nov 12, 2025
@nicomiguelino nicomiguelino changed the title feat: rotate video by 90 degrees clockwise feat: add support for rotating content (videos, images, web pages) Nov 12, 2025
- Refactor FFMPEGMediaPlayer to use rotation settings instead of hardcoded values
- Add __get_rotation_filter() to map rotation angles to ffplay filters
- Update VLCMediaPlayer to use rotation settings with proper angle mapping
- Supports 0°, 90°, 180°, and 270° rotation angles
@sonarqubecloud
Copy link

@quinlan96
Copy link

quinlan96 commented Dec 8, 2025

Thank you for looking into this! I run Anthias on a few vertically mounted displays and have been wanting this feature for a while. The displays are all powered by Raspberry Pi 4B's (4GB RAM), so I'll share what I've learnt from experimenting with solutions for this hardware.

WebView

I found this patch for QT5 which adds a rotation parameter to the linuxfb platform. Upon compiling the patched QT5 and rebuilding the anthias-viewer container, orientation can be controlled with the QT platform environment variable:

QT_QPA_PLATFORM=linuxfb:rotation={0,90,180,270}

This gist contains a recreation of the patch I made for QT 5.15.14. I've been applying it from the build_qt5.sh script like so:

pushd "/src/qt$QT_MAJOR/qtbase"
patch -p1 < /webview/qt5_linuxfb_rotation.patch
popd

So far this patch has been working flawlessly with web page and images.

Videos

I hadn't looked into rotating videos prior to now, but this feature request got me playing around with VLC options. Using your code I couldn't get the rotate filter to work, however I found a suggestion that some filters had better support when hardware decoding was disabled with the --avcodec-hw=none option. Again this didn't work for me within the viewer, but when applied to the standalone vlc command it finally bore fruit. The video was rotated, but the rotate filter preserved the original aspect ratio so the vertical image was squished into a 16:9 frame. I found the desired effect could be achieved with the transform filter instead:

vlc --avcodec-hw=none --video-filter=transform{type=90} file.mp4

Success!

As for why it won't work with python-vlc, apparently the underlying library libvlc ignores this option when constructing a new instance. This means it can be bypassed by applying the option directly to a media object.

In media_player.py:

    def set_asset(self, uri, duration):
        media = self.instance.media_new(uri)
        media.add_option(':avcodec-hw=none')
        self.player.set_media(media)
        ...

The video-filter must still be passed with the Instance options:

    def __get_options(self):
        ...
        return [
            f'--alsa-audio-device={self.get_alsa_audio_device()}',
            f'--video-filter=transform{{type={angle}}}',
        ]

I have also tested with ffplay and can confirm the -vf options work, although playblack on the Pi 4B 4GB is extremely choppy when compared to VLC, which can handle 1080p smoothly in any orientation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants