FFmpeg

Convert, trim, compress and stream audio and video

About

FFmpeg is the toolkit behind most video and audio software. Its command-line form handles nearly any format. Convert files, cut clips, extract sound, or shrink a video before sharing.

Install it

pkg install ffmpeg

Run this inside Termux. If the package is already present, pkg will say so and do nothing.

Commands worth knowing

6 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.

ffmpeg -i input.mp4 output.avi Convert a file from one format to another. The output extension picks the format.
ffmpeg -i input.mp4 -ss 00:00:10 -t 30 clip.mp4 Copy a thirty-second section starting ten seconds in. A quick way to cut a highlight.
ffmpeg -i input.mp4 -vn -acodec copy audio.m4a Pull the audio track out of a video without re-encoding it.
ffmpeg -i input.mp4 -vf scale=640:-1 small.mp4 Resize a video to a fixed width, keeping the aspect ratio. Handy for smaller files.
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3 Encode audio to MP3 at a chosen quality.
ffmpeg -i input.mp4 -r 1 -f image2 frame-%03d.png Extract one frame per second as numbered images.

Worked example

Run ffmpeg -i input.mp4 -ss 00:00:05 -t 10 -c copy clip.mp4 and this is what you should see.

termux
$ ffmpeg -i input.mp4 -ss 00:00:05 -t 10 -c copy clip.mp4
Input #0, mov,mp4,m4a, from 'input.mp4':
  Duration: 00:02:31.20, start: 0.000000, bitrate: 1204 kb/s
  Stream #0:0: Video: h264, 1280x720, 30 fps
  Stream #0:1: Audio: aac, 44100 Hz, stereo
Output #0, mp4, to 'clip.mp4':

Copying the streams avoids re-encoding, so the cut is fast and lossless.

Developed by

The FFmpeg team .