mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
12.06k stars 982 forks source link

Implement ffprobe as an additional metadata filter option #4928

Open Skaronator opened 11 months ago

Skaronator commented 11 months ago

Filtering out videos based on video format, resolution, or duration is currently not possible without downloading the full video file and doing the filtering in the postprocessor/output stage.

I recently learned that you can use ffprobe to figure out the metadata of a video without actually downloading the full thing. That's how your browser also knows how long a video (for the video timeline) is without downloading it completely.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://c5.coomer.su/data/xy.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:08:23.59, start: 0.000000, bitrate: 1212 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1013 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]

This gives us: Duration, Resolution, Framerate, Video-Ratio, Bitrate, Video and Audio format, Audio channel (stereo) and much more.

Similar to extractor.*.image-filter we could have a extractor.*.video-filter that does ffprobe in the background and provides all these fields for the filter string.

What do you think?

Skaronator commented 11 months ago

I'll drop a 75€ bounty for whoever implements this in gallery-dl and get merged within the next 6 months.