mirror of
https://github.com/facefusion/facefusion.git
synced 2026-06-07 13:13:53 +02:00
changes for vp9 support
This commit is contained in:
@@ -11,6 +11,7 @@ from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||
from facefusion.download import conditional_download
|
||||
from facefusion.hash_helper import create_hash
|
||||
from facefusion.libraries import vpx as vpx_module
|
||||
from facefusion.types import VxpVideoCodec
|
||||
from facefusion.vision import read_video_frame
|
||||
|
||||
|
||||
@@ -23,30 +24,41 @@ def before_all() -> None:
|
||||
vpx_module.pre_check()
|
||||
|
||||
|
||||
def test_create() -> None:
|
||||
assert create(1)
|
||||
@pytest.mark.parametrize('video_codec', [ 'vp8', 'vp9' ])
|
||||
def test_create(video_codec : VxpVideoCodec) -> None:
|
||||
assert create(video_codec, 1)
|
||||
|
||||
with patch('facefusion.libraries.vpx.create_static_library', return_value = None):
|
||||
assert create(1) is None
|
||||
assert create(video_codec, 1) is None
|
||||
|
||||
|
||||
def test_decode() -> None:
|
||||
@pytest.mark.parametrize('video_codec', [ 'vp8', 'vp9' ])
|
||||
def test_decode(video_codec : VxpVideoCodec) -> None:
|
||||
video_frame = read_video_frame(get_test_example_file('target-240p.mp4'))
|
||||
video_buffer = cv2.cvtColor(video_frame, cv2.COLOR_BGR2YUV_I420).tobytes()
|
||||
video_resolution = (video_frame.shape[1], video_frame.shape[0])
|
||||
vpx_encoder = create_encoder(video_resolution, 1000, 1, 0)
|
||||
vpx_encoder = create_encoder(video_codec, video_resolution, 1000, 1, 0)
|
||||
encode_buffer = encode(vpx_encoder, video_buffer, video_resolution, 0)
|
||||
vpx_decoder = create(1)
|
||||
vpx_decoder = create(video_codec, 1)
|
||||
|
||||
if is_linux() or is_windows():
|
||||
assert create_hash(decode(vpx_decoder, encode_buffer).get('buffer')) == 'dc9c8864'
|
||||
if video_codec == 'vp8':
|
||||
assert create_hash(decode(vpx_decoder, encode_buffer).get('buffer')) == 'dc9c8864'
|
||||
|
||||
if video_codec == 'vp9':
|
||||
assert create_hash(decode(vpx_decoder, encode_buffer).get('buffer')) == '50f4c1fa'
|
||||
|
||||
if is_macos():
|
||||
assert create_hash(decode(vpx_decoder, encode_buffer).get('buffer')) == '87450f70'
|
||||
if video_codec == 'vp8':
|
||||
assert create_hash(decode(vpx_decoder, encode_buffer).get('buffer')) == '87450f70'
|
||||
|
||||
if video_codec == 'vp9':
|
||||
pytest.skip()
|
||||
|
||||
|
||||
def test_destroy() -> None:
|
||||
vpx_decoder = create(1)
|
||||
@pytest.mark.parametrize('video_codec', [ 'vp8', 'vp9' ])
|
||||
def test_destroy(video_codec : VxpVideoCodec) -> None:
|
||||
vpx_decoder = create(video_codec, 1)
|
||||
|
||||
with patch.object(vpx_module.create_static_library(), 'vpx_codec_destroy') as mock:
|
||||
destroy(vpx_decoder)
|
||||
|
||||
Reference in New Issue
Block a user