Skip to content

Commit

Permalink
CAX 2024 build
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mattsson <[email protected]>
  • Loading branch information
datamattsson committed Aug 5, 2024
1 parent 21dc3a5 commit 4883810
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 23 deletions.
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ config:
debug: true
mv:
ip_addr: 192.168.37.5
remote_timeout: 2.0 # Positive float timeout in seconds for IP-based command
# If null is given, the socket is put in blocking mode
command_delay: .1 # Positive float delay after sending a MV command
# Tune this if timeouts are being hit on quad layouts
modes:
3840x2160p60: 3
3840x2160p30: 5
Expand All @@ -60,12 +64,12 @@ profiles:
scene: quad
# Keyed from with config.mv.modes
output: 3840x2160p60
# Consume key (viewport) with value (HDMI input)
layout: # only use as many keys as there are viewports
one: 1
two: 2
three: 3
four: 4
# Consume key (HDMI input) and put in value (Multi-Viewer viewport)
layout:
HDMI-1: 1
HDMI-2: 2
HDMI-3: 3
HDMI-4: 4
audio: 3
encoder:
# 50 - 200 "quality" slider, default is 100, ignored when --mbps is used
Expand All @@ -74,6 +78,23 @@ profiles:
framerate: raw
# 1920x1080 etc, raw means match input
resolution: raw
player:
mv:
# Keyed from with config.mv.scenes
scene: single
# Keyed from with config.mv.modes
output: 3840x2160p60
# Consume key (HDMI input) with value (viewport output)
layout:
HDMI-2: 1
audio: 3
encoder:
# 50 - 200
bitrate: 200
# frame rate, raw matches input, half, one-third, quarter are valid
framerate: raw
# 1920x1080 etc, raw means match input
resolution: 1920x1080
```
## Prequisites and Hardware SKUs
Expand Down Expand Up @@ -108,7 +129,7 @@ These are the ones I've gone through.

#### Encoders

Magewell Pro Converters all have the same API and Ultra Encode would need work.
Magewell Pro Converters all have the same API. The Ultra Encode series would need work.

- Magewell Pro Convert HDMI 4K Plus (Works 100%)
- Magewell Pro Convert HDMI Plus
Expand All @@ -122,6 +143,12 @@ Magewell Pro Converters all have the same API and Ultra Encode would need work.

![](assets/README/marketecture.png)

## Demos

A short snippet that describes the benefit of using 4K cameras in single view modes.

[![Watch the video](https://img.youtube.com/vi/PLqVQgK3UIY/maxresdefault.jpg)](https://youtu.be/PLqVQgK3UIY)

<!--
## Demonstration

Expand Down
33 changes: 27 additions & 6 deletions config.yaml-dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ config:
debug: true
mv:
ip_addr: 192.168.37.5
remote_timeout: 2.0 # Positive float timeout in seconds for IP-based command
# If null is given, the socket is put in blocking mode
command_delay: .1 # Positive float delay after sending a MV command
# Tune this if timeouts are being hit on quad layouts
modes:
3840x2160p60: 3
3840x2160p30: 5
Expand All @@ -34,12 +38,12 @@ profiles:
scene: quad
# Keyed from with config.mv.modes
output: 3840x2160p60
# Consume key (viewport) with value (HDMI input)
layout: # only use as many keys as there are viewports
one: 1
two: 2
three: 3
four: 4
# Consume key (HDMI input) and put in value (Multi-Viewer viewport)
layout:
HDMI-1: 1
HDMI-2: 2
HDMI-3: 3
HDMI-4: 4
audio: 3
encoder:
# 50 - 200 "quality" slider, default is 100, ignored when --mbps is used
Expand All @@ -48,3 +52,20 @@ profiles:
framerate: raw
# 1920x1080 etc, raw means match input
resolution: raw
player:
mv:
# Keyed from with config.mv.scenes
scene: single
# Keyed from with config.mv.modes
output: 3840x2160p60
# Consume key (HDMI input) with value (viewport output)
layout:
HDMI-2: 1
audio: 3
encoder:
# 50 - 200
bitrate: 200
# frame rate, raw matches input, half, one-third, quarter are valid
framerate: raw
# 1920x1080 etc, raw means match input
resolution: 1920x1080
36 changes: 26 additions & 10 deletions multiviewer/uhdmcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import socket
import serial
import logging
import time

logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S +0000')
Expand All @@ -21,6 +22,16 @@ def __init__(self, config):
self.connect = 'remote'
self.logger.debug('Connection to MV with "{connect}" interface'.format(connect=self.connect))

self.inputs = {
'HDMI-1': 1,
'HDMI-2': 2,
'HDMI-3': 3,
'HDMI-4': 4
}

self.remote_timeout = self.config['mv'].get('remote_timeout', 2.0)
self.command_delay = self.config['mv'].get('command_delay', .1)

def __poweroff(self):
self.send_command('power 0!')

Expand Down Expand Up @@ -56,15 +67,16 @@ def __layout(self, **kwargs):
grid = kwargs.get('grid')

if grid:
window = 1
for viewport in grid:
for hdmi in grid:
if len(grid) == 1:
self.send_command(f's window {grid[viewport]}!')
if grid[hdmi] == 1:
self.send_command(f's in source {self.inputs[hdmi]}!')
else:
self.logger.debug(f'{hdmi} value not legal for scene type')
else:
self.send_command(f's window {grid[viewport]} in {window}!')
window += 1
self.send_command(f's window {grid[hdmi]} in {self.inputs[hdmi]}!')
else:
raise Exception(f'HDMI port number is not set')
raise Exception(f'Layout not found in config file')

def send_command(self, cmd):
console = ''
Expand All @@ -84,15 +96,19 @@ def send_command(self, cmd):

host = self.config['mv']['ip_addr']
port = 23
msg = "{command}\n".format(command=cmd)
msg = "{command}".format(command=cmd)

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(.3)
s.settimeout(self.remote_timeout)
s.connect((host, port))
self.logger.debug(f'About to send "{cmd}" to {host}:{port}')
self.logger.debug(f'About to send "{cmd}" to {host}:{port} with a timeout of {self.remote_timeout}s')
s.sendall(bytes(msg, encoding="ascii"))
console = s.recv(64).decode().rstrip('\r\n')
console = s.recv(32).decode().rstrip('\r\n')
self.logger.debug('Received from MV: "{msg}"'. format(msg=console))
s.shutdown(socket.SHUT_RDWR)
s.close()

time.sleep(self.command_delay)
return console

def apply(self, profile):
Expand Down

0 comments on commit 4883810

Please sign in to comment.