Publishing to a static stream
Here we will talk about how to set up video publishing and how these settings were different in previous versions of Flussonic Media Server.
URLs for accessing a published stream via various protocols are listed in Publishing.
Starting from version 19.01, Flussonic Media Server uses a new parameter to set up video publishing to a static stream. The new parameter input publish://
automatically replaces the old publish_enabled
when you save the Flussonic's configuration file.
Danger
We recommend that you make a backup copy of Flussonic configuration file before making any changes to it in version 19.01. The updated configuration file will become incompatible with previous versions of Flussonic.
How to set up publication in version 19.01 and higher:
stream published {
input publish://;
}
The new parameter 'input publish://' offers more opportunities to manage streams with published sources. It allows you to:
- switch stream sources and use timeout
- prohibit publication by activating another source of a stream
- transcode a published stream
- publish video via WebRTC
- publish video via RTMP
Switching stream sources, using timeout
In previous versions, you could only turn the publishing source on and off by changing the settings.
Now the rules of switching sources according to their priority and state (whether a source is available or not) apply to published sources too. This means that now you can add alternative sources to a stream with a published source and use timeout for switching between sources.
If a published source is unavailable, Flussonic immediately switches by default to the next source. Alternatively, you can specify your custom timeout.
Example with multiple sources and a timeout:
stream published {
source_timeout 3;
input publish://;
input file://vod/bunny.mp4;
}
You can also specify timeout for each source individually:
stream published {
input publish:// source_timeout=3;
input file://vod/bunny.mp4 source_timeout=2;
}
Prohibiting the publication, the event publish_forbidden
When the source input publish://
has a lower priority than the other specified stream sources, it might mean that the publication will not actually happen. You can prevent the publication and allow it again by changing the priority of sources. This can be done during the broadcast.
If publishing is not possible, Flussonic generates the event publish_forbidden
. For example, this event occurs with the following configuration if the file bunny.mp4
exists and is successfully played:
stream published {
source_timeout 3;
input file://vod/bunny.mp4;
input publish://;
}
To allow publication, put the source of publication before the file.
Transcoding of a published source
Specify the transcoder
parameter in the stream settings to transcode a source stream. Flussonic supports such configuration for RTMP streams. For WebRTC, the transcoder
parameter will be added in future versions, but now you can use WebRTC-specific options (read later on this page).
stream published {
source_timeout 3;
input publish://;
input file://vod/bunny.mp4;
transcoder vb=1024k vcodec=h264 open_gop=false preset=veryfast ab=64k;
}
Options for WebRTC streams publishing
For WebRTC sources, you can use WebRTC-specific transcoding options with input publish://`.
Syntax of transcoding options for WebRTC streams:
input publish:// [output_audio=(keep|add_aac|aac)] [prefer_codec=(h264|vp8|vp9)]
-
output_audio=(keep|add_aac|aac)
. Specifies audio transcoding options. You can get the resulting audio for playback in AAC (aac
), AAC+Opus (add_aac
), or Opus (keep
). So, to have audio without changes, you should usekeep
.By default,
add_aac
is used – this means that an input stream, which usually has audio in Opus, will also have a track in AAC on the output. -
prefer_codec=(h264|vp8|vp9)
. Offers to choose one of the listed video codecs at the start of the publication. The default codec is H264. Video encoded in VP8 and VP9 is now transferred without transcoding, its support will be added in the future.
Example:
stream published {
input publish:// output_audio=aac;
}
Audio options for RTMP streams publishing
If published RTMP streams contain audio in PCMU, then you can transcode it to AAC, or specify that the audio tracks must not be transcoded:
-
output_audio=(keep|add_aac|aac)
. Specifies audio transcoding options. You can get the resulting audio for playback in AAC (aac
), AAC+Opus (add_aac
), or Opus (keep
). So, to have audio without changes, you should usekeep
.By default,
add_aac
is used – this means that an input stream, which usually has audio in Opus, will also have a track in AAC on the output.
This option goes together with input publish://
.
Syntax of audio transcoding options:
input publish:// [output_audio=(keep|add_aac|aac)]
stream published {
input publish:// output_audio=keep;
}