Skip to content

Instantly share code, notes, and snippets.

@markvdb
Created September 10, 2023 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markvdb/3dd03ec9fbcf9ec7c35010c1e1a74bd3 to your computer and use it in GitHub Desktop.
Save markvdb/3dd03ec9fbcf9ec7c35010c1e1a74bd3 to your computer and use it in GitHub Desktop.
scaling and pillarboxing the input from the grabber
ffmpeg \
-y \
-v debug \
-report \
-nostdin \
-init_hw_device "vaapi=intel:/dev/dri/renderD128" \
-hwaccel vaapi \
-hwaccel_output_format vaapi \
-hwaccel_device intel \
-filter_hw_device intel \
-probesize 10M \
-analyzeduration 10M \
-f v4l2 \
-video_size 1280x1024 \
-framerate 30 \
-i /dev/video2 \
-itsoffset 0.064 \
-f alsa -sample_rate 48000 \
-channels 2 \
-i hw:1 \
-threads:0 0 \
-aspect 16:9 \
-filter_complex "[1:a]channelsplit=channel_layout=stereo[left][right];[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black,format=nv12,hwupload [vout]"\
-map "[vout]" \
-c:v:0 h264_vaapi \
-rc_mode CBR \
-g 30 \
-x264opts "keyint=30:min-keyint=30:no-scenecut" \
-maxrate:v:0 5000k \
-bufsize:v:0 8192k \
-b:v:0 3000k \
-qmin:v:0 1 \
-map "[left]:1" \
-ac 1 \
-strict \
-2 \
-c:a aac \
-b:a 128k \
-ar 48000 \
-map "[right]:2" \
-ac 1 \
-strict \
-2 \
-c:a aac \
-b:a 128k \
-ar 48000 \
-y \
-f mpegts /tmp/tmp.ts
@markvdb
Copy link
Author

markvdb commented Sep 10, 2023

I've tested the above pipeline with the MS2130 and a 12801024, resp. 1024768 source resolution.

Note that the grabber's supported output resolutions apparently are the following according to the YiuzukiHD github docs:

  • 1920*1080 (16/90)
  • 1600*1200 (4/3)
  • 1360*768 (16/9-ish)
  • 1280*1024 (5/4)
  • 1280*960 (4/3)
  • 1280*720 (16/9)
  • 1024*768 (4/3)
  • 800*600 (4/3)
  • 720*576 (5/4)
  • 720*480 (3/2)
  • 640*480 (4/3)

All of these should be supported at 10, 20, 30, 50 and 60 Hz.

@markvdb
Copy link
Author

markvdb commented Sep 11, 2023

At first sight, it looks as if we can ignore resolution changes as long as the source aspect ratio stays the same. That would be wonderful, considering most projectors will negotiate the same aspect ratio over and over again

This kind of pseudocode should work then:

previous_signal
current_signal
previous_source_resolution
current_source_resolution
current_source_aspect_ratio
previous_source_aspect_ratio

  • if ( current_signal && 1.25 <= current_source_aspect_ratio <=1.78 )
    • if ( !previous_signal | current_source_aspect_ratio != previous_source_aspect_ratio)
      • restart ffmpeg pipeline; parameter: current_source_resolution
    • else
      • do nothing
  • else
    • generic FOSDEM slide on stream

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