aports/testing/py3-ffmpeg/fix-test-pipe.patch

59 lines
1.9 KiB
Diff

Patch-Source: https://github.com/kkroening/ffmpeg-python/pull/726
---
From 557ed8e81ff48c5931c9249ec4aae525347ecf85 Mon Sep 17 00:00:00 2001
From: xiota <github@mentalfossa.com>
Date: Sat, 10 Dec 2022 18:03:35 -0800
Subject: [PATCH] Fix test_pipe()
FFmpeg 5.x duplicates trimmed frames instead of removing them.
---
ffmpeg/tests/test_ffmpeg.py | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/ffmpeg/tests/test_ffmpeg.py b/ffmpeg/tests/test_ffmpeg.py
index 8dbc271a..524f6bef 100644
--- a/ffmpeg/tests/test_ffmpeg.py
+++ b/ffmpeg/tests/test_ffmpeg.py
@@ -688,8 +688,8 @@ def test_pipe():
width = 32
height = 32
frame_size = width * height * 3 # 3 bytes for rgb24
- frame_count = 10
- start_frame = 2
+ frame_count = 15
+ start_frame = 3
out = (
ffmpeg.input(
@@ -716,7 +716,7 @@ def test_pipe():
'-i',
'pipe:0',
'-filter_complex',
- '[0]trim=start_frame=2[s0]',
+ '[0]trim=start_frame={}[s0]'.format(start_frame),
'-map',
'[s0]',
'-f',
@@ -739,8 +739,19 @@ def test_pipe():
p.stdin.close()
out_data = p.stdout.read()
- assert len(out_data) == frame_size * (frame_count - start_frame)
- assert out_data == in_data[start_frame * frame_size :]
+
+ if start_frame > 0 and len(out_data) < len (in_data):
+ # ffmpeg 4.x removes trimmed frames
+ assert len(out_data) == frame_size * (frame_count - start_frame)
+ assert out_data == in_data[start_frame * frame_size :]
+ else:
+ # ffmpeg 5.x duplicates trimmed frames
+ assert len(out_data) == len(in_data)
+
+ for fn in range(0, start_frame):
+ assert out_data[fn*frame_size] == in_data[start_frame * frame_size]
+
+ assert out_data[start_frame * frame_size :] == in_data[start_frame * frame_size :]
def test__probe():