wisdomikezogwo / quilt1m

[NeurIPS 2023 Oral] Quilt-1M: One Million Image-Text Pairs for Histopathology.
https://quilt1m.github.io/
MIT License
138 stars 8 forks source link

Video and Frames Download #6

Closed vinid closed 1 year ago

vinid commented 1 year ago

Hi again :)

do you have any code you can share for downloading the videos?

Thank you so much! I appreciate your help on this!

wisdomikezogwo commented 1 year ago

It's no problem, however, I'm not sure I can share that.

I could, however, refer you to the same package we used in downloading videos called yt_dlp: https://github.com/yt-dlp/yt-dlp

I hope this is helpful, a possible config for low resolution or high resolution video download can be like this:

def get_ydl_opts(video_dir, archive=False, info=True, subtitle=True, low_res=False):
    if not low_res:
        return {
            'ignoreerrors': True,
            'format': "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b",
            "outtmpl": f'{video_dir}/%(channel)s/%(id)s___%(title)s.%(ext)s',
            "writesubtitles": subtitle,
            "writeautomaticsub": subtitle,
            "subtitlesformat": 'srt',
            "writedescription": info,
            "writeinfojson": info,
            "getcomments": info,
            "writeannotations": info,
            "overwrites": False,
            "download_archive": f'{video_dir}/archive.txt' if archive else None,
            "restrictfilenames": True,
        }
    else:
        return {
            'ignoreerrors': True,
            'format': "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b",
            'format_sort': ["+res:320"],
            "outtmpl": f'{video_dir}/%(channel)s/%(id)s___%(title)s.%(ext)s',
            "writesubtitles": subtitle,
            "writeautomaticsub": subtitle,
            "subtitlesformat": 'srt',
            "writedescription": info,
            "writeinfojson": info,
            "getcomments": info,
            "writeannotations": info,
            "overwrites": False,
            "download_archive": f'{video_dir}/archive.txt' if archive else None,
            "restrictfilenames": True,
        }
wisdomikezogwo commented 1 year ago

Again, let me know if you have any issues reconstructing Quilt!