ffplayout/ffplayout.py

68 lines
2.0 KiB
Python
Raw Normal View History

2018-08-27 04:57:14 -04:00
#!/usr/bin/env python3
2018-01-07 07:58:45 -05: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 11:33:08 -05:00
from ffplayout.utils import playout, stdin_args, validate_ffmpeg_libs
2018-01-07 07:58:45 -05:00
try:
if system() == 'Windows':
2019-11-01 10:54:24 -04:00
import colorama
colorama.init()
except ImportError:
2020-02-03 14:40:13 -05:00
print('colorama import failed, no colored console output on windows...')
# ------------------------------------------------------------------------------
# main functions
# ------------------------------------------------------------------------------
2018-01-07 07:58:45 -05:00
def main():
2019-09-09 10:13:18 -04:00
"""
2020-07-18 17:34:55 -04:00
play out depending on output mode
2019-09-09 10:13:18 -04:00
"""
2020-08-31 09:58:15 -04:00
if stdin_args.mode:
output = import_module(f'ffplayout.output.{stdin_args.mode}').output
2020-07-18 17:34:55 -04:00
output()
else:
script_dir = Path(__file__).parent.absolute()
output_dir = script_dir.joinpath('ffplayout', 'output')
2020-07-31 08:03:28 -04:00
for output in output_dir.glob('*.py'):
if output != '__init__.py':
mode = Path(output).stem
2020-07-18 17:34:55 -04:00
if mode == playout.mode:
output = import_module(f'ffplayout.output.{mode}').output
2020-07-18 17:34:55 -04:00
output()
2018-01-07 07:58:45 -05:00
if __name__ == '__main__':
2020-04-24 13:33:04 -04:00
# check if ffmpeg contains all codecs and filters
validate_ffmpeg_libs()
2018-01-07 07:58:45 -05:00
main()