README.md 9.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
# About the RTMP IO plugin

The RTMP plugin provides a standard client implementation of the RTMP protocol.
It is used to provide RTMP input and output to videostitch softwares with a choice of 3 different encoders: libx264, QSV, NVENC.

The plugin implements a client with pull behavior when it is configured for input, and push behavior when configured for output.
In all cases, an RTMP server is needed.

It is tested with the following servers: NGINX, WOWZA, MIST, AKAMAI.

RTMP protocol specification:
https://www.adobe.com/content/dam/Adobe/en/devnet/rtmp/pdf/rtmp_specification_1.0.pdf

FLV/F4V format specification:
http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf

The plugin provides support for pushing RTMP to a compatible server (Nginx, Wowza, Akamai, ...).
RTMP pull (when the server request the connection) is not supported


# RTMP Input configuration

```
"reader_config": {
    "name": "rtmp://127.0.0.1:1935/inputs/0_0",
    "type": "rtmp",
	"frame_rate": {
	    "den": 1,
	    "num": 30
	},
	"audio_samplerate" : 48000,
    "audio_channels" : 2,
    "audio_sample_depth" : "s16"
}
```

###### name
type : *string*
default : **required**
notes : rtmp://SERVER_IP:PORT/APP/STREAMKEY
RTMP authentication is not supported (untested).

###### frame_rate
notes : **required.** *den* & *num* properties are used to specify input framerate such as **framerate = num / den**
VFR (variable framerate) is not supported (untested).

###### frame_rate.den
type : int
default : ?

###### frame_rate.num
type : int
default : ?

###### audio_samplerate :
type : int
default : - optional
notes : 44100 or 48000

###### audio_channels
type : *int*
default : - optional
Notes :  1 (mono) or 2 (stereo)

###### audio_sample_depth
type : *string*
default : - optional
notes : "flt", "s16" or "s32". Specifies the expected audio sample format/depth from the RTMP input. Note that it is converted to "s16" for internal processing if not already in that format.


# RTMP Output configuration


```
{
 	// RTMP protocol settings
 	"type": "rtmp",
	"filename": "rtmp://127.0.0.1:1935/live/output",
    "downsampling_factor": 1,
    "pub_user" : "yourusername",
    "pub_enc_passwd" : "2Njux57MZPgCc6H7S1RcTg==\n",

	// video encoder settings depend on the selected encoder
	"video_codec" : "x264",
	...

	// audio encoder settings
	"audio_codec": "aac",
    ...

}
```


## RTMP output settings

##### filename
type : *string*
default : **required**
notes : (to be confirmed) the URL pattern for publishing rtmp://SERVER_IP:PORT/APP/STREAMKEY?username=%USER%:password=%PASSWORD%

###### pub_user
type : *string*
default : *optional*
notes : username for connecting to a secured RTMP server. Generated by VahanaVR when configuring RTMP with user/password.

###### pub_enc_passwd
type : *string*
default : *optional*
notes : encripted password to connect to a secured RTMP server. Generated & encripted by VahanaVR when configuring RTMP with user/password.

##### downsampling_factor
type : *int*
default : *1*
notes : downsamples the stitcher output by the given factor. eg.: pano size of 3840x1920 with downsampling_factor of 2 will encode a 1920x960 video.

###### bitrate_min
type : *int*
default : *-1*
notes : If output bitrate is higher than available network bandwidth and dynamic bitrate control supported by the video encoder the bitrate will be
automatically adjusted down to bitrate_min to avoid dropping packets (when output queue is full)



## AUDIO Encoding

Note that the f4v format specification which we use as reference for supported values: http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf

