|
| 1 | +# FFmpeg command handling classes |
| 2 | + |
| 3 | +This document describes the contents of the `ffmpeg_handler` folder. |
| 4 | + |
| 5 | +For instructions on how to run check [Running Guide](RunningGuide.md). |
| 6 | + |
| 7 | + |
| 8 | +## FFmpegIO class and subclasses |
| 9 | + |
| 10 | +```mermaid |
| 11 | +classDiagram |
| 12 | + FFmpegIO <|-- FFmpegVideoIO |
| 13 | + FFmpegIO <|-- FFmpegAudioIO |
| 14 | +
|
| 15 | + FFmpegIO <|-- FFmpegMcmMemifAudioIO |
| 16 | + FFmpegIO <|-- FFmpegMcmMemifVideoIO |
| 17 | +
|
| 18 | + FFmpegIO <|-- FFmpegMcmST2110CommonIO |
| 19 | + FFmpegMcmST2110CommonIO <|-- FFmpegMcmST2110AudioIO |
| 20 | + FFmpegMcmST2110AudioIO <|-- FFmpegMcmST2110AudioRx |
| 21 | + FFmpegMcmST2110AudioIO <|-- FFmpegMcmST2110AudioTx |
| 22 | + FFmpegMcmST2110CommonIO <|-- FFmpegMcmST2110VideoIO |
| 23 | + FFmpegMcmST2110VideoIO <|-- FFmpegMcmST2110VideoRx |
| 24 | + FFmpegMcmST2110VideoIO <|-- FFmpegMcmST2110VideoTx |
| 25 | +
|
| 26 | + FFmpegIO <|-- FFmpegMtlCommonIO |
| 27 | + FFmpegMtlCommonIO <|-- FFmpegMtlCommonRx |
| 28 | + FFmpegMtlCommonIO <|-- FFmpegMtlCommonTx |
| 29 | + FFmpegMtlCommonRx <|-- FFmpegMtlSt20pRx |
| 30 | + FFmpegMtlCommonTx <|-- FFmpegMtlSt20pTx |
| 31 | + FFmpegMtlCommonRx <|-- FFmpegMtlSt22pRx |
| 32 | + FFmpegMtlCommonTx <|-- FFmpegMtlSt22pTx |
| 33 | + FFmpegMtlCommonRx <|-- FFmpegMtlSt30pRx |
| 34 | + FFmpegMtlCommonTx <|-- FFmpegMtlSt30pTx |
| 35 | +
|
| 36 | + class FFmpegIO { |
| 37 | + read_at_native_rate : bool |
| 38 | + stream_loop : int |
| 39 | + input_path : str |
| 40 | + output_path : str |
| 41 | + get_command() : str |
| 42 | + } |
| 43 | +
|
| 44 | + class FFmpegVideoIO { |
| 45 | + video_size : str |
| 46 | + f : str |
| 47 | + pix_fmt : str |
| 48 | + } |
| 49 | +
|
| 50 | + class FFmpegAudioIO { |
| 51 | + ar : int |
| 52 | + f : str |
| 53 | + ac : int |
| 54 | + } |
| 55 | +
|
| 56 | + class FFmpegMcmMemifAudioIO { |
| 57 | + channels : int |
| 58 | + sample_rate : int |
| 59 | + f : str |
| 60 | + } |
| 61 | +
|
| 62 | + class FFmpegMcmMemifVideoIO { |
| 63 | + f : str |
| 64 | + conn_type : str |
| 65 | + frame_rate : str |
| 66 | + video_size : str |
| 67 | + pixel_format : str |
| 68 | + } |
| 69 | +
|
| 70 | + class FFmpegMcmST2110CommonIO { |
| 71 | + buf_queue_cap : int |
| 72 | + conn_delay : int |
| 73 | + conn_type : str |
| 74 | + urn : str |
| 75 | + port : int |
| 76 | + socket_name : str |
| 77 | + interface_id : int |
| 78 | + } |
| 79 | +
|
| 80 | + class FFmpegMcmST2110AudioIO { |
| 81 | + buf_queue_cap : int |
| 82 | + payload_type : int |
| 83 | + channels : int |
| 84 | + sample_rate : int |
| 85 | + ptime : str |
| 86 | + f : str |
| 87 | + } |
| 88 | +
|
| 89 | + class FFmpegMcmST2110AudioRx { |
| 90 | + ip_addr : str |
| 91 | + mcast_sip_addr : str |
| 92 | + } |
| 93 | +
|
| 94 | + class FFmpegMcmST2110AudioTx { |
| 95 | + ip_addr : str |
| 96 | + } |
| 97 | +
|
| 98 | + class FFmpegMcmST2110VideoIO { |
| 99 | + transport : str |
| 100 | + buf_queue_cap : int |
| 101 | + payload_type : int |
| 102 | + transport_pixel_format : str |
| 103 | + video_size : str |
| 104 | + pixel_format : str |
| 105 | + frame_rate : str |
| 106 | + f : str |
| 107 | + } |
| 108 | +
|
| 109 | + class FFmpegMcmST2110VideoRx { |
| 110 | + ip_addr : str |
| 111 | + mcast_sip_addr : str |
| 112 | + } |
| 113 | +
|
| 114 | + class FFmpegMcmST2110VideoTx { |
| 115 | + ip_addr : str |
| 116 | + } |
| 117 | +
|
| 118 | + class FFmpegMtlCommonIO { |
| 119 | + p_port : str |
| 120 | + p_sip : str |
| 121 | + dma_dev : str |
| 122 | + rx_queues : int |
| 123 | + tx_queues : int |
| 124 | + udp_port : int |
| 125 | + payload_type : int |
| 126 | + } |
| 127 | +
|
| 128 | + class FFmpegMtlCommonRx { |
| 129 | + p_rx_ip : str |
| 130 | + } |
| 131 | +
|
| 132 | + class FFmpegMtlCommonTx { |
| 133 | + p_tx_ip : str |
| 134 | + } |
| 135 | +
|
| 136 | + class FFmpegMtlSt20pRx { |
| 137 | + video_size : str |
| 138 | + pixel_format : str |
| 139 | + fps : float |
| 140 | + timeout_s : int |
| 141 | + init_retry : int |
| 142 | + fb_cnt : int |
| 143 | + gpu_direct : bool |
| 144 | + gpu_driver : int |
| 145 | + gpu_device : int |
| 146 | + f : str |
| 147 | + } |
| 148 | +
|
| 149 | + class FFmpegMtlSt22pRx { |
| 150 | + video_size : str |
| 151 | + pixel_format : str |
| 152 | + fps : float |
| 153 | + timeout_s : int |
| 154 | + init_retry : int |
| 155 | + fb_cnt : int |
| 156 | + codec_thread_cnt : int |
| 157 | + st22_codec : str |
| 158 | + f : str |
| 159 | + } |
| 160 | +
|
| 161 | + class FFmpegMtlSt30pRx { |
| 162 | + fb_cnt : int |
| 163 | + timeout_s : int |
| 164 | + init_retry : int |
| 165 | + sample_rate : int |
| 166 | + channels : int |
| 167 | + pcm_fmt : str |
| 168 | + ptime : str |
| 169 | + f : str |
| 170 | + } |
| 171 | +
|
| 172 | + class FFmpegMtlSt20pTx { |
| 173 | + fb_cnt : int |
| 174 | + f : str |
| 175 | + } |
| 176 | +
|
| 177 | + class FFmpegMtlSt22pTx { |
| 178 | + fb_cnt : int |
| 179 | + bpp : float |
| 180 | + codec_thread_cnt : int |
| 181 | + st22_codec : str |
| 182 | + f : str |
| 183 | + } |
| 184 | +
|
| 185 | + class FFmpegMtlSt30pTx { |
| 186 | + fb_cnt : int |
| 187 | + ptime : str |
| 188 | + f : str |
| 189 | + } |
| 190 | +``` |
| 191 | + |
| 192 | +## FFmpeg class |
| 193 | + |
| 194 | +```mermaid |
| 195 | +classDiagram |
| 196 | + class FFmpeg{ |
| 197 | + prefix_variables : dict |
| 198 | + ffmpeg_path : str = "ffmpeg" |
| 199 | + ffmpeg_input : FFmpegIO = None |
| 200 | + ffmpeg_output : FFmpegIO = None |
| 201 | + yes_overwrite : bool = False |
| 202 | + get_items() : dict |
| 203 | + get_command() : str |
| 204 | + } |
| 205 | +``` |
| 206 | + |
| 207 | +## FFmpegExecutor class |
| 208 | + |
| 209 | +```mermaid |
| 210 | +classDiagram |
| 211 | + class FFmpegExecutor{ |
| 212 | + host = host |
| 213 | + ff : FFmpeg = ffmpeg_instance |
| 214 | + _processes = [] |
| 215 | + start() |
| 216 | + stop(wait = 0.0) |
| 217 | + } |
| 218 | +``` |
| 219 | + |
| 220 | +## Audio format value matrix |
| 221 | + |
| 222 | +> **Note:** Value of "none" in Tx `-pcm_fmt` column, means given switch should not be used for outbound transmissions. |
| 223 | +
|
| 224 | +<table> |
| 225 | +<tr> |
| 226 | + <th rowspan=3>PCM format</th> |
| 227 | + <th rowspan=2>FFmpeg <code>-f</code></th> |
| 228 | + <th rowspan=2>Media Communications Mesh <code>-f</code></th> |
| 229 | + <th colspan=4>Media Transport Library</th> |
| 230 | +</tr> |
| 231 | +<tr> |
| 232 | + <th>Tx <code>-pcm_fmt</code></th> |
| 233 | + <th>Rx <code>-pcm_fmt</code></th> |
| 234 | + <th>Tx <code>-f</code></th> |
| 235 | + <th>Rx <code>-f</code></th> |
| 236 | +</tr> |
| 237 | +<tr> |
| 238 | + <th>FFmpegAudioIO</th> |
| 239 | + <th>FFmpegMcmMemifAudioIO<br />FFmpegMcmMultipointGroupAudioIO<br />FFmpegMcmST2110AudioIO</th> |
| 240 | + <th>FFmpegMtlSt30pTx</th> |
| 241 | + <th>FFmpegMtlSt30pRx</th> |
| 242 | + <th>FFmpegMtlSt30pTx</th> |
| 243 | + <th>FFmpegMtlCommonRx</th> |
| 244 | +</tr> |
| 245 | +<tr> |
| 246 | + <td>PCM16</td> |
| 247 | + <td><code>s16be</code><br />FFmpegAudioFormat.pcm16.value</td> |
| 248 | + <td><code>mcm_audio_pcm16</code><br />McmFAudioFormat.pcm16.value</td> |
| 249 | + <td rowspan=2>none</td> |
| 250 | + <td><code>pcm16</code><br />MtlPcmFmt.pcm16.value</td> |
| 251 | + <td><code>mtl_st30p_pcm16</code><br />MtlFAudioFormat.pcm16.value</td> |
| 252 | + <td rowspan=2><code>mtl_st30p</code><br />"mtl_st30p"</td> |
| 253 | +</tr> |
| 254 | +<tr> |
| 255 | + <td>PCM24</td> |
| 256 | + <td><code>s24be</code><br />FFmpegAudioFormat.pcm24.value</td> |
| 257 | + <td><code>mcm_audio_pcm24</code><br />McmFAudioFormat.pcm24.value</td> |
| 258 | + <!-- colspaned: <td>none</td> --> |
| 259 | + <td><code>pcm24</code><br />MtlPcmFmt.pcm24.value</td> |
| 260 | + <td><code>mtl_st30p</code><br />MtlFAudioFormat.pcm24.value</td> |
| 261 | + <!-- colspaned: <td><code>mtl_st30p</code><br />"mtl_st30p"</td> --> |
| 262 | +</tr> |
| 263 | +</table> |
| 264 | + |
| 265 | + |
| 266 | +## Executing assertion tests |
| 267 | + |
| 268 | +In order to run the assertion tests from the `ffmpeg_handler` folder, treat them as a module. Starting from Engine folder, |
| 269 | +use `python -m ffmpeg_handler.<module_name>`, e.g. `python -m ffmpeg_handler.test_ffmpeg` to run tests from `./ffmpeg_handler/test_ffmpeg.py`. |
0 commit comments