[pitivi] proxy: Fix traceback when trying to scale proxy an audio asset



commit a1348c7c09896ecb281b059a17bf572b98a2bd68
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Oct 10 00:55:20 2019 +0200

    proxy: Fix traceback when trying to scale proxy an audio asset

 pitivi/utils/proxy.py       | 3 +++
 tests/test_media_library.py | 9 +++++++++
 tests/test_proxy.py         | 9 +++++++++
 3 files changed, 21 insertions(+)
---
diff --git a/pitivi/utils/proxy.py b/pitivi/utils/proxy.py
index 2a9277b0..7c13268f 100644
--- a/pitivi/utils/proxy.py
+++ b/pitivi/utils/proxy.py
@@ -403,6 +403,9 @@ class ProxyManager(GObject.Object, Loggable):
             return False
 
         if scaled:
+            if not asset.get_info().get_video_streams():
+                return False
+
             return not self.is_scaled_proxy(asset) or \
                 self.asset_matches_target_res(asset)
         else:
diff --git a/tests/test_media_library.py b/tests/test_media_library.py
index 3d38b506..c3dcbe09 100644
--- a/tests/test_media_library.py
+++ b/tests/test_media_library.py
@@ -420,6 +420,15 @@ class TestMediaLibrary(BaseTestMediaLibrary):
                 # Delete HQ Proxy
                 self.check_disable_proxy(proxy, asset, delete=True)
 
+    def test_scale_proxy_audio_post_import(self):
+        sample = "mp3_sample.mp3"
+        with common.cloned_sample(sample):
+            self.check_import([sample], proxying_strategy=ProxyingStrategy.NOTHING)
+            asset = self.medialibrary.storemodel[0][medialibrary.COL_ASSET]
+
+            project = self.app.project_manager.current_project
+            project.use_proxies_for_assets([asset], scaled=True)
+
     def test_supported_out_of_container_audio(self):
         sample = "mp3_sample.mp3"
         with common.cloned_sample(sample):
diff --git a/tests/test_proxy.py b/tests/test_proxy.py
index 8e0888ef..d52b50fd 100644
--- a/tests/test_proxy.py
+++ b/tests/test_proxy.py
@@ -120,6 +120,15 @@ class TestProxyManager(common.TestCase):
         image = GES.UriClipAsset.request_sync(uri)
         self.assertFalse(manager.asset_can_be_proxied(image))
 
+        uri = common.get_sample_uri("mp3_sample.mp3")
+        audio = GES.UriClipAsset.request_sync(uri)
+        self.assertTrue(manager.asset_can_be_proxied(audio))
+        self.assertFalse(manager.asset_can_be_proxied(audio, scaled=True))
+        with mock.patch.object(manager, "is_hq_proxy") as hq:
+            hq.return_value = True
+            self.assertFalse(manager.asset_can_be_proxied(audio))
+            self.assertFalse(manager.asset_can_be_proxied(audio, scaled=True))
+
         uri = common.get_sample_uri("30fps_numeroted_frames_blue.webm")
         video = GES.UriClipAsset.request_sync(uri)
         self.assertTrue(manager.asset_can_be_proxied(video, scaled=True))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]