22# Copyright 2025 Intel Corporation
33# Media Communications Mesh
44
5- # TODO: consider how we can use https://github.com/kkroening/ffmpeg-python
6- # TODO: maybe we can write ffmpeg wrapper like scapy? e.g. every protocol is different class and it looks like this:
7- # Ether()/IP()/TCP() so maybe: ffmpeg_cmd = Input()/Transport()/Output() etc.
5+ # MTL extra_options usage:
6+ # >>> import ffmpeg # (typed-ffmpeg library)
7+ # fi = ffmpeg.input(filename="-", extra_options={"ptime": "1ms"}) # extra_options to be used as a mean of adding the parameters
8+ # fo = (fi.output(filename="xyz"))
9+ # fo.compile()
10+ # ['ffmpeg', '-ptime', '1ms', '-i', '-', 'xyz']
11+
12+ # >>> import ffmpeg
13+ # >>> import mtl_st20p_rx
14+ # >>> st20p_rx = mtl_st20p_rx.MtlSt20pRx(video_size="3840x2160", timeout_s=4)
15+ # >>> st20p_rx.get_items()
16+ # {'video_size': '3840x2160', 'fps': 59.94, 'timeout_s': 4, 'init_retry': 5, 'fb_cnt': 3, 'gpu_direct': False, 'gpu_driver': 0, 'gpu_device': 0, 'rx_queues': -1, 'tx_queues': -1, 'udp_port': 20000, 'payload_type': 112}
17+
18+ # >>> fi = ffmpeg.input(filename="xyz", extra_options=st20p_rx.get_items())
19+ # >>> fo = fi.output(filename="abc")
20+ # >>> fo.compile()
21+ # ['ffmpeg', '-video_size', '3840x2160', '-fps', '59.94', '-timeout_s', '4', '-init_retry', '5', '-fb_cnt', '3', '-nogpu_direct', '-gpu_driver', '0', '-gpu_device', '0', '-rx_queues', '-1', '-tx_queues', '-1', '-udp_port', '20000', '-payload_type', '112', '-i', 'xyz', 'abc']
22+ # >>> ' '.join(fo.compile())
23+ # 'ffmpeg -video_size 3840x2160 -fps 59.94 -timeout_s 4 -init_retry 5 -fb_cnt 3 -nogpu_direct -gpu_driver 0 -gpu_device 0 -rx_queues -1 -tx_queues -1 -udp_port 20000 -payload_type 112 -i xyz abc'
24+
25+ # TODO: Continue adding above to below functions
826
927class FFmpeg :
1028 """
11- FFMPEG wrapper with MCM plugin
29+ FFmpeg wrapper with MCM plugin
1230 """
1331 def __init__ (self , connection ):
1432 self .conn = connection
@@ -19,4 +37,5 @@ def start_ffmpeg(self, cmd):
1937 self ._processes .append (ffmpeg )
2038
2139 def prepare_st20_tx_cmd (self ):
40+ # from extra_options import mcm_st20p_tx
2241 pass
0 commit comments