FFmpeg: 10 commands for editing video

Ten FFmpeg commands for converting, trimming, joining and scaling video, checked for current FFmpeg, plus the right export settings for upload.

On this page

FFmpeg is a free, open-source command-line tool for converting, editing and preparing audio and video files. With a single line you can convert a file to MP4, cut a clip, change the resolution or fix the audio, on Windows, macOS or Linux. Below are the 10 commands you will use most for video editing, checked against current FFmpeg releases, followed by one command that prepares a file for upload to a video platform such as AudiencePlayer.

Before you start

Install FFmpeg through your package manager (for example brew install ffmpeg on macOS or sudo apt install ffmpeg on Ubuntu and Debian), or download a ready-made Windows build via the links on ffmpeg.org. Every command follows the same pattern: ffmpeg -i input [options] output.

Two things are good to know. First, most edits re-encode the video, which takes time and costs a little quality. The option -c copy skips re-encoding and is almost instant, but only works when you don’t change the picture itself. Second, if you don’t choose a codec, FFmpeg picks a default for the output format. The examples below set the codec explicitly, so you know what you get.

10 FFmpeg commands for video editing

1. Convert a video to MP4

ffmpeg -i input.mov -c:v libx264 -c:a aac output.mp4

This converts almost any format (MOV, AVI, MKV, WebM) to an MP4 with H.264 video and AAC audio, the combination that plays on practically every device.

2. Set the video quality

ffmpeg -i input.mp4 -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4

CRF (constant rate factor) controls quality for H.264: lower means better quality and bigger files. The default is 23; 18 is close to visually lossless. A slower preset gives a smaller file at the same quality.

3. Change the resolution

ffmpeg -i input.mp4 -vf "scale=1280:-2" -c:v libx264 -c:a copy output.mp4

This scales the video to 1280 pixels wide. The -2 calculates the height automatically, keeps the aspect ratio and makes sure the number is even, which H.264 requires.

4. Crop a video

ffmpeg -i input.mp4 -vf "crop=1280:720" -c:v libx264 -c:a copy output.mp4

This cuts a 1280×720 area out of the centre of the frame. To crop from a specific position, add the x and y offset: crop=1280:720:0:0 starts in the top-left corner.

5. Rotate a video

ffmpeg -i input.mp4 -vf "transpose=1" -c:v libx264 -c:a copy output.mp4

transpose=1 rotates 90 degrees clockwise and transpose=2 rotates 90 degrees counter-clockwise. For 180 degrees, use transpose=1,transpose=1. Phone videos that only look rotated in some players usually carry rotation metadata, which FFmpeg applies automatically when it re-encodes.

6. Trim or split a video

ffmpeg -i input.mp4 -ss 00:01:30 -to 00:05:00 -c copy clip.mp4

This keeps the part between 1:30 and 5:00 without re-encoding. To split a file in two, run it twice: once with -to 00:05:00 and once with -ss 00:05:00. Because -c copy can only cut on keyframes, the cut may be a fraction of a second off. Need it frame-accurate? Replace -c copy with -c:v libx264 -c:a aac.

7. Join multiple videos

ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4

Create a text file list.txt with one line per clip, such as file 'part1.mp4' and file 'part2.mp4'. The often-quoted concat:part1.mp4|part2.mp4 shortcut does not work for MP4 files. Joining with -c copy only works when all clips have the same codec, resolution and frame rate; otherwise convert them to the same settings first.

8. Change the playback speed

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4

This plays video and audio twice as fast. If you only change the video with setpts, the audio keeps its original length and runs out of sync. For slow motion at half speed, use setpts=2.0*PTS and atempo=0.5.

9. Convert the audio to stereo AAC

ffmpeg -i input.mp4 -c:v copy -c:a aac -b:a 128k -ar 48000 -ac 2 output.mp4

The video stays untouched while the audio becomes AAC stereo at 48 kHz. -ac 2 also mixes 5.1 surround down to stereo, which is useful because many streaming workflows expect a stereo track.

