From 500cd0cb43dce858a7ed22ea33d9557068cbfae1 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Thu, 26 May 2016 20:25:47 +0200 Subject: add a test --- test/data/test.mkv | Bin 249856 -> 1214355 bytes test/ffmpeg.py | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/data/test.mkv b/test/data/test.mkv index 9bcacec..6a225a5 100644 Binary files a/test/data/test.mkv and b/test/data/test.mkv differ diff --git a/test/ffmpeg.py b/test/ffmpeg.py index 913d8d8..58b1398 100644 --- a/test/ffmpeg.py +++ b/test/ffmpeg.py @@ -1,6 +1,7 @@ import mediabrowser.ffmpeg as ffmpeg import os +import tempfile from pprint import pprint from unittest import TestCase @@ -23,4 +24,21 @@ class TestFfmpeg(TestCase): def test_calculate_splittimes(self): for time in ffmpeg.calculate_splittimes(self.test_mkv, 120): - print(time) \ No newline at end of file + print(time) + + def test_split(self): + _, pos1 = ffmpeg.find_next_keyframe(self.test_mkv, 2, 5) + frame_dur1, pos2 = ffmpeg.find_next_keyframe(self.test_mkv, pos1+2, 5) + frame_dur2, pos3 = ffmpeg.find_next_keyframe(self.test_mkv, pos2+2, 5) + out1 = open(tempfile.mktemp(), "wb") + out2 = open(tempfile.mktemp(), "wb") + pprint(locals()) + + out1.write(ffmpeg.stream(self.test_mkv, pos1, pos2-pos1-frame_dur1).stdout.read()) + out2.write(ffmpeg.stream(self.test_mkv, pos2, pos3-pos2-frame_dur2).stdout.read()) + + + + os.remove(out1.name) + os.remove(out2.name) + -- cgit v1.2.1