iejMac / video2dataset

Easily create large video dataset from video urls
MIT License
533 stars 65 forks source link

AttributeError: `ResolutionSubsampler` object has no attribute `encode_formats` #263

Closed SCZwangxiao closed 8 months ago

SCZwangxiao commented 11 months ago

Bug descriptions

I am using the following config:

subsampling:
    ResolutionSubsampler:
        args:
            video_size: 224
            resize_mode: "scale"
    # FrameSubsampler:
    #     args:
    #        frame_rate: 5
    # ClippingSubsampler:
    #     args:
    #         min_length: 4.0
    #         max_length: 30.0
    #         max_length_strategy: "all"
    #         precision: "keyframe_adjusted"
    # FFProbeSubsampler:
    #     args:
    #         extract_keyframes: False

reading:
    yt_args:
        download_size: 360
        download_audio_rate: 44100
        yt_metadata_args:
            writesubtitles:  True
            subtitleslangs: ['en']
            writeautomaticsub: True
            get_info: True
    timeout: 60
    sampler: null

I got the following errors:

shard /mmu_nlp_ssd/wangxiao24/internvid/InternVid-10M-FLT_sub/_tmp/3.feather failed with error 'ResolutionSubsampler' object has no attribute 'encode_formats'
Traceback (most recent call last):
  File "/mmu_nlp_ssd/wangxiao24/internvid/video2dataset/video2dataset/workers/download_worker.py", line 102, in __call__
    self.download_shard(row)
  File "/mmu_nlp_ssd/wangxiao24/internvid/video2dataset/video2dataset/workers/download_worker.py", line 161, in download_shard
    writer_encode_formats["video"] = self.subsamplers["video"][0].encode_formats["video"]
AttributeError: 'ResolutionSubsampler' object has no attribute 'encode_formats'

Primary analysis

The errors come from the following code:

# The subsamplers might change the output format, so we need to update the writer
        writer_encode_formats = self.encode_formats.copy()
        if self.subsamplers["audio"]:
            writer_encode_formats["audio"] = self.subsamplers["audio"][0].encode_formats["audio"]
        if self.subsamplers["video"]:
            writer_encode_formats["video"] = self.subsamplers["video"][0].encode_formats["video"]

I cannot understand the meaning of these codes, specifically why The subsamplers might change the output format.

MattUnderscoreZhang commented 8 months ago

I have the same issue.

It appears to have been introduced in the commit on October 05: https://github.com/iejMac/video2dataset/commit/351decc182449bcd3e11a5e04bb21d89784e119d