10. Work with subtitles

ffmpeg -i subtitles.srt subtitles.vtt

This converts an SRT file to WebVTT, the subtitle standard of web players. You can also burn subtitles into the picture with -vf "subtitles=subtitles.srt", but then viewers can’t switch them off and you need a new video for every language. For a streaming platform, separate subtitle files are almost always the better choice.

Export settings for uploading to AudiencePlayer

On AudiencePlayer, every upload is encoded again into multiple qualities for adaptive streaming, so your source file doesn’t need to be huge. It does need to be clean. Most failed uploads come down to the same few settings, often added by the default export presets of professional editing software. The file upload specifications ask for:

  • MP4 with H.264 video in 8-bit, Rec.709 colour and square pixels. 10-bit and HDR are not supported: such a file may look fine on a Mac, but won’t play in Firefox, on iPhone or in apps.
  • 1920×1080 for HD (or 3840×2160 for 4K), 16:9, at a fixed 25 fps, with at least 6 Mbit/s for HD. Higher is not better: extreme bitrates mainly cause longer uploads and timeouts.
  • Stereo AAC audio at 48 kHz and 128 kbps, with a three-letter language code such as “eng” or “nld” on each audio track.
  • Only video and audio tracks. Extra data tracks, such as the timecode track many export presets add, can make processing fail.
  • A short file name with only letters, numbers, hyphens and underscores, under 64 characters, and a file of at most 25 GB.

This command takes care of all of that for an HD file:

ffmpeg -i input.mov -map 0:v:0 -map 0:a:0 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=25" -c:v libx264 -profile:v high -pix_fmt yuv420p -b:v 8M -maxrate 10M -bufsize 16M -colorspace bt709 -color_primaries bt709 -color_trc bt709 -c:a aac -b:a 128k -ar 48000 -ac 2 -metadata:s:a:0 language=eng -map_metadata -1 -write_tmcd 0 -movflags +faststart my-film-hd.mp4

The -map options keep only the first video and audio track, the filter scales to 1080p (with black bars if the aspect ratio differs) at 25 fps, yuv420p forces 8-bit, and -write_tmcd 0 prevents a timecode track. Change eng to the language of your audio. If an upload fails anyway, re-upload it under a new file name, for example with “-v2” at the end, because a file name that has been used before is blocked.

Prefer not to use the command line?

FFmpeg is ideal for quick fixes and batch jobs, but you don’t need it to run a video platform. With AudiencePlayer’s video on demand you upload your files in the browser or in bulk via FTP, and the platform converts them for every screen and connection. You add subtitles and audio tracks as separate files, so viewers can switch between them in the player. Read more about video encoding for every screen or our tips for subtitles and multi-audio. Curious how it works with your own content? Request a demo.

Frequently Asked Questions

Is FFmpeg free to use?

Yes. FFmpeg is free, open-source software that runs on Windows, macOS and Linux. Many video editors and converters use it under the hood.

How do I merge MP4 files with FFmpeg without re-encoding?

Use the concat demuxer: list the files in a text file and run ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4. This only works when all clips have the same codec, resolution and frame rate.

Why doesn’t my FFmpeg cut start at the exact time?

With -c copy, FFmpeg can only cut on keyframes, so the cut moves to the nearest keyframe. Re-encode the clip, for example with -c:v libx264 -c:a aac, for a frame-accurate cut.

Which export settings should I use for AudiencePlayer?

An MP4 with 8-bit H.264 video at 1920×1080 and 25 fps, stereo AAC audio at 48 kHz, and only video and audio tracks. Avoid 10-bit or HDR, 5.1 audio and timecode tracks, and keep file names short and simple.

Why won’t my uploaded video play in Firefox or on iPhone?

The source file is most likely 10-bit, which can look fine on a Mac but isn’t supported everywhere. Export it again as 8-bit H.264, for example with -pix_fmt yuv420p, and upload it under a new file name.

BOOK A DEMO

Ready to start your own video platform?

See a live platform demo — 30 minutes, no obligations.