-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_pyffmpeg.py
107 lines (77 loc) · 2.26 KB
/
test_pyffmpeg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import os
import requests
# from platform import system
import pytest
from pyffmpeg import FFmpeg
from pyffmpeg.misc import Paths
# are we offline?
try:
resp = requests.get('https://google.com/')
TEST_FOLDER = "https://raw.githubusercontent.com/"
TEST_FOLDER += "deuteronomy-works/pyffmpeg/master/tests/"
except:
TEST_FOLDER = os.path.join(os.path.abspath('.'), 'tests/')
home = Paths().home_path
cwd = os.path.dirname(__file__)
EASY_LEMON = "".join([TEST_FOLDER, 'Easy_Lemon_30_Second_-_Kevin_MacLeod.mp3'])
E_FLAT = "".join([TEST_FOLDER, "Ecossaise in E-flat - Kevin MacLeod.mp3"])
COUNTDOWN = "".join([TEST_FOLDER, 'countdown.mp4'])
FLV_WITH_AUDIO = "".join([TEST_FOLDER, 'sample_960x400_ocean_with_audio.flv'])
def test_save_directory():
"""
Test to see if save directory is used
"""
sav_dir = 'H:\\FakePath'
ffmpeg = FFmpeg(sav_dir)
if ffmpeg:
assert ffmpeg.save_dir == sav_dir
else:
assert False
@pytest.mark.parametrize(
'in_file,out_file',
[
(COUNTDOWN, 'countdown.wav'),
(FLV_WITH_AUDIO, 'flv.mp4'),
(FLV_WITH_AUDIO, 'flv.mp3'),
(FLV_WITH_AUDIO, 'flv.wav'),
(FLV_WITH_AUDIO, 'outs/flv.mp3')])
def test_convert(in_file, out_file):
"""
"""
out_file = os.path.join(home, out_file)
ff = FFmpeg()
b_path = os.path.exists(ff.get_ffmpeg_bin())
ff.loglevel = 'info'
print(f'in and out: {in_file} {home} {b_path}')
ff.convert(in_file, out_file)
if ff.error:
print(ff.error)
assert False
else:
assert True
def test_get_ffmpeg_bin():
home_path = Paths().load_ffmpeg_bin()
bin_path = FFmpeg().get_ffmpeg_bin()
print('bin: ', bin_path)
print('home: ', home_path)
assert home_path == bin_path
def test_loglevel():
ff = FFmpeg()
ff.loglevel = 'fa'
path = Paths().home_path
o = os.path.join(path, 'f.wav')
opt = ['-i', EASY_LEMON, o]
ff.options(opt)
assert ff.loglevel != 'fa'
def test_options():
path = Paths().home_path
o = os.path.join(path, 'f.wav')
opt = ['-i', EASY_LEMON, o]
ff = FFmpeg()
print(f'in and out: {EASY_LEMON}, {o}')
ff.options(opt)
if ff.error:
print(ff.error)
assert False
else:
assert True