RomanArzumanyan / VALI

Video processing in Python
Apache License 2.0
34 stars 4 forks source link

problem when running decode sample #106

Open incomingflyingbrick opened 6 days ago

incomingflyingbrick commented 6 days ago

I am trying to decode a video using a sample, but I got the error saying source and output dimention mismatch at this line # Copy pixels to numpy ndarray success, details = pyDwn.Run(surf_dst, frame) decode sample Is this a software bug of the library ?

RomanArzumanyan commented 6 days ago

Hi @incomingflyingbrick

What input do you use ? Is it same as in sample or did you change it ? This may happen if video change it's resolution in the middle. Then PySurfaceDownloader will scold incoming numpy ndarray because it no longer matches the updated Surface resolution.

incomingflyingbrick commented 6 days ago

@RomanArzumanyan Hi, I tried different videos with mp4 format, including the video in the test folder named test.mp4, but none of them worked, still showing the following error. TaskExecInfo.SRC_DST_SIZE_MISMATCH Traceback (most recent call last): File "/storage/ongoing/new/test_decord/test_vali.py", line 78, in <module> raise StopExecution StopExecution

RomanArzumanyan commented 6 days ago

@incomingflyingbrick

That's very strange. Can you modify the sample to output both surf_dst and frame shape ? It can be done like this:

print(frame.shape)
print(surf_dst.__cuda_array_interface__)

# Copy pixels to numpy ndarray
success, details = pyDwn.Run(surf_dst, frame)
if not success:
    print(details)
    raise StopExecution

When working properly, the output shall be like this (for test.mp4 video of resolution 848x464):

(1180416,)
{'shape': (464, 848, 3}, ...

848x464 RGB Surface requires 848x464x3 == 1180416 bytes.

incomingflyingbrick commented 6 days ago

@RomanArzumanyan Hi, I changed the code and got the following output (2764800,) {'shape': (1280, 720, 3), 'typestr': '<u1', 'data': (139942994903040, False), 'version': 3, 'strides': (2560, 3, 1), 'stream': 36464064} TaskExecInfo.SRC_DST_SIZE_MISMATCH Traceback (most recent call last): File "/storage/ongoing/new/test_decord/test_vali.py", line 79, in <module> raise StopExecution StopExecution

It seems the shape is correct, but still unable to obtain a successful result.

RomanArzumanyan commented 5 days ago

Hi @incomingflyingbrick

It looks like something is happening in the C++ land although I'm not sure what. Can you build VALI from branch issue_106 and run the same decoding sample ? It adds more verbose debug output like this:

/home/roman/git/VALI/src/python_vali/src/PySurfaceDownloader.cpp::Run
array size:   1180416
buffer size:  1180416
surface size: 1180416
/home/roman/git/VALI/src/TC/src/TaskCudaDownloadSurface.cpp::Run
buffer size:  1180416
surface size: 1180416

Building from source is not difficult, you just check out the feature branch and run pip isntall . in console.

incomingflyingbrick commented 4 days ago

@RomanArzumanyan I got the following output using the issue_106 branch build from the source. array size: 0 buffer size: 0 surface size: 230400 /storage/ongoing/new/test_decord/VALI/src/TC/src/TaskCudaDownloadSurface.cpp::Run buffer size: 0 surface size: 230400 TaskExecInfo.SRC_DST_SIZE_MISMATCH Traceback (most recent call last): File "/storage/ongoing/new/test_decord/test_vali.py", line 79, in <module> raise StopExecution StopExecution

RomanArzumanyan commented 4 days ago

Thanks for the update @incomingflyingbrick

It means that ndarray was created on the python side with size of 230400 but those changes aren't seen on C++ side for some reason.

Need to google on this. Looks like some sort of lazy init of ndarray. Didn't face that before. I'll come back as I find something.

P. S. Meanwhile may I ask you to check the lazy init suggestion by initializing ndarray with zeroes ?

# Numpy array which contains decoded RGB Surface
frame = np.ndarray(
    dtype=np.uint8,
    shape=surf_dst.HostSize)
frame[:]=0
incomingflyingbrick commented 4 days ago

@RomanArzumanyan Hi I got the same error again after I changed to lazy init.

/storage/ongoing/new/test_decord/VALI/src/python_vali/src/PySurfaceDownloader.cpp::Run array size: 0 buffer size: 0 surface size: 230400 /storage/ongoing/new/test_decord/VALI/src/TC/src/TaskCudaDownloadSurface.cpp::Run buffer size: 0 surface size: 230400 TaskExecInfo.SRC_DST_SIZE_MISMATCH Traceback (most recent call last): File "/storage/ongoing/new/test_decord/test_vali.py", line 80, in raise StopExecution StopExecution