Skip to content

Instantly share code, notes, and snippets.

@pgram1
Created December 9, 2022 13:52
Show Gist options
  • Save pgram1/866f3eb344927a8f9c6bd82097dbee60 to your computer and use it in GitHub Desktop.
Save pgram1/866f3eb344927a8f9c6bd82097dbee60 to your computer and use it in GitHub Desktop.
Tips on acquiring and handling media

FFmpeg

FFmpeg is a utility that handles almost all multimedia formats that exist. It is usually the program that is used behind all the options of media-editing and management software. It is also used in automations like the one Google uses when we upload our videos and they convert them to all the alternative qualities.

An extensive tutorial is located here: https://img.ly/blog/ultimate-guide-to-ffmpeg/

yt-dlp

yt-dlp is a utility that can be used as an easy method to acquire media from the internet. It supports many different websites

VLC

A player that plays almost all formats of media files, get it from here: https://www.videolan.org/vlc/

Instructions

Create a folder, where ffmpeg and yt-dlp will be.

After that you will need to download the Windows versions of both of these utilities from the following places (the links might change, so I am explaining the process):

FFmpeg (pick the windows logo, then "Windows builds from gyan.dev", then "ffmpeg-git-full.7z". Extract all the .exe programs from the bin folder using 7-zip or whatever archive tool that supports 7z)

yt-dlp (go to the bottom in assets and get yt-dlp.exe, which is the 64 bit version so it's faster)

You should now have ffmpeg.exe,ffprobe.exe,ffplay.exe and yt-dlp.exe. Move those in that folder you created.

Copy the path of the folder from the top bar.

press windowskey+R and type systempropertiesadvanced

Go to environment variables

At the bottom area, find and edit the PATH variable. Add the path of the folder that you copied earlier in there and save. Now you will be able to run ffmpeg and yt-dlp from anywhere in the system.

Let's test this!

Press windowskey+R and type cmd

This will start a console session. It should be at the top of your user folder by default. Write cd Downloads to change directory to Downloads

Now, try downloading a video from youtube like so: yt-dlp "https://www.youtube.com/watch?v=g3jOJfrOknA". yt-dlp without any options downloads the best quality format of the media it finds on a page. The video will automatically download in your Downloads folder.

You can learn more option flags that you can use with yt-dlp by writing yt-dlp --help. Most used flags are:

yt-dlp -F [link]

(finds and lists all formats of the media on a page, with IDs first which you can use with -f)

yt-dlp -f videoFormatID+audioFormatID [link]

(downloads the specific formats you requested, video must always be first when you download both video and audio)

I personally use -N 100 --cookies-from-browser firefox a lot, so that yt-dlp logs in with my youtube profile to bypass age restrictions and also downloads videos faster with maxed out connection requests (100 is way above the maximum youtube allows).

Now that you downloaded the video, let's do some basic things to it (check ffmpeg tutorial above!):

ffmpeg -i videonamehere.formathere resultvideonamehere.resultformathere

-i is a media input, you can combine many -is in a row, but now we only have a videofile as an input. Let's convert the video to an mp3 file to only keep the audio!

You can use TAB to autocomplete file and folder names, press it multiple times to be shown many options.

ffmpeg -i videotitle.videoformat out.mp3

now out.mp3 is the audio extracted from the video. FFmpeg by default tries to pick the best options for what you are trying to do automatically, so you maintain the best quality and least filesize possible between conversions. Keep in mind that many conversions always result in a loss of quality.

Go through the whole tutorial for way more interesting things! The most useful thing I do with FFmpeg is trimming media fast, without a long conversion: https://img.ly/blog/ultimate-guide-to-ffmpeg/#editing-without-reencoding

Also keep in mind that MKV is a container that can represent any combination of media formats, so when in doubt just use MKV!

Final tip, MPV is an advanced media player that can be used from the console as well. You find, download and install it and add it to the PATH similarly to ffmpeg and yt-dlp. The combination of those 3 is literally all you need for media editing and previewing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment