Merge pull request #2898 from lbryio/duration_is_int

`ffmpeg` file analysis returns duration as integer now
This commit is contained in:
Lex Berezhny 2020-03-31 12:06:44 -04:00 committed by GitHub
commit e62678e4e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import re
import shlex import shlex
import shutil import shutil
import subprocess import subprocess
from math import ceil
import lbry.utils import lbry.utils
from lbry.conf import TranscodeConfig from lbry.conf import TranscodeConfig
@ -354,7 +355,7 @@ class VideoFileAnalyzer:
def _build_spec(scan_data): def _build_spec(scan_data):
assert scan_data assert scan_data
duration = float(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 width = -1
height = -1 height = -1
for stream in scan_data["streams"]: for stream in scan_data["streams"]:
@ -363,7 +364,7 @@ class VideoFileAnalyzer:
width = max(width, int(stream["width"])) width = max(width, int(stream["width"]))
height = max(height, int(stream["height"])) 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} spec = {"duration": duration}
if height >= 0: if height >= 0:

View file

@ -60,7 +60,7 @@ class TranscodeValidation(ClaimTestCase):
self.assertEqual(self.video_file_webm, new_file_name) self.assertEqual(self.video_file_webm, new_file_name)
self.assertEqual(spec["width"], 1280) self.assertEqual(spec["width"], 1280)
self.assertEqual(spec["height"], 720) self.assertEqual(spec["height"], 720)
self.assertEqual(spec["duration"], 15.054) self.assertEqual(spec["duration"], 16)
async def test_volume(self): async def test_volume(self):
self.conf.volume_analysis_time = 200 self.conf.volume_analysis_time = 200