Rotate 90 clockwise:
ffmpeg -i in.mov -vf "transpose=1" out.mov
For the transpose parameter you can pass:
0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip
Use -vf "transpose=2,transpose=2"
for 180 degrees.
Make sure you use a recent ffmpeg version from here (a static build will work fine).
Note that this will re-encode the audio and video parts. You can usually copy the audio without touching it, by using -c:a copy
. To change the video quality, set the bitrate (for example with -b:v 1M
) or have a look at the H.264 encoding guide if you want VBR options.
A solution is also to use this convenience script.
FFmpeg has three concatenation methods:
Use this method if your inputs do not have the same parameters (width, height, etc), or are not the same formats/codecs, or if you want to perform any filtering.
Note that this method performs a re-encode of all inputs. If you want to avoid the re-encode, you could re-encode just the inputs that don't match so they share the same codec and other parameters, then use the concat demuxer to avoid re-encoding everything.
ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv \
-filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] \
concat=n=3:v=1:a=1 [v] [a]" \
-map "[v]" -map "[a]" output.mkv
Use this method when you want to avoid a re-encode and your format does not support file-level concatenation (most files used by general users do not support file-level concatenation).
$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
For Windows:
(echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txt
ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
Use this method with formats that support file-level concatenation
(MPEG-1, MPEG-2 PS, DV). Do not use with MP4.
ffmpeg -i "concat:input1|input2" -codec copy output.mkv
This method does not work for many formats, including MP4, due to the nature of these formats and the simplistic concatenation performed by this method.
If in doubt about which method to use, try the concat demuxer.
Also see
Best Answer
ffprobe
This actually counts packets instead of frames but it is much faster. Result should be the same. If you want to verify by counting frames change
-count_packets
to-count_frames
andnb_read_packets
tonb_read_frames
.What the ffprobe options mean
-v error
This hides "info" output (version info, etc) which makes parsing easier (but makes it harder if you ask for help since it hides important info).-count_frames
Count the number of packets per stream and report it in the corresponding stream section.-select_streams v:0
Select only the first video stream.-show_entries stream=nb_read_packets
Show only the entry fornb_read_frames
.-of csv=p=0
sets the output formatting. In this case it hides the descriptions and only shows the value. See FFprobe Writers for info on other formats including JSON.Only counting keyframes
See Checking keyframe interval?
MP4 Edit List
The presence of an edit list in MP4/M4V/M4A/MOV can affect your frame count.
Also see
mediainfo
The well known
mediainfo
tool can output the number of frames:MP4Box
For MP4/M4V/M4A files.
MP4Box
from gpac can show the number of frames:Refer to the
Media Info
line in the output for the video stream in question:In this example the video stream has 2525 frames.
boxdumper
For MP4/M4V/M4A/MOV files.
boxdumper
is a simple tool from l-smash. It will output a large amount of information. Under thestsz
sample size box section refer tosample_count
for the number of frames. In this example the input has 1900 video frames:stsz
atom.