Skip to main content
275 votes

How to do I convert an animated gif to an mp4 or mv4 on the command line?

Here's what worked for me: ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4 movflags – This option optimizes the structure of the MP4 ...
d0n.xyz's user avatar
  • 2,851
253 votes

How can I reduce a video's size with ffmpeg?

You mentioned wanting to reduce the file size to fit more videos on a mobile device, which is my use case as well.  All the answers here are for reducing the compression quality, but nobody has ...
georgiecasey's user avatar
  • 2,721
125 votes

Merge two video clips into one, placing them next to each other

To be honest, using the accepted answer resulted in a lot of dropped frames for me. However, using the hstack filter_complex produced perfectly fluid output: ffmpeg -i left.mp4 -i right.mp4 -...
Albus Dumbledore's user avatar
121 votes

How can I reduce a video's size with ffmpeg?

I tested most of the other proposed answers to this question. The test data conclusions are below. These are the proposed answers that I tested: (BR) Modify the bitrate, using: ffmpeg -i $infile -b $...
John Pankowicz's user avatar
104 votes

How can I reduce a video's size with ffmpeg?

Note that it seems that ffmpeg already performs some optimization when ran without options, so before trying to use settings you don't understand or deciding to explicitly lose information, give a try ...
Skippy le Grand Gourou's user avatar
64 votes

How can I reduce a video's size with ffmpeg?

Unless you're looking for a specific bit rate, I'd recommend the -crf option. This is most commonly used for x264 encoding as described in this article. In short: a constant rate factor (CRF) of 23 ...
Tom Kelly's user avatar
  • 807
33 votes

How do I watch my webcam's feed on Linux?

guvcview This program is ideal for screencasts, as it can show just the camera on a window and nothing else: sudo apt-get install guvcview guvcview Then just use any screen recorder to make a feed. ...
Ciro Santilli OurBigBook.com's user avatar
29 votes
Accepted

How to recover a broken mp4 file: moov atom not found

You can try and use Untrunc to fix the file. Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video. you may need to compile it from source, but ...
Rabin's user avatar
  • 3,893
28 votes
Accepted

Multiple /dev/video for one physical device

The second device provides metadata about the video data from the first device. The new devices were introduced by this patch: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/...
James Henstridge's user avatar
23 votes

Convert OGV video to GIF animation?

Simple script with good quality Script: inputFile=$1 FPS=15 WIDTH=320 #Generate palette for better quality ffmpeg -i $inputFile -vf fps=$FPS,scale=$WIDTH:-1:flags=lanczos,palettegen tmp_palette....
Gelldur's user avatar
  • 333
21 votes

How do I watch my webcam's feed on Linux?

ffplay /dev/video0 is one of the simpler methods, and will work provided you have ffmpeg installed. To install, use sudo apt install ffmpeg.
Henry Wilson's user avatar
21 votes

How can I reduce a video's size with ffmpeg?

I compressed a 40-minute HD video presentation from 505MB to 183MB That's like going from 100MB → 36MB. Original video was HD and output was almost zero noticeable difference. It's a video file "...
Jake Berger's user avatar
17 votes

How can I change my webcam's power line frequency setting?

On the command line, you can set the uvcvideo driver's power line frequency setting to the 50 Hz value with: v4l2-ctl --set-ctrl=power_line_frequency=1 If your webcam is not /dev/video0, add a -d /...
telcoM's user avatar
  • 99.3k
16 votes

Re-encoding video library in x265 (HEVC) with no quality loss

I've recently gone through the trouble of Transcoding my whole video catalog over to HEVC. I use https://github.com/FallingSnow/h265ize with the following settings. h265ize -v -m medium -q 20 -x --no-...
Ashleigh-Paul Charlesworth's user avatar
15 votes

Convert a video to a fixed screen size by cropping and resizing

If you want to crop and scale in one go, you can make a crop-then-scale filterchain like so: ffmpeg -i SomeInput.mp4 -vf "crop=in_h*9/16:in_h,scale=-2:400" -t 4 SomeOutput.mp4 The above first crops ...
Chris's user avatar
  • 451
