Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
September 06, 2026 - @75.46
Activity rating: Four Stars Posts & Arts: 51/1k.beats ~ Boop! The forum will close in 925.beats! Random | Recent Posts | Guild Recents
News: :sleep: These are fast times on the World Wide Web~ Guild Events: 10: window

+  MelonLand Forum
|-+  Projects & Art
| |-+  ⛽︎ ∙ Technology & Archiving
| | |-+  cool ffmpeg tricks


« previous next »
Pages: [1] Print Embed
Author Topic: cool ffmpeg tricks  (Read 665 times)
purpleraindrip
Newbie ⚓︎
*
View Profile WWW


meow meow meow
⛺︎ My Room

Guild Memberships:
Artifacts:
Joined 2026!
« on: August 07, 2026 @79.48 » Embed

I've recently found myself just converting files in command line using ffmpeg than having to open up adobe media encoder. It's just easier than opening up a whole ass app.

you can do it like this:
ffmpeg -i [input].[fileformat] [output].[fileformat]

of course it looks a lot different without the brackets. You also need to be in the right path

c:\users\person\downloads ffmpeg -i video.mov video2.mp4

like that. I also think it's really fun to compress video and audio cause the crunch is beautiful. so far I know how to mess with resolution, bitrate, and audio sample rate. it's like this

RESOLUTION
ffmpeg -i video.mp4 -vf scale=[width]:[height] video2.mp4

BITRATE
ffmpeg -i video.mp4 -b [desired data rate] video2.mp4
(you can also specify if you want to change the bitrate of the video or audio using -b:v or -b:a)
(also data rate is in thousands, example: 800k you gotta write it like that)

SAMPLE RATE
ffmpeg -i video.mp4 -ar [desired sample rate] video2.mp4
(while the bitrate will make the audio more compressed. for that real nice audio crunch you gotta bring down the sample rate. lowest is 8000 i think)

but yeah. those are all the ones that I know. But if anyone else knows any fun things to mess with using ffmpeg please reply! It's really fun making videos rly compressed and shitty and also it makes it easier to send shit to people on discord or apps with a file size limit. enjoy :D

Logged

:D :] ;P :L :I doot doot lalala~~~
Melooon
Hero Member ⚓︎
*****
View Profile WWWArt


So many stars!
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Wavy Shoulder-Length Hair with BangsTop HatBug!You're a Star!Flinstone VitaminI got robbed by Dan Q on Melonland!
« Reply #1 on: August 07, 2026 @100.68 » Embed

Here's a script I've not messed with in years but I made this video with it:

The idea was to have a folder with 100s of videos in it, the script them splits all those videos into individual frames, then recombine them into a single tiled montage of all the videos playing at once. I also got carried away and started using ImageMagick to rotate each frame a little each time, so you get the tiles spinning while the montage plays!

So you put your videos in the VIDEOS folder names 1.mp4 2.mp4 etc, it'll dump the frames into FRAMES, then process them!  :ozwomp:

Code
#!/bin/bash

