[ffmpeg] Improve version check and call it from hls (Fixes #4377)
authorPhilipp Hagemeister <phihag@phihag.de>
Sat, 6 Dec 2014 11:14:26 +0000 (12:14 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Sat, 6 Dec 2014 11:14:26 +0000 (12:14 +0100)
test/test_utils.py
youtube_dl/downloader/hls.py
youtube_dl/postprocessor/ffmpeg.py
youtube_dl/utils.py

index badab1370629cf0214f3eaf1b1822a7768aeaa5b..5c7bf5175cc4d718c37b1f379fce89b7a9a9a5c2 100644 (file)
@@ -48,6 +48,7 @@ from youtube_dl.utils import (
     intlist_to_bytes,
     args_to_str,
     parse_filesize,
+    version_tuple,
 )
 
 
@@ -381,5 +382,10 @@ class TestUtil(unittest.TestCase):
         self.assertEqual(parse_filesize('1.2Tb'), 1200000000000)
         self.assertEqual(parse_filesize('1,24 KB'), 1240)
 
+    def test_version_tuple(self):
+        self.assertEqual(version_tuple('1'), (1,))
+        self.assertEqual(version_tuple('10.23.344'), (10, 23, 344))
+        self.assertEqual(version_tuple('10-6'), (10, 6))  # avconv style
+
 if __name__ == '__main__':
     unittest.main()
index 954beffd50e51db43ce203931d31ad2fbeee95dc..ad26cfa4085bbb028c7252aa9db2a8de3f7bd1e4 100644 (file)
@@ -4,6 +4,7 @@ import os
 import re
 import subprocess
 
+from ..postprocessor.ffmpeg import FFmpegPostProcessor
 from .common import FileDownloader
 from ..utils import (
     compat_urlparse,
@@ -32,6 +33,9 @@ class HlsFD(FileDownloader):
             return False
         cmd = [program] + args
 
+        ffpp = FFmpegPostProcessor(downloader=self)
+        ffpp.check_version()
+
         retval = subprocess.call(cmd)
         if retval == 0:
             fsize = os.path.getsize(encodeFilename(tmpfilename))
index 9303b8378b8065d84ed2d064ab76aacb463ef6bf..965ded4c1590eb3cccfebcfc3fd460f5a83d1c90 100644 (file)
@@ -37,11 +37,11 @@ class FFmpegPostProcessor(PostProcessor):
         if not self._executable:
             raise FFmpegPostProcessorError('ffmpeg or avconv not found. Please install one.')
 
-        REQUIRED_VERSION = '1.0'
+        required_version = '10-0' if self._uses_avconv() else '1.0'
         if is_outdated_version(
-                self._versions[self._executable], REQUIRED_VERSION):
+                self._versions[self._executable], required_version):
             warning = 'Your copy of %s is outdated, update %s to version %s or newer if you encounter any errors.' % (
-                self._executable, self._executable, REQUIRED_VERSION)
+                self._executable, self._executable, required_version)
             if self._downloader:
                 self._downloader.report_warning(warning)
 
index 5efb4c59a18e0c89e902f66be6dfe93af6b71df5..2e70cc791bca5eaf5b2c1067741b9e25334a3377 100644 (file)
@@ -1502,7 +1502,7 @@ def limit_length(s, length):
 
 
 def version_tuple(v):
-    return [int(e) for e in v.split('.')]
+    return tuple(int(e) for e in re.split(r'[-.]', v))
 
 
 def is_outdated_version(version, limit, assume_new=True):