I know this thread isn't active but it's useful. Not sure how much of this has already been covered in other posts as I've not read through everything in the thread, but here are my bookmarks and notes for the most common tasks with ffmpeg for clipping or altering content. Note this is all windows pseudocode and you will need to test it yourself, DM me if you have questions.
simple clipping from timestamps
in my opinion the best method is using the -ss and -to flags to tell ffmpeg the timeframes to clip. This is a slower process than other methods but it ensures the video playback is smooth and does not have keyframe issues:
Code:
./ffmpeg.exe -i input.mp4 -ss 00:01:00 output.mp4
./ffmpeg.exe -i input.mp4 -ss 00:01:00 -to 00:02:00.999 output.mp4
./ffmpeg.exe -i input.mp4 -to 00:02:00.999 output.mp4
the first example will clip from 1 minute to the end of the video, the second will clip from 1min to 2m and 999ms, the last from the start of the video to 2m and 999ms
clipping from timestamps using a URL without full archive download
this site covers this case in good detail:
https://ostechnix.com/download-a-portion-of-youtube-video-with-youtube-dl-and-ffmpeg/
you have to use yt-dlp or youtube-dl in tandem with ffmpeg like so
Code:
./yt-dlp --external-downloader ./ffmpeg.exe --external-downloader-args "-ss 00:01:00.00 -to 00:02:00.00" -f best "<URL>"
note that there can sometimes be issues with the way this works due to how the video stream is processed and if the process hangs for a long time you should simply download the full video/stream and manually clip the timestamps
this can also be confusing on windows when first doing it based on executable file locations depending on your workspace, DM me or post here and I can explain
downsizing a video
the -s flag tells ffmpeg what resolution it should convert the video to:
Code:
./ffmpeg.exe -i input720p.mp4 -s hd480 output480p.mp4
converting from a 720 to 480 video. there are more options than just hd480:
http://underpop.online.fr/f/ffmpeg/help/video-size.htm.gz
there's a lot more about resizing videos that i dont know, maybe start here:
https://trac.ffmpeg.org/wiki/Encode/H.264
reducing quality for disk space/upload limits (KF has a 200MB upload limit you will hit one day)
just read this and figure out your favorite method that works with what you need to achieve, there is no one-size-fits-all option for reducing quality. some days you need to preserve pixels for chat and others you dont:
https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg
simple method for stitching videos together
this has a number of options:
https://stackoverflow.com/questions...-two-mp4-files-using-ffmpeg/11175851#11175851
this is my simple method when both sources are the same resolution:
Code:
./ffmpeg.exe -i input1.mp4 -i input2.mp4 -filter_complex "concat=n=2:a=1:v=1" output.mp4
if you get "1000 frames dropped" stop it and add "-vsync 2"
if you get errors because the videos have wildly different encodings then one method to get it working is re-encoding all videos to the same preset and then concating using the -s <preset> method on
this page again. open to hearing more elegant solutions because I don't often do this.
cc:
@Wendy's Chili @GaryGray and
@Temperance XIV