Last active
September 5, 2024 21:03
-
-
Save DoktorMike/b1033f3c64af0b3af17bb1478a658b7f to your computer and use it in GitHub Desktop.
Useful commands for converting videos using ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Examples taken from https://opensource.com/article/17/6/ffmpeg-convert-media-file-formats | |
# Convert a webm file to a matroska format with a vp9 encoding and keeping the same audio encoding. | |
# Also changes the bitrate to 1Mb/s | |
ffmpeg -i input.webm -c:a copy -c:v vp9 -b:v 1M output.mkv | |
# Same but change the frame rate to 30 FPS and dropping the bitrate conversion | |
ffmpeg -i input.webm -c:a copy -c:v vp9 -r 30 output.mkv | |
# Same but only setting the video size to a predetermined format HD 720 in this case | |
ffmpeg -i input.mkv -c:a copy -s hd720 output.mkv | |
# Same but sets the size explicitely | |
ffmpeg -i input.mkv -c:a copy -s 1280x720 output.mkv | |
# This cuts 10 seconds away from the original movie starting at 00:01:00, i.e., after one minute. | |
ffmpeg -i input.mkv -c:av copy -ss 00:01:00 -t 10 output.mkv | |
# The "-vn / -an / -sn / -dn" options can be used to skip inclusion of | |
# video, audio, subtitle and data streams respectively | |
# Remove the video stream from a mkv file and save the remaining streams as an ogg | |
ffmpeg -i input.mkv -vn audio_only.ogg | |
# Remove the audio from a mkv file and save it as an mkv | |
ffmpeg -i input.mkv -an video_only.mkv | |
# Remove the subtitles from a mkv file and save it as an mkv | |
ffmpeg -i input.mkv -sn audio_only.mkv | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment