83 lines
2.7 KiB
Python
83 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
SRC_ROOT = Path(__file__).resolve().parents[2] / "src"
|
|
|
|
if str(SRC_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(SRC_ROOT))
|
|
|
|
|
|
from ffx.file_properties import FileProperties # noqa: E402
|
|
from ffx.i18n import set_current_language # noqa: E402
|
|
from ffx.logging_utils import get_ffx_logger # noqa: E402
|
|
from ffx.track_codec import TrackCodec # noqa: E402
|
|
from ffx.track_type import TrackType # noqa: E402
|
|
from tests.support.ffx_bundle import SourceTrackSpec, create_source_fixture # noqa: E402
|
|
|
|
|
|
class StaticConfig:
|
|
def __init__(self, data: dict):
|
|
self._data = data
|
|
|
|
def getData(self):
|
|
return self._data
|
|
|
|
|
|
class FilePropertiesAssetProbeTests(unittest.TestCase):
|
|
def tearDown(self):
|
|
set_current_language("de")
|
|
|
|
def test_boruto_webm_probe_recognizes_webm_stream_codecs(self):
|
|
context = {
|
|
"logger": get_ffx_logger(),
|
|
"config": StaticConfig({}),
|
|
"language": "de",
|
|
"use_pattern": False,
|
|
}
|
|
set_current_language("de")
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
media_path = create_source_fixture(
|
|
Path(tmpdir),
|
|
"fixture.webm",
|
|
[
|
|
SourceTrackSpec(TrackType.VIDEO, identity="video-0"),
|
|
SourceTrackSpec(TrackType.AUDIO, identity="audio-1", language="eng"),
|
|
SourceTrackSpec(
|
|
TrackType.SUBTITLE,
|
|
identity="subtitle-2",
|
|
language="eng",
|
|
subtitle_lines=("Lorem ipsum dolor sit amet.",),
|
|
),
|
|
],
|
|
duration_seconds=3,
|
|
video_encoder="libvpx-vp9",
|
|
video_encoder_options=("-b:v", "0", "-crf", "45"),
|
|
audio_encoder="libopus",
|
|
audio_encoder_options=("-b:a", "48k"),
|
|
subtitle_encoder="webvtt",
|
|
)
|
|
|
|
file_properties = FileProperties(context, str(media_path))
|
|
tracks = file_properties.getMediaDescriptor().getTrackDescriptors()
|
|
|
|
subtitle_codecs = [
|
|
track.getCodec()
|
|
for track in tracks
|
|
if track.getType() == TrackType.SUBTITLE
|
|
]
|
|
|
|
self.assertIn(TrackCodec.VP9, [track.getCodec() for track in tracks])
|
|
self.assertIn(TrackCodec.OPUS, [track.getCodec() for track in tracks])
|
|
self.assertTrue(subtitle_codecs)
|
|
self.assertTrue(all(codec == TrackCodec.WEBVTT for codec in subtitle_codecs))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|