Skip to content

Add ffmpeg H.264/MKV video recording with configurable format selection#26

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/update-video-recording-method
Draft

Add ffmpeg H.264/MKV video recording with configurable format selection#26
Copilot wants to merge 5 commits intomasterfrom
copilot/update-video-recording-method

Conversation

Copy link

Copilot AI commented Feb 4, 2026

The SHIFT-M recording feature used a hand-rolled FLC encoder producing 540MB files for typical gameplay. This adds H.264/MKV encoding via the existing ffmpeg integration, reducing file sizes ~50-100x while maintaining playability in standard media players.

Changes

MKV Encoder (src/bflib_fmvids.cpp)

  • H.264 encoder with palette conversion pipeline: 8-bit indexed → RGB24 → YUV420P
  • CRF 23, GOP 114 frames (~2s at 57 FPS), medium preset
  • Outputs to scrshots/game####.mkv

Configuration

  • Added VIDEO_RECORDING_FORMAT to config_keeperfx.c supporting MKV (default) and FLC
  • Format constants defined in scrcapt.h (VIDEO_FORMAT_MKV, VIDEO_FORMAT_FLC)

Integration (src/scrcapt.c)

  • Recording functions dispatch to MKV or FLC encoder based on configuration
  • Original FLC implementation preserved unchanged

Build

  • Added libswscale to deps/CMakeLists.txt for pixel format conversion

Example Configuration

; File format for video recording (SHIFT-M); MKV or FLC.
; MKV provides 50-100x better compression and is playable in standard media players.
VIDEO_RECORDING_FORMAT=MKV

Technical Notes

  • Maintains 57 FPS framerate matching original FLC format
  • Requires 8-bit color mode (existing constraint)
  • MKV encoder allocates two frames (RGB24 intermediate, YUV420P output) plus sws_context
  • Uses existing ffmpeg dependencies, no new external libraries

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 4, 2026 16:54
Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
…e, add format constants

Co-authored-by: Cerwym <1760289+Cerwym@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace legacy FLC encoder with ffmpeg for recording Add ffmpeg H.264/MKV video recording with configurable format selection Feb 4, 2026
Copilot AI requested a review from Cerwym February 4, 2026 17:00
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.

2 participants