FFMPEG Tips and Tricks - Questions and suggestions about this video editing tool

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
Lot of kvetching in that thread.

kieran_kunhya_enjoys_cocks_in_his_anus.png

What a fag.
 
I have been fooling around with ffmpeg some more and found that instead of what I think is the more common "-loop 1" input flags that you apply to an image, you can use the tpad video filter (stop=-1 stop_mode=clone). In my testing this rendered faster than using -loop 1, especially if you add the "framerate=fps=1" filter.

Bash:
ffmpeg -i INPUT.png -i AUDIO.wav -filter_complex "[0:v:0]format=pix_fmts=yuv420p,framerate=fps=1,tpad=stop=-1:stop_mode=clone" -preset:v ultrafast -tune:v stillimage -c:a copy -shortest -y OUTPUT.mkv

Another fun thing I discovered is that the Matroska container (.mkv) supports lossless WAV/FLAC audio (aka using pcm_ codecs in ffmpeg), and youtube supports this as well, so you can upload your video with no compression on your part and let youtube handle it (the filesize will be a few megabytes larger than the original wav file was, so be mindful if you have slow upload speed).
 
  • Informative
Reactions: Smaug's Smokey Hole
Anyone here knows how to download Youtube videos at 2x speed (or 1.25, 1.5, and so on)?

It could be handy for videos where the idiot talking takes forever to utter sentences.
 
  • Thunk-Provoking
Reactions: Smaug's Smokey Hole
Anyone here knows how to download Youtube videos at 2x speed (or 1.25, 1.5, and so on)?

It could be handy for videos where the idiot talking takes forever to utter sentences.
There's no way to download a video at a different speed than the original from Youtube because Youtube doesn't encode separate versions of each video at different speeds. They just allow you to change the playback speed in the video player, which causes the player to play the same video but at a different rate.

If you want to speed up or slow down a video with FFmpeg, try the methods on this page.
 
Anyone here knows how to download Youtube videos at 2x speed (or 1.25, 1.5, and so on)?

It could be handy for videos where the idiot talking takes forever to utter sentences.
VLC can do it and it sounds fine. Under Playback there's "speed", increase it there. "Speed up (fine)" increase it incrementally by 10%, it can probably be bound to a convenient key. VLC is also available on mobile, so there's that as well.

MPC can also speed up video but it doubles the speed with one click and that's way too much, I'm not sure if that can be tweaked or not. As much as VLC annoys me it is the way superior option for this.
 
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
 
Last edited:
This is more likely a yt-dlp or rtmpdump issue, but here's the closest I could find. I've downloaded shows from WFMU.org before, but that was then and this is [CURRENT YEAR], where the direct mp3 links are gone and they're using a Flash player. And that works to stream, but ytp-dl fails both with the regular URL


and the direct RTMP link

rtmp://rtmp.wfmu.org/cfx/st/mp4:MS/ms081023.mp4

(I had to fix the second link because the source says 'rtmpt://') The audio data is there somewhere on a server, but rtmpdump can't connect to the RTMP server. Running 'lsof -i' to see my browser's connections, the one I want is probably one of the IP addresses without a name. Boy do I miss the days when all you had to do was go into your browser's temp directory and you'd find all the shit they were trying so desperately to keep us plebs from getting our grubby little hands on. Anyway, there's where my expertise ends and patience dies - would greatly appreciate any assistance and/or advice.
 
This is more likely a yt-dlp or rtmpdump issue, but here's the closest I could find. I've downloaded shows from WFMU.org before, but that was then and this is [CURRENT YEAR], where the direct mp3 links are gone and they're using a Flash player. And that works to stream, but ytp-dl fails both with the regular URL


and the direct RTMP link

rtmp://rtmp.wfmu.org/cfx/st/mp4:MS/ms081023.mp4

(I had to fix the second link because the source says 'rtmpt://') The audio data is there somewhere on a server, but rtmpdump can't connect to the RTMP server. Running 'lsof -i' to see my browser's connections, the one I want is probably one of the IP addresses without a name. Boy do I miss the days when all you had to do was go into your browser's temp directory and you'd find all the shit they were trying so desperately to keep us plebs from getting our grubby little hands on. Anyway, there's where my expertise ends and patience dies - would greatly appreciate any assistance and/or advice.
RTMPT is a thing, no need to fix anything. The Flash player seems to be a legacy holdover for whoever is listening to this with IE6. I've tried to rtmpdump that link directly, but it refuses the connection. Probably needs a cookie or something. There's an alternative URL in the HTML data that is most likely served to you as well, use the browser's dev tools to spot that. It's in the same embedded JSON blob as the RTMPT part, but it needs to be reconstructed into a full URL which is why yt-dlp's generic extractor chokes. Look for mp4_server. The full URL would then be https + contents of mp4_server + whatever is past "mp4:" in the Flash player stream. In this case, it would be https://s3.amazonaws.com/arch.wfmu.org/MS/ms081023.mp4.
 
  • Informative
Reactions: Fabio Socialist
Making an animated WEBP image from a video using FFMPEG.
In this example the start point is 120 seconds into the video for a duration of 8 seconds, 15 frames per second, horizontal resolution of 400 pixels and infinite loop (set to 0).


ffmpeg -ss 120 -t 8 -i input.mp4 -vf "fps=15,scale=400:-1:flags=lanczos" -vcodec libwebp -lossless 0 -compression_level 6 -q:v 60 -loop 0 -preset picture -an -vsync 0 output.webp
 
  • Agree
Reactions: seri0us
Back