def valid_video()

in datasets/AVideoDataset.py [0:0]


def valid_video(vid_idx, vid_path, decode_audio, num_sec):
    try:
        probe = ffmpeg.probe(vid_path)
        video_stream = next((
            stream for stream in probe['streams'] if stream['codec_type'] == 'video'), 
            None
        )
        if decode_audio:
            audio_stream = next((
                stream for stream in probe['streams'] if stream['codec_type'] == 'audio'), 
                None
            )
            if audio_stream and video_stream and float(video_stream['duration']) > num_sec and float(audio_stream['duration']) > num_sec:
                print(f"{vid_idx}: True", flush=True)
                return True
            else:
                print(f"{vid_idx}: False (duration short/ no audio)", flush=True)
                return False
        else:
            if video_stream and float(video_stream['duration']) > num_sec:
                print(f"{vid_idx}: True", flush=True)
                return True
            else:
                print(f"{vid_idx}: False (duration short/ no audio)", flush=True)
                return False
    except:
        print(f"{vid_idx}: False", flush=True)
        return False