FFmpeg is a very simple way to download, convert and stream media (video and audio). You can download FFmpeg from here. I find it very good at downloading streams (m3u8 and ts files).
I am going to cater this guide towards windows users, once you have downloaded the FFmpeg.zip open it and drag the 3 files from the bin folder into C:\Users\YOURUSERNAME\
And make sure the files are unblocked by right clicking and going to properties and ticking UNBLOCK at the bottom of the details tab.
Next create a new text file and rename it something like fetch.bat so it’s now the bat extension rather than text. RIght click it and click edit
Now comes the fun, the basics of FFmpeg is as follows
ffmpeg -i "https://videofile.mp4" downloadedfile.mp4
Here you can see we are fetching/downloading the videolink.mp4 file and saving it as downloadedfile.mp4
ffmpeg -i "https://videofile.mp4" -c:v libx264 -preset fast -crf 18 AFLWfile.mp4
This will download videofile.mp4 and will use a fast encoding to compression speed, so the file will be quiet large but it will encode it quickly. A slow -preset will take longer but compress the file better.
The -preset values are:
The -crf is constant buffer rate or quality control on the video. 0 is lossless meaning it wont encode it or change its quality, FFmpeg say an output that is roughly “visually lossless” but not technically lossless is -crf 17 or -crf 18
The range of the CRF scale is 0–51, 0 is lossless, 23 is the default, and 51 is the worst quality possible. A -crf of around 18-21 is the sweet spot i have found.
A good solid combination i find to make the file slightly smaller, keep quality and do it quickly is the values used here
ffmpeg -i "https://videofile.mp4" -c:v libx264 -preset fast -crf 18 AFLWfile.mp4
Here is a nice graph to see roughly what the time to quality would be like at different values.
Two more examples are:
The quickest encode
ffmpeg -i "https://videofile.mp4" -c:v libx264 -preset ultrafast -crf 0 downloadedfile.mp4
The slowest but best compression rate
ffmpeg -i "https://videofile.mp4" -c:v libx264 -preset veryslow -crf 0 downloadedfile.mp4
Once you have edited your fetch.bat file save it and now double-click it, you will now see the command line and FFmpeg go through the process of downloading and encoding your media file.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…