# Warning videos must have number names like 1.mp4 or it wont work
VIDEOS=./videos/*
FRAMES=./frames
SORTEDFRAMES=./sortedframes
MONTAGES=./montages
FRAMECOUNT=2000				#how many frames to process must be less than limit
FRAMERATE=24					#force framerate on videos
PLAYBACKSPEED=10

mkdir -p $FRAMES
mkdir -p $SORTEDFRAMES
mkdir -p $MONTAGES

for path in $VIDEOS
do
  file=$(basename ${path})
  ffmpeg -i "$path" -r $FRAMERATE -vframes $FRAMECOUNT $FRAMES/$file-%04d.png
done

for (( f=0 ; f<=$FRAMECOUNT ; f++ ))
do
	padded_count=$(printf "%04d" $f)
	for file in $FRAMES/*-$padded_count.png
	do
		mkdir -p $SORTEDFRAMES/$padded_count
		mv "$file" $SORTEDFRAMES/$padded_count/$(basename ${$file})
	done
done

ROTATEDEG=0

for (( i=1 ; i<=$FRAMECOUNT ; i++ ))
do
	padded_count=$(printf "%04d" $i)
  	echo $padded_count
	  # 20x10 96px fits EXACTLY 200 on a 1080p screen at around 3cm at 27" - 10x20 is vertical
  	magick montage "$SORTEDFRAMES/$padded_count/*" -geometry 96x96\!+0+0 -tile 10x20 -rotate $ROTATEDEG -background black -bordercolor black -mattecolor black $MONTAGES/$i.jpg
	#magick montage "$SORTEDFRAMES/$padded_count/*" -geometry 96x96\!+0+0 -tile 10x20 -background black -bordercolor black -mattecolor black $MONTAGES/$i.jpg

	# image rotation
	ROTATEDEG=$(($ROTATEDEG+1))
	if [ $ROTATEDEG -ge $((361)) ]
	then
		ROTATEDEG=0
	fi
done

convert -delay $((100/$PLAYBACKSPEED)) $MONTAGES/*.png -quality 100 final.mp4

Logged


everything lost will be recovered, when you drift into the arms of the undiscovered

Artifact Swap: Have a chillpillMove it, football head!black n orange yappin kittayRed Tulip100 coinsLurbyxDeyntivemds pet fishGreen partyhatPlankGo dig, girl!Maya's Magatama
Seechain
Casual Poster ⚓︎
*
View Profile WWW


⛺︎ My Room
Itch.io: My Games

Artifacts:
Joined 2026!
« Reply #2 on: August 07, 2026 @162.27 » Embed

ffmpeg is awesome. A while ago, I started converting reels to GIFs using this command.  :ok:

Code
ffmpeg -i reel.mp4 -vf "fps=12,scale=200:-1:flags=lanczos" reel.gif

https://i.imgur.com/eEFnAkH.gif

Logged

mrparker
Jr. Member ⚓︎
**
View Profile WWW

⛺︎ My Room

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!lighthouse keeper artemisUserJoined 2026!
« Reply #3 on: August 07, 2026 @263.85 » Embed

ffmpeg is awesome. A while ago, I started converting reels to GIFs using this command.  :ok:

Code
ffmpeg -i reel.mp4 -vf "fps=12,scale=200:-1:flags=lanczos" reel.gif

https://i.imgur.com/eEFnAkH.gif

I just want to say - the arguments on this command specifically can lower the FPS, scale the result down to a smaller size than the original (or, unintentionally upscale the output), and then apply lanczos resampling - depending on the source, this can all result in a larger size than the original in some instances! Use no options by default - or use scaling only, and add more as you see fit if performance (size, encoding/format) is your goal.

To prevent upscaling entirely, you can modify the above to be similar to this:

Code
ffmpeg -i reel.mp4 -vf "scale='min(200,iw)':-1" reel.gif

The parameters in the scale flag are specifically width:height. Read more in the official documentation here: https://trac.ffmpeg.org/wiki/Scaling

This specifically keeps the aspect ratio when resizing the width to 200px - which is why for the height parameter in this example we set it to -1 - which tells ffmpeg to keep the original value for the height from the original file.

The iw/ih variables in the min() function specifically applies to the initial height/width of the source - read it as
Code
[i]nitial [w]idth / [i]nitial [h]eight

This basically tells ffmpeg "Hey - only if the original is wider/taller than 200px, shrink it to 200px".

Like for width, the same can be done for the height parameter, too:

Code
ffmpeg -i reel.mp4 -vf "scale=-1:'min(200,ih)'" reel.gif

Instead of iw for width, for height we use ih instead.

Keep in mind as well, mp4 in a lot of cases is smaller for web applications, which is why a lot of the time "gifs" are actually mp4 files - you can loop mp4 videos in raw HTML, and even save more space by removing audio tracks - so that way the file is smaller and downloads faster (also add the attribute to mute the video just in case the user agent relies on that for autoplay).

If you still want to use an image format - apng, webp, avif all allow additional frames - sometimes compresses better and looks better than gif - resembling more of the original file! Try a mix and match of all - and keep whichever is smaller!

Of course, nothing wrong with doing what you want - just letting people know other options exist, just in case it matters at all. The gif format provides an aesthetic that it's known for - but the other file formats with the right parameters can replicate it, too - so even then you don't need to limit yourself to gif.

« Last Edit: August 07, 2026 @265.91 by mrparker » Logged
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
Artifacts:
Dan Q Cruisin'I DIDN'T meet Dan Q on Melonland!Visited on Melon's 10th Anniversary!
« Reply #4 on: August 07, 2026 @325.39 » Embed

If anybody's looking for a better media encoder but isn't yet willing to teach themselves ffmpeg, can I swoop in and recommend Handbrake. It's free, open source, multiplatform, and basically backs onto ffmpeg under the hood.

I find it useful because I've got a handful of common output scenarios I use so I can have them saved as Handbrake presets and just drag files in. I use ffmpeg as well, but sometimes you just want a lazy GUI approach, y'know?

Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif

Artifact Swap: PolyamorousI met Dan Q on Melonland!Joined 2025!
Seechain
Casual Poster ⚓︎
*
View Profile WWW


⛺︎ My Room
Itch.io: My Games

Artifacts:
Joined 2026!
« Reply #5 on: August 07, 2026 @570.68 » Embed

I just want to say - the arguments on this command specifically can lower the FPS, scale the result down to a smaller size than the original (or, unintentionally upscale the output), and then apply lanczos resampling - depending on the source, this can all result in a larger size than the original in some instances! Use no options by default - or use scaling only, and add more as you see fit if performance (size, encoding/format) is your goal.

To prevent upscaling entirely, you can modify the above to be similar to this:

Code
ffmpeg -i reel.mp4 -vf "scale='min(200,iw)':-1" reel.gif



I love this, it's like sorcery, and every spell has room for improvement. :wizard:




Logged

mrparker
Jr. Member ⚓︎
**
View Profile WWW

⛺︎ My Room

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!lighthouse keeper artemisUserJoined 2026!
« Reply #6 on: August 07, 2026 @841.09 » Embed

If anybody's looking for a better media encoder but isn't yet willing to teach themselves ffmpeg, can I swoop in and recommend Handbrake. It's free, open source, multiplatform, and basically backs onto ffmpeg under the hood.

I find it useful because I've got a handful of common output scenarios I use so I can have them saved as Handbrake presets and just drag files in. I use ffmpeg as well, but sometimes you just want a lazy GUI approach, y'know?


Oh yeah, this is also great if you have movies you want to re-encode for things like jellyfin (or plex - if you have money).

Logged
purpleraindrip
Newbie ⚓︎
*
View Profile WWW


meow meow meow
⛺︎ My Room

Guild Memberships:
Artifacts:
Joined 2026!
« Reply #7 on: August 08, 2026 @27.22 » Embed

Here's a script I've not messed with in years but I made this video with it:


this is on ffmpeg???? that's fucking crazy!!!!!!! i clearly do not know the full extent of what it can do. that is bananas

Logged

:D :] ;P :L :I doot doot lalala~~~
mrparker
Jr. Member ⚓︎
**
View Profile WWW

⛺︎ My Room

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!lighthouse keeper artemisUserJoined 2026!
« Reply #8 on: August 14, 2026 @430.14 » Embed

this is on ffmpeg???? that's fucking crazy!!!!!!! i clearly do not know the full extent of what it can do. that is bananas

A lot of video editors actually just use FFmpeg underneath to encode (typically called "render") videos. KDEnlive uses it, and I believe the Vegas suite and Adobe Premiere too.

Logged
bartender
Newbie
*
View Profile WWW

⛺︎ My Room

Artifacts:
Joined 2026!
« Reply #9 on: August 26, 2026 @273.13 » Embed

There's old codecs you can use as well. Such as Cinepak used for the Sega Saturn.

Some example command I looked up:
ffmpeg -i input_file -s 320x240 -ar 48000 -c:a pcm_s16le -c:v cinepak output_file.avi

There's others included in ffmpeg from the 90s as well. I wanted to find out how to get video to look like the intro FMVs for this game 'Winning Post'. Couldn't quite recreate it but it still gave me some nice results.

(1:05 - 3:00)

Logged
Rubbereon
Sr. Member ⚓︎
****
View Profile WWWArt


⛺︎ My Room
SpaceHey: Friend Me!
Matrix: Chat!
XMPP: Chat!

Guild Memberships:
Artifacts:
NoSmoking!Hope, the silliest ink kittayyVisited on Melon's 10th Anniversary!Joined 2025!
« Reply #10 on: August 26, 2026 @633.70 » Embed

I haven't really tested it much, but this script can apparently let you stream to Twitch, thing that is convenient on a weaker machine since obs requires some bit of processing power and ram.
Code
ffmpeg -f x11grab -video_size 1920x1080 -i :0.0 -f alsa -i default -c:v libx264 -preset ultrafast -c:a aac -f flv rtmp://your-streaming-url/your-stream-key
https://salivity.github.io/ffmpeg/article/how-to-use-ffmpeg-re-for-live-streaming
https://trac.ffmpeg.org/wiki/Capture/Desktop?source=post_page---------------------------

This one can repair corrupted video files, it does so by trimming out unreadable chunks out of the file (they call it muxing, I'm specialized in art preservation so I might have the wrong idea, but this sounds like removing whatever is corrupted and rebuilding the file with what's left). I used it once and was able to "recover" a mp4 video i.e. I could play it without any issues.
Code
ffmpeg -i "video-broken.mp4" -c copy "video-fixed.mp4"
https://www.junian.dev/tech/ffmpeg-fix-corrupted-video/

Logged

https://bettysgraphics.neocities.org/images/animals/cat%20695.gifFuzzy fwiendhttps://bettysgraphics.neocities.org/images/animals/cat%20696.gifhttps://bettysgraphics.neocities.org/images/animals/cat%20697.gif
https://rubbereon.nekoweb.org/img/penguin.gifLinux userhttps://rubbereon.nekoweb.org/img/penguin.gif
↓ All my web profiles are available on this website ↓
https://fursona.directory/@rubbereon :eyes:

Artifact Swap: pearl yappin kittaydiamond yappin kittayGreen Spiffo
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 MelonLand Editor Recent Edits Tenement Arcade Want to Login or Join ? Forum Art Hub Chat Webring Web Guides Graphics Catalogue Wiki Newsletters Image Stream
Melon's Sites TamaNotchi Textures PixelSea GifyPet MoMG Ozwomp Online Loom Videos Leaky Webring Melonking
Tools Melon Software ArtHub Embed Maker ML Passports
Outlinks Frutiger Aero Forum Onio Club m15o's Web Services 32Bit Cafe iMood Webrings Internet Phone Book HTML Energy Declarations Hackers & Designers
Zap!
Minecraft: Online
Join: craft.melonking.net