mirror of
https://github.com/ApfelTeeSaft/restream_playout.git
synced 2026-08-26 19:33:32 +00:00
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from restream_playout.exceptions import InvalidMediaError
|
|
from restream_playout.models import MediaKind
|
|
from restream_playout.mp4 import parse_mp4
|
|
|
|
from .mp4_builder import write_test_mp4
|
|
|
|
|
|
class MP4Tests(unittest.TestCase):
|
|
def test_parse_h264_aac_mp4(self) -> None:
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
path = Path(directory, "clip.mp4")
|
|
write_test_mp4(path)
|
|
clip = parse_mp4(path)
|
|
self.assertEqual((clip.config.width, clip.config.height), (16, 16))
|
|
self.assertEqual(clip.config.audio_sample_rate, 44100)
|
|
packets = list(clip.packets())
|
|
self.assertEqual({packet.kind for packet in packets}, {MediaKind.VIDEO, MediaKind.AUDIO})
|
|
self.assertTrue(next(packet for packet in packets if packet.kind is MediaKind.VIDEO).keyframe)
|
|
|
|
def test_rejects_missing_file(self) -> None:
|
|
with self.assertRaises(InvalidMediaError):
|
|
parse_mp4("does-not-exist.mp4")
|
|
|