| 1 | Patch-Source: https://github.com/kkroening/ffmpeg-python/pull/726
|
| 2 | ---
|
| 3 | From 557ed8e81ff48c5931c9249ec4aae525347ecf85 Mon Sep 17 00:00:00 2001
|
| 4 | From: xiota <[email protected]>
|
| 5 | Date: Sat, 10 Dec 2022 18:03:35 -0800
|
| 6 | Subject: [PATCH] Fix test_pipe()
|
| 7 |
|
| 8 | FFmpeg 5.x duplicates trimmed frames instead of removing them.
|
| 9 | ---
|
| 10 | ffmpeg/tests/test_ffmpeg.py | 21 ++++++++++++++++-----
|
| 11 | 1 file changed, 16 insertions(+), 5 deletions(-)
|
| 12 |
|
| 13 | diff --git a/ffmpeg/tests/test_ffmpeg.py b/ffmpeg/tests/test_ffmpeg.py
|
| 14 | index 8dbc271a..524f6bef 100644
|
| 15 | |
| 16 | |
| 17 | @@ -688,8 +688,8 @@ def test_pipe():
|
| 18 | width = 32
|
| 19 | height = 32
|
| 20 | frame_size = width * height * 3 # 3 bytes for rgb24
|
| 21 | - frame_count = 10
|
| 22 | - start_frame = 2
|
| 23 | + frame_count = 15
|
| 24 | + start_frame = 3
|
| 25 |
|
| 26 | out = (
|
| 27 | ffmpeg.input(
|
| 28 | @@ -716,7 +716,7 @@ def test_pipe():
|
| 29 | '-i',
|
| 30 | 'pipe:0',
|
| 31 | '-filter_complex',
|
| 32 | - '[0]trim=start_frame=2[s0]',
|
| 33 | + '[0]trim=start_frame={}[s0]'.format(start_frame),
|
| 34 | '-map',
|
| 35 | '[s0]',
|
| 36 | '-f',
|
| 37 | @@ -739,8 +739,19 @@ def test_pipe():
|
| 38 | p.stdin.close()
|
| 39 |
|
| 40 | out_data = p.stdout.read()
|
| 41 | - assert len(out_data) == frame_size * (frame_count - start_frame)
|
| 42 | - assert out_data == in_data[start_frame * frame_size :]
|
| 43 | +
|
| 44 | + if start_frame > 0 and len(out_data) < len (in_data):
|
| 45 | + # ffmpeg 4.x removes trimmed frames
|
| 46 | + assert len(out_data) == frame_size * (frame_count - start_frame)
|
| 47 | + assert out_data == in_data[start_frame * frame_size :]
|
| 48 | + else:
|
| 49 | + # ffmpeg 5.x duplicates trimmed frames
|
| 50 | + assert len(out_data) == len(in_data)
|
| 51 | +
|
| 52 | + for fn in range(0, start_frame):
|
| 53 | + assert out_data[fn*frame_size] == in_data[start_frame * frame_size]
|
| 54 | +
|
| 55 | + assert out_data[start_frame * frame_size :] == in_data[start_frame * frame_size :]
|
| 56 |
|
| 57 |
|
| 58 | def test__probe():
|