Skip to content

Commit 55c0ae7

Browse files
committed
move experimental or non-essential features to tools.etools
1 parent a8ad672 commit 55c0ae7

14 files changed

+309
-335
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.NOTPARALLEL: ; # wait for target to finish
55
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
66

7-
VERSION = 1.0.1
7+
VERSION = 1.0.4
88
PACKAGE = ffmpeg-generator
99

1010
# While console windows in Windows 10 do support VT (Virtual Terminal) / ANSI

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ This project is based on [`ffmpeg-python`](https://github.com/kkroening/ffmpeg-p
4343
- support video sources
4444
- support almost all filters
4545
- support FFplay&FFprobe
46-
- enable cuda hwaccel by default
46+
- enable cuda hwaccel by default, or close globally by code below
4747

48-
## TODO
48+
```python
49+
from ffmpeg import settings
4950

50-
- [] separate outputs for select filter
51-
- [] experiment: automatically generate subtitle files
51+
settings.CUDA_ENABLE = False
52+
```
5253

5354
## Installation
5455

ffmpeg/__init__.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,43 @@
22
Date: 2021.02.25 14:34:07
33
Description: Omit
44
LastEditors: Rustle Karl
5-
LastEditTime: 2021.05.31 10:38:26
5+
LastEditTime: 2021.06.25 09:25:13
66
'''
77
import subprocess
88

99
from pkgs import color
1010

1111
from ._ffmpeg import input, input_source, merge_outputs, output
12-
from ._ffplay import (detect_device_available, ffplay_audio, ffplay_video,
13-
run_ffplay)
12+
from ._ffplay import ffplay_audio, ffplay_video, run_ffplay
1413
from ._ffprobe import FFprobe, metadata, run_ffprobe
15-
from ._progress import show_progress
1614
from ._utils import convert_kwargs_to_cmd_line_args
17-
from ._view import view
1815
from .filters import afilters, avfilters, vfilters
1916
from .nodes import FFmpegError
20-
from .tools import atools, avtools, iotools, rtmp, vtools
17+
from .tools import atools, avtools, vtools
2118

2219
__all__ = [
2320
'FFmpeg',
2421
'FFmpegError',
2522
'FFprobe',
26-
'__version__',
2723
'afilters',
2824
'atools',
2925
'avfilters',
3026
'avtools',
3127
'constants',
32-
'detect_device_available',
3328
'ffplay_audio',
3429
'ffplay_video',
3530
'input',
3631
'input_source',
37-
'iotools',
3832
'merge_outputs',
3933
'metadata',
4034
'output',
41-
'rtmp',
4235
'run_ffmpeg',
4336
'run_ffplay',
4437
'run_ffprobe',
45-
'show_progress',
4638
'vfilters',
47-
'view',
4839
'vtools',
4940
]
5041

51-
__version__ = '1.0.2'
52-
5342

5443
def run_ffmpeg(option: str = None, stdout=None, check=True, **kwargs) -> subprocess.CompletedProcess:
5544
'''Run raw ffmpeg command.'''

ffmpeg/_ffplay.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
'''
22
Date: 2021.03.06 23:06:21
33
LastEditors: Rustle Karl
4-
LastEditTime: 2021.04.25 13:39:24
4+
LastEditTime: 2021.06.25 09:45:47
55
'''
66
import subprocess
77
from pathlib import Path
88

99
from pkgs import color
1010

11-
from ._utils import join_cmd_args_seq, convert_kwargs_to_cmd_line_args
11+
from ._utils import convert_kwargs_to_cmd_line_args, join_cmd_args_seq
1212

1313
__all__ = [
14-
"detect_device_available",
1514
"ffplay_audio",
1615
"ffplay_video",
1716
"run_ffplay",
1817
]
1918

2019

21-
def run_ffplay(source: str = None, direct_print=True, **kwargs):
20+
def run_ffplay(source: str = None, print_cmd=True, **kwargs):
2221
"""Run raw ffplay command."""
2322
args = ["ffplay", "-hide_banner"]
2423

@@ -34,7 +33,7 @@ def run_ffplay(source: str = None, direct_print=True, **kwargs):
3433
if source is not None:
3534
args.append(Path(source).as_posix())
3635

37-
if direct_print:
36+
if print_cmd:
3837
color.greenln(join_cmd_args_seq(args))
3938

4039
return subprocess.Popen(args)
@@ -68,12 +67,3 @@ def ffplay_video(source: str, x: int = None, y: int = None, video_size: str = No
6867
fs=fs, an=an, vn=vn, sn=sn, f=f, s=s, sync=sync, ss=ss, t=t, vf=vf,
6968
af=af, seek_interval=seek_interval, window_title=window_title,
7069
showmode=show_mode, loop=loop)
71-
72-
73-
def detect_device_available(source: str, f: str):
74-
"""
75-
Examples:
76-
ffplay -f dshow -i video='USB2.0 PC CAMERA
77-
ffplay -f vfwcap -i 0
78-
'"""
79-
run_ffplay(source, f=f).wait()

ffmpeg/_progress.py

-107
This file was deleted.

ffmpeg/_view.py

-86
This file was deleted.

ffmpeg/nodes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ def get_output_args(self, overwrite=True, progress='') -> List[str]:
102102

103103
return args
104104

105-
def compile(self, *, executable="ffmpeg", direct_print=True, join_args=False,
105+
def compile(self, *, executable="ffmpeg", print_cmd=True, join_args=False,
106106
overwrite=True, progress='') -> Union[str, List[str]]:
107107
'''Build command-line for invoking ffmpeg.'''
108108
cmd_args_seq = [executable] + self.get_output_args(overwrite, progress)
109109
command = join_cmd_args_seq(cmd_args_seq)
110110

111-
if direct_print:
111+
if print_cmd:
112112
color.greenln(command)
113113

114114
if join_args:
115115
return command
116116

117117
return cmd_args_seq
118118

119-
def run_async(self, *, executable="ffmpeg", direct_print=True, join_args=False,
119+
def run_async(self, *, executable="ffmpeg", print_cmd=True, join_args=False,
120120
pipe_stdin=False, pipe_stdout=True, pipe_stderr=True, quiet=False,
121121
overwrite=True, progress='') -> subprocess.Popen:
122122
'''Asynchronously invoke ffmpeg for the supplied node graph.'''
@@ -127,7 +127,7 @@ def run_async(self, *, executable="ffmpeg", direct_print=True, join_args=False,
127127

128128
cmd_args_seq = self.compile(
129129
executable=executable,
130-
direct_print=direct_print,
130+
print_cmd=print_cmd,
131131
join_args=join_args,
132132
overwrite=overwrite,
133133
progress=progress,
@@ -144,14 +144,14 @@ def run_async(self, *, executable="ffmpeg", direct_print=True, join_args=False,
144144
stderr=stderr_stream if not quiet else subprocess.STDOUT,
145145
)
146146

147-
def run(self, executable="ffmpeg", direct_print=True, quiet=False,
147+
def run(self, executable="ffmpeg", print_cmd=True, quiet=False,
148148
capture_stdout=True, capture_stderr=True, pipe_stdin=None,
149149
overwrite=True, progress='') -> Union[str, List[str]]:
150150
'''Invoke ffmpeg for the supplied node graph.'''
151151
start = perf_counter()
152152
process = self.run_async(
153153
executable=executable,
154-
direct_print=direct_print,
154+
print_cmd=print_cmd,
155155
quiet=quiet,
156156
pipe_stdin=pipe_stdin is not None,
157157
pipe_stdout=capture_stdout,

0 commit comments

Comments
 (0)