0

When I use youtube-dl, I use --recode-video mp4 to ensure output to MP4 (as well as -f bestvideo[height<=1080]+bestaudio/best[height<=1080]/best to limit downloads to 1080p resolution, max). So, videos I download from YouTube are usually transcoded via ffmpeg (I’m not enough of a an A/V person to know if the video track itself is being converted, or just being muxed into a new container format, but I can say it takes a while) before ending up as MP4.

I can also say that the resulting videos are enormous. Fifteen-minute videos, even simple ones that should compress well, are often many hundreds of megabytes. I suppose this is the level of quality YouTube uses internally, which is fine, but when ffmpeg is already spending so much time post-processing each video I would hope I could do something like set a maximum bitrate for the resulting file so my hard drive doesn’t completely fill up with youtube-dl-downloaded videos. Any advice? (Again, I already know how to limit the resolution of videos downloaded.)

(Also, if I’m not mistaken, the --audio-quality setting does something like what I describe, but for audio; I’m looking for advice on the video side of things.)

3
  • 1
    What do you mean by "optimize"? YouTube will offer videos which are already pretty optimized in regard to 1. suitable for chunked transfer, 2. maximum compatibility and 3. as small as they can get with a decent quality. If you want even smaller files, you need so sacrifice quality when "recoding". Can you give a link to an example?
    – Hermann
    Commented May 26, 2021 at 23:14
  • Yeah, sacrificing some amount of quality during transcoding is what I was expecting. I guess I figured that YouTube’s way of doing things must be a bit bloated and there must be a way to have youtube-dl tell ffmpeg to make the video a bit more economical when transcoding, even at the same resolution (like the way JPEG encoding works, with its different levels of compression), Commented May 27, 2021 at 0:43
  • A 16:9 best video with a height of 1080 might mean producing almost HD quality. Commented May 28, 2021 at 0:22

1 Answer 1

1

This is a list of available formats for sample 15 minute video.

$ youtube-dl -F https://www.youtube.com/watch?v=ItR1ViLHeP4
 
[youtube] ItR1ViLHeP4: Downloading webpage
[info] Available formats for ItR1ViLHeP4:
format code  extension  resolution note
249          webm       audio only tiny   46k , webm_dash container, opus @ 46k (48000Hz), 5.25MiB
250          webm       audio only tiny   55k , webm_dash container, opus @ 55k (48000Hz), 6.27MiB
251          webm       audio only tiny  124k , webm_dash container, opus @124k (48000Hz), 14.15MiB
140          m4a        audio only tiny  127k , m4a_dash container, mp4a.40.2@127k (44100Hz), 14.47MiB
160          mp4        256x144    144p   81k , mp4_dash container, avc1.4d400c@  81k, 25fps, video only, 9.28MiB
278          webm       256x144    144p   84k , webm_dash container, vp9@  84k, 25fps, video only, 9.64MiB
242          webm       426x240    240p  169k , webm_dash container, vp9@ 169k, 25fps, video only, 19.26MiB
133          mp4        426x240    240p  170k , mp4_dash container, avc1.4d4015@ 170k, 25fps, video only, 19.38MiB
243          webm       640x360    360p  308k , webm_dash container, vp9@ 308k, 25fps, video only, 35.18MiB
134          mp4        640x360    360p  445k , mp4_dash container, avc1.4d401e@ 445k, 25fps, video only, 50.75MiB
244          webm       854x480    480p  563k , webm_dash container, vp9@ 563k, 25fps, video only, 64.19MiB
135          mp4        854x480    480p  842k , mp4_dash container, avc1.4d401e@ 842k, 25fps, video only, 95.99MiB
247          webm       1280x720   720p 1128k , webm_dash container, vp9@1128k, 25fps, video only, 128.56MiB
136          mp4        1280x720   720p 1634k , mp4_dash container, avc1.4d401f@1634k, 25fps, video only, 186.16MiB
248          webm       1920x1080  1080p 1993k , webm_dash container, vp9@1993k, 25fps, video only, 226.97MiB
137          mp4        1920x1080  1080p 3027k , mp4_dash container, avc1.640028@3027k, 25fps, video only, 344.79MiB
18           mp4        640x360    360p  611k , avc1.42001E, 25fps, mp4a.40.2 (44100Hz), 69.66MiB
22           mp4        1280x720   720p 1761k , avc1.64001F, 25fps, mp4a.40.2 (44100Hz) (best)

As you can see 1080p video takes ~350[MB]. You can compare your resulting video with format/s on YT and see whether there is any difference. My guess is there won't be much of a difference.

An advice to not fill out your disk would be to download less, either lower resolution or less in general, or get more storage. You can also get cheap mechanical hard drive where you can store all of this stuff. They are big and will fit tons of data. Speed is irrelevant here as to replay it one needs 0.4[MB/s].

2
  • Yeah, you’ve got a point. I downloaded that video with my usual options and the resulting file was 359.5 MiB; then I used ffmpeg manually to bring the bitrate down to 800k and while the file size was now 99.9 MiB, the video quality was quite noticeably sketchy. Now, that’s a video that wouldn’t compress super well under normal circumstances (constantly moving viewpoint, lots of tall grass, etc.), but even then I guess from the start I just wasn’t prepared for how big 1080p video file sizes are. Thanks for the help. Commented May 27, 2021 at 4:53
  • Glad to hear it and that I could help. If that answers your question you want to accept it.
    – tansy
    Commented May 27, 2021 at 9:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .