Home >Web Front-end >Front-end Q&A >Essential for getting started with ffmpeg
I recently wanted to play with video watermarking, so I found the ffmpeg script, and then started playing with this tool.
Here are just simple operations, there are more tricks to play, and other functions are waiting for you to discover.
If you want to use it, you must install it first. Next, Kaka will take you step by step to achieve it. Install.
The installation environment is centos7 for linux.
Download address: wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
Figure 1-1 is the compressed package after downloading.
You can see that this compressed package is different from the usually used tar, and the suffix is xz.
Execution: xz -d ffmpeg-git-amd64-static.tar.xz
Perform the first step on the downloaded file.
Figure 1-2 is the file after executing the above command. At this time, the file suffix is only tar.
Then use tar to further decompress the file.
Figure 1-3 is the decompressed file.
After fmpeg is downloaded, it is started.
Go to the file you just decompressed, and then execute ./ffmpeg
.
If you can see the information below, it means the installation has been successful.
In fact, it is to create a soft link. Links on Linux are divided into soft and hard links. As for the detailed explanation, please check the relevant information yourself!
First enter the bin directory: cd usr/bin
Then execute the following two commands, as shown in Figure Essential for getting started with ffmpeg, click here to facilitate the decompression of the files A name change was made.
Execute command: ffmpeg -i test.mp4 -vf "drawtext=fontfile=/SIMHEI.TTF: text='Kaka Chat':x=100:y=10: fontsize=48:fontcolor=red:shadowy=2" new.mp4
Parameter description
Start executing this command happily. When you click Enter to execute, you will be asked to enter y\n.
Just enter y directly.
Then you will be disappointed to see such an interface, as shown below
According to the error message, you can get I know the font cannot be found.
Since the font cannot be found, this is not very easy to deal with. Just open a window computer and you can choose from a variety of fonts.
Just copy the font you need and then transfer it to the linux server.
Then execute the command again.
You will then be able to see the data, which means that the text watermark has been printed successfully.
If you look at the renderings, you can see that the four words Kaka Chat
have been typed into the video.
Have you ever wondered why watermarked videos are so bad?
Actually, this has nothing to do with ffmpeg. This is compressed when recording gif.
Since text watermarks are so successful, the same is true for picture watermarks. Next, let’s take a look at what picture watermarks should be. Do.
Execute the command: ffmpeg -i test.mp4 - vf "movie=mark.png[watermark];[in][watermark] overlay=10:10[out]" new.mp4
Parameter Description
It is much easier to use image watermark than text watermark. You don’t need to consider whether the font exists, you only need to have a watermark image.
The picture above is the effect after the picture watermark is successfully set.
Let’s take a look at the effect!
The picture of 51 in the upper left corner is the watermark picture set by Kaka.
After looking at the above two operations, it seems very simple, but in fact ffmpeg is very complicated, and there is so much content that it will make you collapse.
But we don’t need to understand everything, as long as it can fulfill our needs.
For example, current video websites basically play in m3u8 mode, so ffmpeg can also convert video files in mp4 format into m3u8 format.
If you are interested, you can give it a try. I won’t go into details here.
Persistence in learning, persistence in writing, and persistence in sharing are the beliefs that Kaka has always adhered to since its beginning. I hope that Kaka’s articles on the huge Internet can bring you a little bit of help. I’m Kaka, see you next time.
The above is the detailed content of Essential for getting started with ffmpeg. For more information, please follow other related articles on the PHP Chinese website!