Tag FFmpeg

Add text to a video with FFmpeg

If you want to add text to multiple video files in a bulk operation, FFmpeg is the way to go. You don’t want to manually edit a bunch of videos just to add the same stuff each time. Automation for the win! In this FFmpeg example, we will add some text to this video clip. As you can see, no text yet. We want to add “hard coded” text (that cannot be removed after it is added). We are not talking subtitles/captions. Here is the command, but hold on for a sec… The following command has been made simpler to read by breaking the long command into multiple lines. If you use this command you should remove all ^-symbols, so that everything is displayed in one line. Also don’t miss the spaces in there. This command is made for a Windows environment so it might look a little different if you are on another OS. You can also make the text with a little better position and padding like this: This is the result: Sources: https://superuser.com/questions/939357/ffmpeg-watermark-on-bottom-right-corner

Record microphone with FFmpeg in Windows

It’s easy to record your computer microphone with FFmpeg. The only tricky part (although not that tricky) is you just have to know the name of your microphone input. Before you begin make sure you have FFmpeg added to PATH. Let’s start by listing your recording devices. Amongst other things this will give you something like: The only thing you need to note is your device name. In this case it is Line (3- Steinberg UR44). To start the recording you just run the following code: To stop the recording hit CTRL+C. -f dshow means “DirectShow” and lets FFmpeg capture audio and video devices, video capture devices, analog tv tuner devices. -i audio="name_of_your_microphone" is the audio device you wish to record from. Replace name_of_your_microphone with the name of your input device. -c:a libmp3lame means FFmpeg will encode the audio with LAME MPEG Audio Layer III, also known as the MP3 format. -ar 44100 tels FFmpeg to record at a sample rate of 44,100 Hz. That is the standard for most audio nowadays unless you intend to use the audio for a video in which case you would use 48,000 Hz. -b:a 320k is the audio bit rate. The highest support for MP3 is 320 kbit/s. -ac 1 means the audio will be in mono as opposed to stereo streams. This makes sense as most microphones record in mono only. If you haven’t changed the directory in your command line you can always specify where to save the file. For example C:\output.mp3.

Slow down video with FFmpeg

Here is a quick example on how you can use FFmpeg to slow down a video. Slowed down video by 50%: -vf setpts=2*PTS will slow down the video twice it’s original speed. -filter:a atempo=0.5 slows down the audio to 50%. Unfortunately, the caveat here is that the tempo must be in the range of 0.5 to 2.0. Also, you do not get that slow-motion down pitched sound as many slow-motion videos have. Sources: Speeding up/slowing down video

Rotate videos with FFmpeg

There are actually two ways you can rotate videos with FFmpeg: You can rotate the video “physically” with the -vf transpose option. This will re-encode the video, thus it might degrade the video quality slightly. Or you can just change…

Convert audio to visualization video

FFmpeg has a bunch of really cool filters you can use to turn audio into visualizations. Showvolume is my favorite as it shows volume changes in real-time, but the others are great too depending on use case. avectorscope showcqt ahistogram aphasemeter showfreqs showspectrum showwaves showvolume

Merge video files together with FFmpeg

In FFmpeg merging files together is called concatenation. The video files have to have the same codec. Different file containers are allowed though. For the concatenation to work we need to make a list of every file we want to…

Merge audio and video files with FFmpeg

If the video has no audio: If the video already has audio: When you start to manipulate stuff like this you should try to get a basic grasp of FFmpeg streams. The example above is very basic so no need to dig deeper, but if you are editing a video with multiple audio tracks, for example, you should be a little careful. Here is one example if you want to know more.

Downscale video with FFMpeg

Straight to the point this time. Let’s say we want to resize an 8K video to 4K or perhaps a 4k video to HD. To downscale while keeping the aspect ratio use: To set the resolution regardless of aspect ratio…