NVIDIA DALI : unable to load videos using readers.video in NVIDIA DALI pipeline

613 Views Asked by At

Trying to load the video for NVIDIA DALI pipeline for video processing but not able to load the .mp4 video.

import os
import numpy as np    
from nvidia.dali import pipeline_def
import nvidia.dali.fn as fn
import nvidia.dali.types as types       

batch_size=2
sequence_length=8
initial_prefetch_size=16 

video_directory=['sintel_trailer-720p_0.mp4']
n_iter=6

print(video_directory)


@pipeline_def
def video_pipe(file_root):
    video, labels = fn.readers.video(device="gpu", file_root=file_root, sequence_length=sequence_length,
                                     random_shuffle=True, initial_fill=initial_prefetch_size)
    return video, labels


pipe = video_pipe(batch_size=batch_size, num_threads=2, device_id=0, file_root=video_directory, seed=12345)
pipe.build()

Above DALI pipeline shows the following issue while loading the video:

RuntimeError: Critical error when building pipeline: Error when constructing operator: readers__Video encountered: [/opt/dali/dali/operators/reader/loader/video_loader.cc:117] Assert on "dir != nullptr" failed: Directory ['sintel_trailer-720p_0.mp4'] could not be opened.

I have referred the documentation from NVIDIA DALI for video processing but not to able solve,

Please check for reference : NVIDIA DALI DOCS VIDEO PROCESSING

2

There are 2 best solutions below

0
Marek Wawrzos On

The file_root argument points to the root directory, where DALI should search for videos, and the file_list argument should point to a file listing all samples to be loaded.

However, from your example, the filenames argument must be the one that suits your needs better.

Your example should work as expected, with the following pipeline definition:

@pipeline_def
def video_pipe(file_root):
    video, labels = fn.readers.video(device="gpu", filenames=file_root, labels=[], sequence_length=sequence_length,
                                     random_shuffle=True, initial_fill=initial_prefetch_size)
    return video, labels

I added the labels argument too. Without it, the operator returns just one output. Please see the DALI manual if you want to understand the operator better.

0
Abhijit Manepatil On

After some research and forum discussion from NVIDIA DALI got this Answer, Please refer to issues/3503 the link for a detailed answer discussion. Thank you