14 votes

How to do I convert an animated gif to an mp4 or mv4 on the command line?

A side note: the important thing is to specify -pix_fmt yuv420p lest your video might seem a black rectangle in various tools: $ ffmpeg -i animated.gif -pix_fmt yuv420p output.mp4 References Why won'...
beefeather's user avatar
14 votes
Accepted

How to check if a video is completely downloaded?

ffmpeg is an OS agnostic tool that is capable of determining if a video file has been completely downloaded. The command below instructs ffmpeg to read the input video and encode the video to nothing. ...
J363's user avatar
  • 500
14 votes

How can you download 4k youtube videos in mp4 using youtube-dl?

You can find the available mp4 resolutions available for a video with: youtube-dl --list-formats https://youtu.be/LXb3EKWsInQ | grep mp4 ... 401 mp4 3840x2160 2160p60 18167k , av01.0....
Hugh's user avatar
  • 387
13 votes

How can I reduce a video's size with ffmpeg?

If you’re targeting a specific file size (or bitrate) rather than a specific quality, you'll need to use a two-pass average bitrate encoding (or “2-pass ABR” for short) to fit the video within this ...
SaltySub2's user avatar
  • 231
12 votes
Accepted

Convert image based subtitle to text based subtitle inside MKV file

Converting image based subtitles to text is a nontrivial process, as you will need some kind of OCR system to interpret the bitmaps and figure out what the corresponding text is. ffmpeg alone will not ...
marcan's user avatar
  • 968
12 votes

How to strip GPS location data from an MP4 video file?

You need to remux the video, removing the GPS location metadata. You can use ffmpeg: ffmpeg -i input.mp4 -metadata location="" -metadata location-eng="" -acodec copy -vcodec copy output.mp4 Then ...
unfa's user avatar
  • 1,745
12 votes
Accepted

How to reduce the size of a video to a target size?

@philip-couling's answer is close but missing several pieces: The desired size in MB needs to be multiplied by 8 to get bit rate For bit rates, 1Mb/s = 1000 kb/s = 1000000 b/s; the multipliers aren't ...
tobek's user avatar
  • 388
12 votes

How to significantly lower a video file size with ffmpeg without quality loss?

I had a pretty good experience with the h265 codec. The output videos were between 2-8x smaller in size, without any noticeable loss in quality. ffmpeg -i input.mkv -c:v libx265 -vtag hvc1 -c:a copy ...
mashuptwice's user avatar
  • 1,384
11 votes

How do I watch my webcam's feed on Linux?

Or you can try mpv command mpv /dev/video0
hungptit's user avatar
  • 211
10 votes
Accepted

How to restart a failed amdgpu kernel module

As @Chris Stryczynski says, sudo cat /sys/kernel/debug/dri/N/amdgpu_gpu_recover is the correct way to reload the amdgpu kernel module, or you can start your system with amdgpu.gpu_recovery=1 kernel ...
Dávid Bíró's user avatar
10 votes

How to recover a broken mp4 file: moov atom not found

Solution provided here (https://github.com/ponchio/untrunc) solved my problem! I run it as a Docker container. Here my steps: Install Docker (in case you don't have it yet) Clone the repository: ...
Alexandre Andrade's user avatar
10 votes

How can I download a video from an M3U8 file?

The movie can be easily downloaded using the FFmpeg command line tool: ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i my_movie.m3u8 -c copy my_movie.ts Note that if the .m3u8 file was ...
M. Justin's user avatar
  • 293
10 votes

How can I watch an encrypted Blu-ray on a Linux desktop?

I've been working with MakeMKV beta, which is a commercial (beta: shareware) converter that can play DVDs and Blu-ray discs or save them to the hard disk. It is also possible to convert existing .iso ...
kanehekili's user avatar
10 votes

How can I watch an encrypted Blu-ray on a Linux desktop?

There is no official commercial Blu-ray player for Linux. Linux users have to use open-source libraries capable of handling the DRM schemes that protect these disc contents. This is legal in most ...
Lutz Willek's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible