Skip to content

Conversation

@rafel-roboflow
Copy link
Contributor

@rafel-roboflow rafel-roboflow commented Jan 13, 2026

What does this PR do?

Resolves DG-18

Videos recorded on mobile devices in portrait mode were displaying incorrectly. The video dimensions showed as landscape (1920×1080) even though the video should appear as portrait (1080×1920). This happened because aiortc's MediaPlayer and PyAV don't automatically apply rotation metadata stored in the video's displaymatrix.

Solution
Detect rotation metadata using ffprobe (PyAV doesn't reliably expose displaymatrix side_data)
Apply rotation correction usin cv2.rotate() (which is fast for 90 deg rotations)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • [x ] I have tested this change locally
  • I have added/updated tests for this change

I tested it with the same video provided by the user in DG-18.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context


Note

Corrects orientation of videos by reading rotation metadata and rotating frames during processing.

  • Adds get_video_rotation, get_cv2_rotation_code, and rotate_video_frame in webrtc_worker/utils.py (uses ffmpeg-python and OpenCV)
  • Extends VideoFrameProcessor.set_track(track, rotation_code=None) and applies rotation in _process_frame_async
  • On video upload completion, probes file rotation and passes rotation_code to MediaPlayer/OnDemandVideoTrack setup in webrtc.py
  • Improves logging around upload and rotation detection
  • Updates requirements/_requirements.txt to include ffmpeg-python

Written by Cursor Bugbot for commit d2e8607. This will update automatically on new commits. Configure here.

@grzegorz-roboflow
Copy link
Collaborator

bugbot run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants