ffplayout/ffplayout.py

68 lines
2.0 KiB
Python
Raw Normal View History

2018-08-27 10:57:14 +02:00
#!/usr/bin/env python3
2018-01-07 13:58:45 +01:00
# This file is part of ffplayout.
#
# ffplayout is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ffplayout is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ffplayout. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------
"""
This module is the starting program for running ffplayout engine.
"""
from importlib import import_module
from pathlib import Path
from platform import system
2020-02-03 17:33:08 +01:00
from ffplayout.utils import playout, stdin_args, validate_ffmpeg_libs
2018-01-07 13:58:45 +01:00
try:
if system() == 'Windows':
2019-11-01 15:54:24 +01:00
import colorama
colorama.init()
except ImportError:
2020-02-03 20:40:13 +01:00
print('colorama import failed, no colored console output on windows...')
# ------------------------------------------------------------------------------
# main functions
# ------------------------------------------------------------------------------
2018-01-07 13:58:45 +01:00
def main():
2019-09-09 16:13:18 +02:00
"""
2020-07-18 23:34:55 +02:00
play out depending on output mode
2019-09-09 16:13:18 +02:00
"""
2020-08-31 15:58:15 +02:00
if stdin_args.mode:
output = import_module(f'ffplayout.output.{stdin_args.mode}').output
2020-07-18 23:34:55 +02:00
output()
else:
script_dir = Path(__file__).parent.absolute()
output_dir = script_dir.joinpath('ffplayout', 'output')
2020-07-31 14:03:28 +02:00
for output in output_dir.glob('*.py'):
if output != '__init__.py':
mode = Path(output).stem
2020-07-18 23:34:55 +02:00
if mode == playout.mode:
output = import_module(f'ffplayout.output.{mode}').output
2020-07-18 23:34:55 +02:00
output()
2018-01-07 13:58:45 +01:00
if __name__ == '__main__':
2020-04-24 19:33:04 +02:00
# check if ffmpeg contains all codecs and filters
validate_ffmpeg_libs()
2018-01-07 13:58:45 +01:00
main()