From 5ec74f8abe477154a53162a542f5f27022f075ba Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 31 Mar 2020 10:28:04 -0400 Subject: [PATCH 1/3] ffmpeg file analysis returns duration as integer now --- lbry/file_analysis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbry/file_analysis.py b/lbry/file_analysis.py index 7e083991c..3ae8b7dc8 100644 --- a/lbry/file_analysis.py +++ b/lbry/file_analysis.py @@ -354,7 +354,7 @@ class VideoFileAnalyzer: def _build_spec(scan_data): assert scan_data - duration = float(scan_data["format"]["duration"]) # existence verified when scan_data made + duration = int(scan_data["format"]["duration"]) # existence verified when scan_data made width = -1 height = -1 for stream in scan_data["streams"]: @@ -363,7 +363,7 @@ class VideoFileAnalyzer: width = max(width, int(stream["width"])) height = max(height, int(stream["height"])) - log.debug(" Detected duration: %f sec. with resolution: %d x %d", duration, width, height) + log.debug(" Detected duration: %d sec. with resolution: %d x %d", duration, width, height) spec = {"duration": duration} if height >= 0: From 6f22f6a59f616f6fd6b67a3aaf5011bec57e1f28 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 31 Mar 2020 10:57:37 -0400 Subject: [PATCH 2/3] use ceil() on duration float() instead of int() directly --- lbry/file_analysis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lbry/file_analysis.py b/lbry/file_analysis.py index 3ae8b7dc8..21dd8df61 100644 --- a/lbry/file_analysis.py +++ b/lbry/file_analysis.py @@ -8,6 +8,7 @@ import re import shlex import shutil import subprocess +from math import ceil import lbry.utils from lbry.conf import TranscodeConfig @@ -354,7 +355,7 @@ class VideoFileAnalyzer: def _build_spec(scan_data): assert scan_data - duration = int(scan_data["format"]["duration"]) # existence verified when scan_data made + duration = ceil(float(scan_data["format"]["duration"])) # existence verified when scan_data made width = -1 height = -1 for stream in scan_data["streams"]: From 558ac24f7e9f6b0c27000aec90960851dcee1c63 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 31 Mar 2020 11:29:58 -0400 Subject: [PATCH 3/3] fix test --- tests/integration/other/test_transcoding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/other/test_transcoding.py b/tests/integration/other/test_transcoding.py index 9bf654825..673e39a0c 100644 --- a/tests/integration/other/test_transcoding.py +++ b/tests/integration/other/test_transcoding.py @@ -60,7 +60,7 @@ class TranscodeValidation(ClaimTestCase): self.assertEqual(self.video_file_webm, new_file_name) self.assertEqual(spec["width"], 1280) self.assertEqual(spec["height"], 720) - self.assertEqual(spec["duration"], 15.054) + self.assertEqual(spec["duration"], 16) async def test_volume(self): self.conf.volume_analysis_time = 200