[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: sB1XQYDbzOE.webm (3.91 MB, 2048x1024)
3.91 MB
3.91 MB WEBM
>high quality webms within a filesize limit with ffmpeg

ffmpeg.exe[1] -i .\input.mp4 -c:v libvpx-vp9 -b:v 512k[2] -pass 1 -an -f rawvideo -y NUL[3]
ffmpeg.exe[1] -i .\input.mp4 -c:v libvpx-vp9 -b:v 512k[2] -pass 2 -an .\output.webm


[1] https://github.com/BtbN/FFmpeg-Builds

[2] here's the formula for calculating the appropriate bitrate in kilobits:
4096 Kilobytes (K) [4] MULTIPLIED BY 8 (to make it into kilobits) DIVIDED BY video length in seconds.milliseconds = k
512k would be for a 64 second video, because:
4096 * 8 / 64 = 512

[3] UN*X users should use
/dev/null
INSTEAD of NUL

[4]chan filesize limit on most boards
6144 for >>>/wsg/, 2048 for >>>/b/ & >>>/bant/
https://a.4cdn.org/boards.json


want audio for >>>/gif/ or >>>/wsg/ ? add
 -c:a libopus -b:a 64k[5] 
REMOVE -an from the second pass (second line with -pass 2)
[5] SUBTRACT the AUDIO bitrate you want from VIDEO bitrate (-b:v from above [2]) so that the TOTAL bitrate is the same and under the filesize limit [4]

include either/both
 -ss 00:00:00.000 
(SEEK START) and
 -to 00:00:00.000 
(END) to cut in the video
obviously take this into account when calculating bitrate

avoid scaling video if possible, as it always results in quality loss and a number of caveats; users should be assumed to have a competent browser and media player with higher quality scaling of their own (4chan settings -> Images & Media -> Fit expanded images to screen)
but say you want to simply *scale the video to 720p (height) and keep the aspect ratio, then add
 -vf scale=-1:720 


FINALLY, webmrel is the result of combining the concepts above, except audio (no audio on /g/). 21.054 seconds, downscaled from 3840×1920 (see reply for full command)


CROSS-REFERENCE INSTRUCTIONS WITH OFFICIAL DOCUMENTATION:
https://www.ffmpeg.org/ffmpeg-all.html
https://developers.google.com/media/vp9


or just use handbrake lmao
>>
>>101428428
>FINALLY, webmrel is the result of combining the concepts above, except audio (no audio on /g/). 21.054 seconds, downscaled from 3840×1920 (see reply for full command)
ffmpeg.exe -i .\sB1XQYDbzOE.mp4 -c:v libvpx-vp9 -b:v 1556k -pass 1 -an -ss 00:14:16.890 -to 00:14:37.944 -vf scale=2048:-1 -f rawvideo -y NUL
ffmpeg.exe -i .\sB1XQYDbzOE.mp4 -c:v libvpx-vp9 -b:v 1556k -pass 2 -an -ss 00:14:16.890 -to 00:14:37.944 -vf scale=2048:-1 .\sB1XQYDbzOE-output.webm
>>
>>101428428
or just use mpv-webm for mpv
https://github.com/ekisu/mpv-webm/
>>
>>101428445
That's pretty cool
>>
>>101428428
This could've been made into a GUI application but /g/tards can't into UI/UX
>>
>>101428428

https://argorar.github.io/WebMConverter/
>>
>>101428428
You just know
>>
>>101428445
Any downsides to using this?
The mpvffmpegytdlp general doesn't recommend using script. I don't remember why.
>>101428575
Windows only.
>>
>>101428713
>Any downsides to using this?
yeah it makes mustard gas
>>
>>101428428
Thanks I was trying to figure this out recently.
>>
add this line.

-row-mt 1 and -qmin 26
>>
>>101428965
>-row-mt
No difference unless you have tons of cores.
>-qmin 26
What is this arbitrary value based on?
And what about -cpu-used?
>>
>>101428428
Why not use crf?
>>
>>101429046
>No difference unless you have tons of cores.
Everyone today has 4 core or more now. So it speeds up double digit percentage to triple digit percentage.

>arbitrary value
Minimum value of 26 is just to keep same perceptual quality as original so that it doesnt waste bitrate with min value when there isn't a need to
>>
>>101429134
Ok but why is it 26?
>>
>>101428539
I made my own GUI but I'm not sharing it, fuck off and make your own.
>>
>>101429278
Personal perceptual value threshold for internet webms. Thats probably a good number for most people as well
>>
>>101428445
Holy based
>>
>>101428428
You ruined this thread by posting linus cuck tips.

t. know VP9 secret params that let you cram video into really small file sizes
>>
>>101428445
I just this function
vp8 ()
{
echo -e "Script input output bitrate crf/26 qmax/30 vf"
duration=$(ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 "$1")
bitrate=$(bc -l <<< "scale=0; 27000000 / ${duration}")
echo -e "Starting 1st pass..."
ffmpeg -hide_banner -loglevel error -y -i "$1" -threads 4 -c:v libvpx -crf "${4:-26}" -qmin 5 -qmax "${5:-30}" -b:v "${3:-$bitrate}" -maxrate "${3:-$bitrate}" -bufsize "${3:-$bitrate}" -vf ${6:-"scale=-1:480"} -an -auto-alt-ref 1 -pass 1 -f webm /dev/null
value=$(echo "$bitrate/10000"| bc)
echo -e "Found bitrate: $value K\nStarting 2nd pass..."
ffmpeg -hide_banner -loglevel error -i "$1" -threads 4 -c:v libvpx -crf "${4:-26}" -qmin 5 -qmax "${5:-30}" -b:v "${3:-$bitrate}" -maxrate "${3:-$bitrate}" -bufsize "${3:-$bitrate}" -vf ${6:-"scale=-1:480"} -an -auto-alt-ref 1 -pass 2 -f webm "${2:-$1}".webm
rm ffmpeg2pass-0.log
}
>>
File: 1716428264193746.png (243 KB, 716x726)
243 KB
243 KB PNG
Some time ago I saved this, maybe it helps:

> Best FFMPEG Scripts for 4chan <

>Convert Video to WEBM
ffmpeg -i INPUT.mp4 -o OUTPUT.webm
>The -o flag is NOT required

>Lower Quality Before Conversion
ffmpeg -i INPUT.mp4 -crf 48 OUTPUT.webm
>The range is from 0 to 51 where the higher the number, the lower the quality

>Cut a Specific Portion of a Video
ffmpeg -i INPUT.mp4 -ss 00:30 -to 01:53 OUPTPUT.webm
>The -ss flag signifies the start point and -to as the end point

>Adjust Video Size
ffmpeg -i INPUT.mp4 -vf scale=1280:720 OUTPUT.webm
ffmpeg -i INPUT.mp4 -vf scale=iw/2:ih/2 OUTPUT.webm
>Self-Explanatory; the second one halves the Width and Height or divides by two

>Combine Video and Audio File
ffmpeg -i INPUT.mp4 -i INPUT.mp3 -map 0:v -map 1:a OUTPUT.webm

>Disable Audio Track
ffmpeg -i INPUT.mp4 -an OUTPUT.webm

>Convert GIF into a Continuously Looping Video
ffmpeg -r 7 -ignore_loop 0 -i INPUT.gif -t 30 OUTPUT.webm
>The -r flag is the Frame Rate; the -t flag is the amount of seconds you want the video to be

>Overlay an Image at a Specific Time
ffmpeg -i INPUT.mp4 -i INPUT.jpg -filter_complex "[0:v][1:v] overlay=0:enable='between(t,0,1)'" OUTPUT.mp4
>You only need to worry about the (t,0,1) which focuses on the length of time the image will be on the screen

>Crop a Video File
ffplay -vf "crop=x:y:w:h" OUTPUT.webm
ffmpeg -vf "crop=500:500" OUTPUT.webm
>The ffplay program allows us to preview the video as it is being rendered so we can stop it and adjust accordingly
>Once we are satisfied with the results, we can use FFMPEG to render the actual video file

>Export Individual Frames to Image Files
ffmpeg -i input.mp4 %04d.png
>The %04d indicates how many sequencial numbers you want to use. %04d goes to 9999 while %03d goes to 999
>Essentially, if you want to export more than 1,000 frames, you'll need to use %04d
>>
>>101429705
Share your secrets anon I won't tell a soul
>>
peak dunning krueger
>>
>>101431867
OP is but thanks to this thread I learned about -qmin so this wasn't a complete waste of time
>>
>>101431929
i knew about qmin but i've never tried -row-mt so i get your point
>>
>>101431867
you can tell by the .exe
>>
>>101431867
there are a bunch of shitty opinionated ffmpeg pastas with esoteric, forced meme switches and shit like combining b:v and -crf circulating that nu-/g/ (and 4chan in general obv.) is confused to complete oblivion on how simple it is to make good webms, so someone stating the "obvious" was needed
KISS, niggers.
also, saying
>peak dunning krueger
is peak dunning kruger* :)
>>101432087
>WINDOWS LE BAD!!!!!!!!
case in point
>>
File: 1713675396002.png (411 KB, 856x924)
411 KB
411 KB PNG
for me it's open-source abandonware
>b-but if you spend 15min encoding and tweaking 50 different options it'll be better quality!!
not my problem
>>
>>101432106
>NOOOO YOU HAVE TO USE THE NIGGERIZED SPELLING
oslo
>esoteric options like crf and bitrate
>>
for me it's
ffmpeg -i input.mp4 input.webm
>>
>>101428428
90% of posters use their phones. The rest of us want this site to die.
>>
>>101429408
In other words it's guesswork of your own that may not work universally.
Random options without supporting documentation isn't helpful.
>>
>>101432724
If you dont trust others to see the same reality as you do, then you shouldn't be able to comprehend whats infront of your screen either.
>>
File: image.png (11 KB, 527x150)
11 KB
11 KB PNG
>>101428428
ain't reading that shit
>>
>>101432760
Nonsense.
Make OPs webm with -qmin 26. Let's compare.
>>
>>101432768
based
>>
>>101432768
What GUI is this now?
>>
>>101432885
https://argorar.github.io/WebMConverter/
>>
File: boram.png (582 KB, 962x959)
582 KB
582 KB PNG
ain't reading that shit
>>
>>101432904
What GUI is this now?
>>
>>101428445
>>101428713
>The mpvffmpegytdlp general doesn't recommend using script. I don't remember why.
>>101431524
>>101432929
>>
File: shutter.png (545 KB, 1029x684)
545 KB
545 KB PNG
aint reading that shit
>>
>>101432953
What GUI is this now?
>>
>>101432885
looks like webm for retards
>>
>>101432087
did you miss where it says it's a guide for retards?
>>
>>101428428
thanks but for me it's vidcoder
>>
>>101428428
Imagine still using command line in 2024. The 90s called, they want their ui back hahaha. Even mac solved UI in the early 2000s.
>>
i forget if i ever asked this but does anyone know why -threads 8 crashes powershell?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.