Skip to content

Commit 39bef84

Browse files
committed
Fix test_pipe()
FFmpeg 5.x duplicates trimmed frames instead of removing them.
1 parent df129c7 commit 39bef84

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

ffmpeg/tests/test_ffmpeg.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ def test_pipe():
688688
width = 32
689689
height = 32
690690
frame_size = width * height * 3 # 3 bytes for rgb24
691-
frame_count = 10
692-
start_frame = 2
691+
frame_count = 15
692+
start_frame = 3
693693

694694
out = (
695695
ffmpeg.input(
@@ -716,7 +716,7 @@ def test_pipe():
716716
'-i',
717717
'pipe:0',
718718
'-filter_complex',
719-
'[0]trim=start_frame=2[s0]',
719+
'[0]trim=start_frame={}[s0]'.format(start_frame),
720720
'-map',
721721
'[s0]',
722722
'-f',
@@ -739,8 +739,19 @@ def test_pipe():
739739
p.stdin.close()
740740

741741
out_data = p.stdout.read()
742-
assert len(out_data) == frame_size * (frame_count - start_frame)
743-
assert out_data == in_data[start_frame * frame_size :]
742+
743+
if start_frame > 0 and len(out_data) < len (in_data):
744+
# ffmpeg 4.x removes trimmed frames
745+
assert len(out_data) == frame_size * (frame_count - start_frame)
746+
assert out_data == in_data[start_frame * frame_size :]
747+
else:
748+
# ffmpeg 5.x duplicates trimmed frames
749+
assert len(out_data) == len(in_data):
750+
751+
for fn in range(0, start_frame):
752+
assert out_data[fn*frame_size] == in_data[start_frame * frame_size]
753+
754+
assert out_data[start_frame * frame_size :] == in_data[start_frame * frame_size :]
744755

745756

746757
def test__probe():

0 commit comments

Comments
 (0)