This blog post tells you how to convert and resize MOV and MP4 video files to GIF or WEBM and vice versa.
Warning: You download and use FFmpeg or any other application and file at your own risk.
Please note: Please view this blog post as a beginners guide and starting place to help you learn the basics. Personally I avoid converting files when I can, in an attempt to preserve quality. If possible, I try and keep a backup of the original video files that are important to me.
So before I begin with the instructions, I will quickly mention that MOV, MP4 and WEBM are containers. So for example you can have MPEG-4 video in both MP4 and MOV files, accompanied by audio, such as AAC and PCM.
It’s important to mention this is a very basic ‘how to’ blog post, which focuses on the basic use of FFmpeg to handle the conversion tasks. There are various FFmpeg commands that could help resolve an issue and/or change the output, but the majority I won’t mention here.
When looking at the example commands I’ve used, you can substitute GIF, MP4, MOV and WEBM for each other. So instead of converting MP4 to GIF, you could try MOV to WEBM and so on.
I hope you find this blog post helpful.
How I’m using FFmpeg
I’ve downloaded FFmpeg and then placed the ffmpeg.exe application in the same directory as the files I’m converting. I’ve then opened a ‘command prompt’ in Windows 10 and gone to that directory.
The directory I’ve created is called videotesting on the C drive. So via a command prompted I’ve typed cd \videotesting.
If the directory had been on another drive, I would’ve typed the drive letter followed by a colon. i.e. D: and then pressed enter. Then on a new line I would’ve typed cd videotesting to enter the directory.
FFmpeg doesn’t need to be in the same directory as the files you’re converting and you could call it from another location. i.e. c:\ffmpegfiles\ffmpeg
How to convert MP4 to GIF
ffmpeg -i testfile.mp4 output.gif
The resulting GIF animation has a larger file size than my original MP4 test file and can be viewed in Google Chrome.
A GIF file won’t have sound. My test video was a recording at a beach and the resulting GIF is lower quality.
How to resize a video file and convert to GIF
My MP4 is 1280×720 pixels and without using additional commands to resize the GIF is as well. For the next example I’m going to resize and make the GIF smaller, but maintain aspect ratio.
ffmpeg -i testfile.mp4 -vf scale=200:-1 smaller.gif
The resulting GIF I created is 200×113 pixels in size and the file size is also considerably smaller.
I could’ve typed similar commands for a MOV file, instead of a MP4.
As you might’ve noticed the test file I’m using shows a beach and the MP4 has sound. The GIFs I created are low quality and don’t include sound.
How to convert MP4 to WEBM and resize the video
So for the next example I’m going to convert a MP4 to WEBM and resize at the same time.
ffmpeg -i testfile.mp4 -vf scale=400:-1 medium.WEBM
The resulting WEBM file is again considerably smaller than my original larger sized MP4. Both the sound and video have been converted and the visual quality is superior to the GIF I created.
How to convert WEBM to MOV and remove sound from the video file
This time I’m going to convert the WEBM to MOV, remove the sound and make the file slightly larger and set the specific height and width size.
ffmpeg -i medium.WEBM -an -vf scale=720×480 output.mov
The newly created MOV doesn’t have sound. The pixel size is larger and as there was less data to work with and at this stage I’ve converted a few times, the quality isn’t good.
How to remove a metadata comment from a WEBM file
Now meta information for the WEBM file still has a META comment, which mentions the camera I used to record the original video file. I want to remove the metadata comment, but not change the video or audio in the container file.
ffmpeg -i medium.webm -vcodec copy -map_metadata -1 removed.webm
These days I hardly use GIF files, but recently I wanted to test MOV to WEBM, which then led me to writing this blog post.
As mentioned this blog post is intended for beginners. Please don’t forget there is much more to ffmpeg and if you run into problems, you could start by looking at Ffmpeg’s excellent documentation for advanced info.
I’m sorry, but I won’t be providing help with FFmpeg commands in the comments.