- Buffer Videos
- Download Videos
- Inspect Video File Metadata
- Downscale Video to 720p mp4
- Clip Video
- Transcode mkv into standard mp4 for smart TVs to play
Install the extension and then just click the extension when on a web page.
It'll replace the video placer with a custom one that buffers.
Install yt-dlp
to download, and ffmpeg for conversions:
brew install yt-dlp ffmpeg
There's a long list of extractors for different sites:
yt-dlp --list-extractors
but it even works on even sites for which there aren't special extractors.
Show available download formats:
yt-dlp -F "$url"
You can then choose the format quality you want:
yt-dlp -f "$format_id" "$url"
If you get an error like this:
ERROR: [youtube] ...: Sign in to confirm you’re not a bot.
You can add this switch with your browser to use its cookies:
--cookies-from-browser chrome
Use script from DevOps-Bash-tools repo to simplify downloading with maximum quality and compatibility, with continue and no overwrite settings.
This script has symlinks for X/Twitter and Facebook too as it can download from those sites and should also work for all
those listed by the above command of yt-dlp --list-extractors
:
youtube_download_video.sh "$url"
These are just symlinks for convenience:
x_download_video.sh "$url"
twitter_download_video.sh "$url"
facebook_download_video.sh "$url"
The script will even attempt to install yt-dlp
and ffmpeg
prerequisites if not already installed.
If you get an error like this:
ERROR: [youtube] ...: Sign in to confirm you’re not a bot.
then export this:
export YT_DLP_COOKIES_FROM_BROWSER=chrome
and re-run the script, which will then use the switch --cookies-from-browser chrome
.
The yt-dlp
tool works really well for extracting the video from many different web pages, but
if it fails to parse the page, there is a workaround:
- Open Chrome Developer Tools or similar network request tracing
- Click to play the video
- Record the
m3u8
url from the Network section - Pass the
m3u8
url to the script - sinceyt-dlp
will infer the filename from the m3u8 filename, you'll likely want to pass a second argument to the script for the real filename eg.Some Video.mp4
youtube_download_video.sh "https://.../index.m3u8" "Some Video.mp4"
Using DevOps-Bash-tools repo:
youtube_download_channel.sh "$url"
ffprobe "$file"
If you just want to see whether a video is 480p or 720p or 1080p etc:
ffprobe "$file" 2>&1 | grep 'Stream.*Video'
exiftool "$file"
mediainfo "$file"
mediainfo --fullscan "$file"
avprobe "$file"
mplayer -vo null -ao null -identify -frames 0 "$file"
tovid id "$file"
ffmpeg -i "$file"
or
ffprobe "$file"
Useful to make good trade-off of quality vs size for social media posting.
Using DevOps-Bash-tools repo:
video_to_720p_mp4 "$file"
If the video is less than this resolution already, it'll do nothing.
Quickly clip a video on Mac using QuickTime Player:
open -a "QuickTime Player" "$file"
Then press shortcut Cmd
+ T
or click Edit
-> Trim
to bring up a slider to drag and then save the resulting clip as a new file.
Create a clip from a video file using ffmpeg
args:
-ss <offset>
and-to <duration>
where duration is integer seconds orHH:MM:SS
format-c copy
--c
specifies codec,copy
is quick and cheap codec compared to transcoding
ffmpeg -i input_vid.mp4 -ss 00:08:35.0 -t 72 -c copy output_vid.mp4
or using time format -to 00:01:12
which is the same as 72 seconds from offset start.
ffmpeg -i "input.mkv" "output.mp4"
There is an automated script in the DevOps-Bash-tools repo's media/
directory to iterate many files easily:
mkv_to_mp4.sh *.mkv
or find all mkv files recursively under the given directory and convert them (retains originals), in this case the $pwd
denoted by a dot:
mkv_to_mp4.sh .