Coder Social home page Coder Social logo

conti's Introduction

Conti

FFMpeg based playout server

About the project

Conti is a simple linear video playout server. It enables you to broadcast your video files with minimal configuration and hardware requirements.

Conti demo script can be modified to run simple stand-alone channels such as lobby TVs, info channels, community TV stations, and so on.

For more complex projects, Nebula broadcast automation system can be used for scheduling and playout control.

Features

Conti has a very simple architecture allowing extensive tweaking. Most of the features come from FFMpeg, notably:

  • Vast source format support
  • Multiple simultaneous outputs including RTP, RTMP, MPEG-TS, NDI and SDI
  • Video and audio filtering on a source, global, or output level. This includes on-the-fly loudness normalization, station logo burn-in, ARC and so on.
  • Up to 16 channel audio support with channels shuffling.
  • Hardware-accelerated encoding (nvenc) of selected formats (h.264, HEVC)

Limitations

  • Most of the output formats does not support pausing. It is possible to pause Decklink or SDL outputs by calling Conti.freeze(self) method, but IP streams have to run all the time.
  • It is not possible to control displayed graphics overlays during playback.
  • There is probably no easy way to create a continuous text crawl. Prove us wrong.
  • Looping is not implemented yet (but is planned)
  • source and output filters usage differs slightly. We want to unify the behavior.

Quick start

Conti runs on Linux (no other OS has been tested) and requires Python3, FFMpeg and nxtools.

FFMpeg

For the most use-cases, FFMpeg build available in your favorite Linux distribution is sufficient.

In case you need Blackmagic Decklink or NDI I/O, you may use our build script from this repository.

nxtools

nxtools is a set of Python utilities we use for many tasks. Install it using pip3 install nxtools

Running Conti

Clone this repository and tweak conti.py script to point to your data location (directory with your video files)

By default, Conti streams in RTP over multicast to rtp://224.0.0.1:2000, but you can change the destination as well as the encoding profile(s).

Start ./conti.py and tune your station: Start VLC on any machine in your network, hit ctrl+n and enter rtp://@224.0.0.1:2000.

Architecture

Conti uses several FFMpeg processes tied together using pipes to produce a gapless stream. Each source (ContiSource Python class) spawns an FFMpeg process with a filter-chain which handles format and tracks layout normalization and pipes its uncompressed output to the encoder process. Conti opens several source processes in advance, so right after one clip is finished, the next one can be started without delays.

The encoder process applies global output filter-chain to the piped input (e.g. audio normalization), splits the output if there is more than one output specified, applies per-output filter-chains and transcode or output the result to the desired streams/devices.

Examples

Feel free to tweak the sample script to meet your needs. You can modify the get_next method to play different media files in different parts of the day or to follow a playlist stored in a database.

Following settings.json file instruct the conti.py demo script to playback media files from the chosen directory, the top-level video_filters parameter is applied to all outputs (in this case, black&white conversion). Two SDL outputs (desktop windows) are defined, but the audio output is not used. The second output has its feed horizontally flipped.

{
    "media_dir" : "/export/media.dir",
    "video_filters" : "hue=s=0",
    "outputs" : [ 
    {
        "target" : "SDL Output 1",
        "audio" : false,
        "params" : {
            "c:v" : "rawvideo",
            "f" : "sdl",
            "pix_fmt" : "yuv420p"
        }
    },
    {
        "target" : "SDL Output 2",
        "audio" : false,
        "video_filters": "hflip",
        "params" : {
            "c:v" : "rawvideo",
            "f" : "sdl",
            "pix_fmt" : "yuv420p"
        }
    }

]
}

Note: SDL is not available in the immstudios ffmpeg build (yet)

Pipe format

The example assumes 1080p25 is used as an "intermediate" format (the format which goes thru the pipe), but at the top level of the settings.json you may override the following default values.

{
        "width"           : 1920,
        "height"          : 1080,
        "frame_rate"      : 25,
        "pixel_format"    : "yuv422p",
        "audio_only"      : false,
        "audio_codec"     : "pcm_s16le",
        "audio_sample_rate" : 48000,
}

Decklink

Decklink cards are very picky regarding the used format, especially the interlaced flag. In order to output 1080i50, use the default values of the pipe format and use the following values for your output.

{
    "target" : "DeckLink SDI",
    "video_filters" : "setfields=tff",
    "params" : {
        "field_order" : "tt",
        "f" : "decklink",
        "pix_fmt" : "uyvy422"
    }
}

Audio

All sources are converted to 16channels audio, so in order to get a stereo output (for example for an IP stream), use {"audio_filters" : "pan=stereo|c0=c0|c1=c1} or similar to get the desired channel pair.

conti's People

Contributors

martastain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

conti's Issues

General Playout Question

I have two general questions, pardon my ignorance.

  1. What is the purpose of a playout server compared to using something like this vlc scheduler? Other playout software are more feature rich such as CasparCG and well recommended but is that comparable to software like OBS-Studio or is it server a different purpose?

  2. Anyways I do want to run a pirate TV station and am also trying to setup your Nebula project but that uses CasparCG. Using CasparCG seems to be a unnecessary complexity to my simple needs and was wondering if Conti could be used with Nebula (for the scheduling and MAM).

Thank you.

no media files in ....

ERROR There are no media files in '/media.dir'
DEBUG Critical error. Terminating program.

Hi, i tried different folders and syntax but each times it failed. The media files have to be of a specific type ?
Does absolute path should be working ?
Thanks for any help !

UnicodeDecodeError - video/audio sync issue

When playing certain files I get an error which causes either a BrokenPipeError or the following:

DEBUG       Executing ffmpeg -hide_banner -i data/Jesus Christ Bruce...-oLMkUKAiVDY.mp4 -filter:a [in]apad[out] -s 12
80x720 -pix_fmt yuv420p -r 25 -ar 48000 -t 13.978411 -c:v rawvideo -c:a pcm_s16le -max_interleave_delta 400000 -f avi
 -
DEBUG       Appending <Conti source: Jesus Christ Bruce...-oLMkUKAiVDY> to playlist
ERROR       Exception!

    Traceback (most recent call last):
      File "/mnt/c/Projects/telsat/channel/conti/conti/__init__.py", line 115, in progress_thread
        ch = decode_if_py3(source.proc.stderr.read(1))
      File "/mnt/c/Projects/telsat/channel/conti/.venv/lib/python3.6/site-packages/nxtools/common.py", line 36, in <l
ambda>
        decode_if_py3 = lambda x, enc="utf-8": x.decode(enc)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

ERROR       Exception!

    Traceback (most recent call last):
      File "/mnt/c/Projects/telsat/channel/conti/conti/__init__.py", line 115, in progress_thread
        ch = decode_if_py3(source.proc.stderr.read(1))
      File "/mnt/c/Projects/telsat/channel/conti/.venv/lib/python3.6/site-packages/nxtools/common.py", line 36, in <l
ambda>
        decode_if_py3 = lambda x, enc="utf-8": x.decode(enc)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x99 in position 0: invalid start byte

INFO        Starting clip <Conti source: Jesus Christ Bruce...-oLMkUKAiVDY>

Play continues but these files can cause video/audio sync problems which can be very small or adds up over an hour or two to be noticeable.

All files were downloaded with youtube-dl and I was just playing them in a loop to see if this type of error would occur; only a few of the files seem to cause the error.

How to use nvenc HW acceleration

Dears,

from the given files it's not clear how to enable nvenc HW acceleration. I've tried it with by adding

  • "c:v" : "h264_nvenc"_ to the params section in settings.json, but CPU is still used
  • found gpu_id parameter in common.py, but i haven't found any reference to it where it would be actually used.
    Thank you in advance for your comments

BrokenPipeError Line 48 in encoder.py

INFO        Starting clip <Conti source: wiki>
DEBUG       Executing ffmpeg -hide_banner -i /home/michael/Videos/wiki.mov -filter:a [in]apad[out] -filter:v [in]drawtext=text=wiki:fontsize=48:fontcolor=white:x=(w/2) - (tw/2):y=2*lh:box=1:boxborderw=8:boxcolor=black[out] -s 1920x1080 -pix_fmt yuv420p -r 25 -ar 48000 -t 21.502 -c:v rawvideo -c:a pcm_s16le -max_interleave_delta 400000 -f avi -
DEBUG       Appending <Conti source: wiki> to playlist
Traceback (most recent call last):
  File "conti.py", line 90, in <module>
    conti.start()
  File "/home/michael/Projects/conti/conti/__init__.py", line 64, in start
    self.main_thread()
  File "/home/michael/Projects/conti/conti/__init__.py", line 94, in main_thread
    self.encoder.write(data)
  File "/home/michael/Projects/conti/conti/encoder.py", line 48, in write
    self.proc.stdin.write(data)
BrokenPipeError: [Errno 32] Broken pipe

Running the ffmpeg command on its own results with

bash: syntax error near unexpected token `('

Removing the entire filter section works seems to work. Am I missing something in settings that results in a bad filter? Or something else?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.