165
votes
How can I reduce a video's size with ffmpeg?
You mentioned wanting to reduce filesize to fit more videos on a mobile device, which is my usecase as well. All the answers here are for reducing the compression quality but nobody has mentioned ...
143
votes
How can I use ffmpeg to split MPEG video into 10 minute chunks?
Here is the one line solution:
ffmpeg -i input.mp4 -c copy -map 0 -segment_time 00:20:00 -f segment output%03d.mp4
Please note that this does not give you accurate splits, but should fit your needs....
121
votes
Accepted
Trim audio file using start and stop times
ffmpeg seems to have a new option -to in the documentation:
-to position (input/output)
Stop writing the output or reading the input at position. position
must be a time duration specification, ...
102
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 $...
95
votes
Accepted
How do I split an audio file into multiple?
This worked for me when I tried it on a mp3 file.
$ ffmpeg -i somefile.mp3 -f segment -segment_time 3 -c copy out%03d.mp3
Where -segment_time is the amount of time you want per each file (in seconds)...

slm♦
- 344k
94
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 -...
80
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 ...
78
votes
Re-encoding video library in x265 (HEVC) with no quality loss
From my own experience, if you want absolutely no loss in quality, --lossless is what you are looking for.
Not sure about avconv but the command you typed looks identical to what I do with FFmpeg. In ...
72
votes
Accepted
Merge two video clips into one, placing them next to each other
ffmpeg \
-i input1.mp4 \
-i input2.mp4 \
-filter_complex '[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]' \
-map '[vid]' \
-c:v libx264 \
-crf 23 \
-preset veryfast \
output.mp4
...
67
votes
Bash script to convert all *flac to *.mp3 with FFmpeg?
A simple 1 liner solution:
find -name "*.flac" -exec ffmpeg -i {} -acodec libmp3lame -ab 128k {}.mp3 \;
http://lewisdiamond.blogspot.ca/2012/01/converting-flac-to-mp3.html
Note that this will be ...
60
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 ...
46
votes
How to check if a shared library is installed?
You can use:
ldconfig -p | grep libavfilter
If there is no output library is not installed. I am not sure if this is 100% reliable.
At least in man page of ldconfig for option -p:
Print the lists ...
45
votes
How do I split an audio file into multiple?
To split a big audio file into a set of tracks with varying lengths, you can use the following command:
# -to is the end time of the sub-file
ffmpeg -i BIG_FILE -acodec copy -ss START_TIME -to ...
38
votes
Accepted
Lossless audio conversion from FLAC to ALAC using ffmpeg
Ok, I was probably a little quick to ask here but for the sake of future reference here is the answer:
One should pass the flag -acodec alac to ffmpeg for a lossless conversion between FLAC and ALAC:
...
32
votes
Merge two video clips into one, placing them next to each other
This can be done with just two filters and the audio from both inputs will also be included.
ffmpeg -i left.mp4 -i right.mp4 -filter_complex \
"[0:v][1:v]hstack=inputs=2[v]; \
[0:a][1:a]amerge[a]" \
...
28
votes
Convert a video to a fixed screen size by cropping and resizing
ffmpeg -i input.file -vf "scale=(iw*sar)*max(720/(iw*sar)\,480/ih):ih*max(720/(iw*sar)\,480/ih), crop=720:480" -c:v mpeg4 -vtag XVID -q:v 4 -c:a libmp3lame -q:a 4 output.avi
Replace "input.file" with ...
27
votes
Accepted
Remove silence from audio files while leaving gaps
The best way that I've seen is by adding the -l flag to silence as follows:
sox in.wav out6.wav silence -l 1 0.1 1% -1 2.0 1%
I've copied this command from Example 6 of this very useful blog post ...
26
votes
Re-encoding video with ffmpeg including all subtitles but not all audio
The stream selection default behavior only selects one stream per type of stream, so inputs with multiple audio streams will create an output with one audio stream. To disable this behavior and ...
24
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 ...
23
votes
Accepted
Convert a video to a fixed screen size by cropping and resizing
I'm no ffmpeg guru, but this should do the trick.
First of all, you can get the size of input video like this:
ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width in....
18
votes
Accepted
Play subtitles automatically with mpv
As seen in man mpv:
--sub-auto=<no|exact|fuzzy|all>, --no-sub-auto
Load additional subtitle files matching the video filename. The
parameter specifies how external ...
17
votes
ffmpeg: 'Protocol not found' for normal file name
I came to this topic for the message, just to add one tip for users, I found out that if the filename itself has ':' in it would cause the problem, as some programs generate files with the time stamp ...
16
votes
Encode with ffmpeg using avi to mp4
As far as i understand it's required to replace avi-container with mp4 one (formally - ISO base media file format ISO/IEC 14496-12 ).
if you run the following command:
ffmpeg -i input.avi -y output....
15
votes
Accepted
bash: ffmpeg libx265 prevent output
It looks like ffmpeg doesn't tell the x265 encoder to use the loglevel you're telling ffmpeg to use. So if you want ffmpeg and the x265 encoder within ffmpeg to be quiet, you need to set log level ...
15
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-...
14
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 "...
14
votes
Accepted
FFmpeg - Split video multiple parts
I found the answer. It turns out I was having problems because I didn't have the proper FFmpeg installed, but a fork of ffmpeg.
This code works for me:
ffmpeg -i fff.avi -acodec copy -f segment -...
14
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 ...
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. ...
13
votes
How to get near-perfect screen recording quality?
I've had success with:
ffmpeg -f x11grab -video_size 1920x1080 -framerate 30 -i :1 \
-vcodec libx264 -preset ultrafast -qp 0 -pix_fmt yuv444p \
video.mkv
Key points:
-qp 0: x264 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
ffmpeg × 584video × 101
audio × 68
linux × 57
bash × 53
video-encoding × 52
shell-script × 33
centos × 29
avconv × 25
conversion × 24
streaming × 24
debian × 23
video-editing × 22
command-line × 21
ubuntu × 19
camera × 19
alsa × 15
find × 14
pipe × 14
pulseaudio × 14
recording × 14
shell × 12
x11 × 12
compiling × 12
mp3 × 12