Replies: 11 comments
|
Here is a simplified version of your code, which uses import av
import numpy as np
def process_video(container, process_frame, start, stop):
stream = container.streams.video[0]
if start > 0:
stream.seek(start, 'frame', any_frame=True)
index = start
for packet in container.demux(stream):
for frame in packet.decode():
img = frame.to_image()
img = np.asarray(img)
process_frame(index, img)
index += 1
if stop is not None and index >= stop:
return
def noop(index, img):
print('-- frame %d --' % index)
print(img)
container = av.open('test.mp4')
process_video(container, noop, 10, 20)Could you please provide a sample video for which this does not work? NOTE: it seems a bit strange to convert first to a PIL image then to a numpy array, why not use |
|
Here is a small test file that triggers the issue. The file is cut to just 3MB using Use the following test to reproduce: def noop(index, img):
print('Frame %d: %d', (index, img.sum()))
process_video(av.open('test-trimmed.avi'), noop, 2, 4, use_seek=False)
process_video(av.open('test-trimmed.avi'), noop, 2, 4, use_seek=True)The output without seeking: The output with seeking: Concerning the to_image, the video is in pal8 which |
|
I see the zero frames also with the current 6.0.0 release. |
|
Why are you purposefully damaging the AVI file? If you open the same file with VLC it complains that the index is broken, and seeking will not work correctly.. Could you provide an un-damaged file which reproduces the error please? |
|
@gatagat Does this mean that you had a file which you weren't cutting with |
|
The original file as well as the trimmed sample file both behave the same way, i.e., I get zero frames after a seek and correct frames without a seek. I see the error in 6.0.0 as well. |
|
@jlaine Here is a different test file that is tiny enough to share in full https://ufile.io/1lacy |
|
I have yet another version of the script in question: A few interesting things:
|
|
If I am grabbing both RGB and PAL arrays, it segfaults at 41. If I'm just doing PAL, it segfaults at 85. |
|
I can trigger it via |
|
This problem can now be solved with post-15.1 release as the solution is outlined in Issue #1987 |
Uh oh!
There was an error while loading. Please reload this page.
First of all, thanks for releasing this library!
I encountered a bug in
seek, that causes the subsequently read frames to be constant zero. It would be simple to just linearly loop through the frames, but there is no indication of the error. It happens only with some AVI files, however these files play/seek as expected in e.g. VLC.I would like to have something like the following
process_videofunction that would allow processing a selected range of the video frames. I see the error if I call it withuse_seek=True.Python 2.7.13
av: 0.4.1 (from pypi)
All reactions