In our implementation (using lame) please note that mp3 only supports 44100 Hz sampling rate: [lameEncode](src/lameEncoder.cpp#L38)

**AAC codec**
sampling rate : 48000 Hz
sample format : s16 | s32 | flt
channel layout : mono | stereo

**MP3 codec**
sampling rate : 44100 Hz
sample format : s16 | s32 | flt
channel layout : mono | stereo

###### Sample configuration
```
{
    "type": "rtmp"
...
    "audio_bitrate": 128,
    "audio_codec": "aac",
    "channel_layout": "stereo",
    "sample_format": "s16",
    "sampling_rate": 44100
...
}
```

###### audio_codec
type : string
default : ?
notes : "aac" or "mp3"

###### audio_bitrate
type : int
default : ?
notes :

###### channel_layout
type : string
default : ?
notes : "stereo" or "mono"

###### sampling_rate
type : int
default : ?
notes : 41000 / 48000

###### sample_format
type : string
default : ?
notes : "fltp", "s16" or "s32". According to the f4v format specifications, the



## VIDEO Encoding

The only supported video encoding is H264. A choice of 3 encoders is provided :


### libx264 encoder

This is the encoder for RTMP output used by VahanaVR by default.
It runs on CPU on all plateform and does not involve specific HW dependencies.

###### Sample configuration
```
{
	"type" : "rtmp",
	"video_codec" : "x264",
	"tune" : "",
	"profile" : "baseline",
	"level" : "4.2",
	"filename" : "rtmp://localhost:1935/live/stream",
	"bitrate_mode" : "VBR",
	"quality_balance" : 5,
	"b_frames" : 2,
	"bitrate" : 8001,
	"cbr_padding" : false,
	"target_usage" : 4,
	"gop" : -1,
}
```

###### bitrate
type : *int*
default : *2000*
notes : target bitrate, in *??*

###### bitrate_mode
type : **
default : **
notes :

###### buffer_size
type : **
default : **
notes :

###### cbr_padding
type : **
default : **
notes :

###### preset
type : **
default : **
notes :

###### tune
type : **
default : **
notes :

###### profile
type : **
default : **
notes :

###### level
type : **
default : **
notes :

###### quality_balance
type : **
default : **
notes :

###### gop
type : **
default : **
notes :

###### b_frames
type : **
default : **
notes :


### Intel Quicksync encoder

The QSV encoder works on Intel processors, provided that the Intel Quicksync video engine is available.
It leverages Intel GPU to provide HW accelerated H264 video encoding.

###### Sample configuration
```
{
    "type": "rtmp"
...
    "video_codec": "qsv",
    "bitrate": 4000,
    "target_usage": 5,
    "num_slice": 0,
    "gop": 30,
    "level": "5.1",
    "profile": "baseline",
    "bitrate_mode": "CBR",
...
}
```

###### bitrate
type : *int*
default : *4000*
notes : target bitrate, in *kbps*

###### bitrate_mode
type : *string*
default : *CBR*
notes : bit rate control mode (for compatibility with libx264) cqp, cbr, vbr (upper or lower case).

###### target_usage
type : *int*
default : 4
notes : trade-off between quality and speed, from 1 (quality) to 7 (fastest)

###### num_slice
type : *int*
default : *0*
notes : Number of slices in each video frame. If num_slice=0 , the encoder may choose any slice partitioning allowed by the codec standard.

###### profile
type : *string*
default : *baseline*
notes : H264 profile, baseline | main | extended | high | constrained_baseline | constrained_high | progressive_high
Specified values will be ignored if the resolution & fps do not fit in the requested profile.

###### level
type : *int*
default : *3.1*
notes : Any of the H264 standard levels.
Specified values will be ignored if the resolution & fps do not fit in the requested level.

###### gop
type : *int*
default : *250*
notes : The target GOP size. Unknown range (0~250 ?).
It is unknown wether scenecut detection can overide this or wether automatic GOP size is possible (eeg. w/ gop=0 as in libx264 encoder). All I-Frames are IDR-Frames.

###### memtype
type : *string*
default : *d3d11*
notes : This parameter is hardcoded. Any value here will be ignored.


### NVENC encoder

The NVENC encoder works on Nvidia GPU processors, provided that the Nvidia video engine is available.
It leverages Nvidia GPU to provide HW accelerated H264 video encoding.

###### Sample configuration
```
{
    "type": "rtmp"
...
    "video_codec": "h264_nvenc",
    "bitrate": 4000,
    "preset" : "slow",
    "profile": "baseline",
    "bitrate_mode": "CBR",
    "gop": 30,
    "vbvMaxBitrate" : 4000,
    "buffer_size" : 600,
...
}
```

###### bitrate
type : *int*
default : *5000*
notes : target bitrate, in *kbps*

###### preset
type : *string*
default : *default*
notes : trade-off between quality and speed : slow/hq, fast/hp, bd, ll, llhp, llhq, lossless, losslesshp, medium/default.

###### profile
type : *string*
default : *baseline*
notes : H264 profile, baseline | main | high | constrained_high | high444 | stereo
Specified values will be ignored if the resolution & fps do not fit in the requested profile.

###### bitrate_mode
type : *string*
default : *cqp*
notes : bit rate control mode (for compatibility with libx264) cqp, cbr, vbr, vbr_minqp (upper or lower case).
It is overriden by rcmode if used

###### rcmode
type : *int*
default : *0*
notes : bit rate control mode 0(CQP), 1(VBR), 2(CBR), 4(VBR_MINQP), 8(2_PASS_QUALITY), 16(2_PASS_FRAMESIZE), 32(2_PASS_VBR)

###### gop
type : *int*
default : *250*
notes : The target GOP size. Unknown range (0~250 ?).
It is unknown wether scenecut detection can overide this or wether automatic GOP size is possible (eeg. w/ gop=0 as in libx264 encoder). All I-Frames are IDR-Frames.

###### vbvMaxBitrate
type : *int*
default : *0*
notes : Video Buffering Verifier maximum bitrate, in *kbps*

###### buffer_size
type : *int*
default : *0*
notes : Video Buffering Verifier maximum buffer size, in *kb*

###### qp
type : *int*
default : *28*
notes : quantization parameter, QP, that ranges from 0 to 51

###### b_frames
type : *int*
default : *0*
notes : number of B frames between two P frames

###### video_codec
type : *string*
default : *0*
notes : video codec "h264_nvenc", "hevc_nvenc"