Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvidia.dali.fn.experimental.decoders.video cannot parse raw HEVC #4479

Closed
zeruniverse opened this issue Nov 30, 2022 · 3 comments
Closed

nvidia.dali.fn.experimental.decoders.video cannot parse raw HEVC #4479

zeruniverse opened this issue Nov 30, 2022 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@zeruniverse
Copy link

zeruniverse commented Nov 30, 2022

This sample hevc file is raw HEVC without container (I manually appended ODT suffix as otherwise GitHub won't let me upload it) black.hevc

FFMPEG can parse it successfully with

ffmpeg -i black.hevc 123/%2d.jpg

However, DALI cannot parse this (I used following code, and it said Could not seek to the first frame of video memory filedue toOperation not permitted)

import numpy as np
class ExternalInputIterator(object):
    def __init__(self, batch_size):
        pass

    def __iter__(self):
        self.i = 0
        self.n = 1
        return self

    def __next__(self):
        return [np.frombuffer(open('black.hevc', 'rb').read(), dtype=np.uint8)]
import nvidia.dali as dali
from nvidia.dali import fn
import nvidia.dali.types as types
eii = ExternalInputIterator(1)
@dali.pipeline_def(batch_size=256, num_threads=12, device_id=0)
def i_pipeline():
    vid = fn.external_source(source=eii, device="cpu", name="INPUT_0", ndim=1, dtype=dali.types.UINT8)
    seq = fn.experimental.decoders.video(vid, device='mixed')
    return seq
pipe = i_pipeline()
pipe.build()
pipe.run()

Changing black.hevc to other regular HEVC encoded video with MP4 container, the above code runs successfully.

The sample raw HEVC is generated by code:

import av
import numpy as np
c = av.open('black.hevc', 'w', format='hevc')
s = c.add_stream(codec_name='libx265', rate=1)
s.pix_fmt='gray'
s.height, s.width = [300, 300]
for i in range(10):
    f = av.VideoFrame.from_ndarray(np.zeros((300, 300), dtype=np.uint8),format="gray8")
    for p in s.encode(f):
        c.mux(p)
for p in s.encode():
    c.mux(p)
c.close()
@jantonguirao jantonguirao self-assigned this Nov 30, 2022
@JanuszL JanuszL added the bug Something isn't working label Nov 30, 2022
@JanuszL JanuszL assigned awolant and unassigned jantonguirao Nov 30, 2022
@JanuszL
Copy link
Contributor

JanuszL commented Nov 30, 2022

Hi @zeruniverse,

Thank you for reporting this problem. We are aware of it (that DALI cannot properly handle raw video files as it needs to seek to the beginning) and working hard to resolve it.
We will keep you posted.

@zeruniverse
Copy link
Author

Thanks @JanuszL Please let me know when it is resolved.

@JanuszL JanuszL added the enhancement New feature or request label Dec 1, 2022
@JanuszL
Copy link
Contributor

JanuszL commented Dec 1, 2022

#4480 should improve the decoding of the video files that are raw streams not packed inside any specific container. Still, this particular video will not work as described in #4483 until a CPU fallback is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

4 participants