Learn FFmpeg - Basic Commands & Transcoding
Episode 3 of 23

Learn FFmpeg - Basic Commands & Transcoding

Start typing real FFmpeg commands: the basic ffmpeg -i input output syntax, converting MP4 to MKV and WebM formats, the difference between stream copy and a full re-encode, and the habit of reading file metadata and duration via ffprobe before deciding on a command.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

After understanding FFmpeg's architecture in episode 2 — the demux-decode-filter-encode-mux pipeline and the stream concept — it's now time to type real commands. This episode is your "first day on the job": you'll learn the basic syntax, do format conversions, and tell apart the two strategies that most determine the result — stream copy and re-encode.

Why does this matter? Because most beginner FFmpeg mistakes don't come from complicated options, but from misunderstanding two things: the input-output order, and whether data is really re-processed or merely copied.

Basic Syntax

All of FFmpeg starts from one pattern: input first, output last.

Pola dasar
ffmpeg [opsi-input] -i INPUT [opsi-output] OUTPUT

The simplest example — copy (without re-encoding) one file to another format:

Konversi container paling sederhana
ffmpeg -i sample.mp4 sample.mkv

This command reads sample.mp4, then writes sample.mkv. Because there are no codec options, FFmpeg picks defaults: libx264 for video and aac for audio, so re-encoding happens. For quick tasks, this is often undesirable — we cover stream copy below.

Important

The order cannot be reversed: ffmpeg sample.mp4 -i sample.mkv will confuse FFmpeg and fail. Always write -i along with its input before the output. This is rule number one to internalize.

Format Conversion: MP4, MKV, and WebM

Now let's break down the term we only mentioned briefly in episode 0: codec vs container. Format conversion can mean two very different things:

  1. Changing only the container — the stream content stays, only the "packaging" changes.
  2. Changing the codec at the same time — the data is truly decoded and re-encoded.

For pure container-swapping tasks, use stream copy:

MP4 ke MKV tanpa re-encode
ffmpeg -i sample.mp4 -c copy sample.mkv
MP4 ke WebM dengan re-encode
ffmpeg -i sample.mp4 -c:v libvpx-vp9 -c:a libopus sample.webm

The first completes in seconds because data is only copied. The second takes time because H.264 video must be decoded then re-encoded into VP9 and Opus — the standard codec pair for WebM.

Stream Copy vs Re-encode

This is one of the decisions you'll make most often. Understand this table early:

Aspect-c copyRe-encode
ProcessData copied rawDecode + re-encode
SpeedVery fastSlow, depending on codec
QualityUnchangedPotentially reduced
File sizeGenerally unchangedCan be reduced
Use caseChange container, join streamsChange codec, resolution, bitrate

-c copy is like photocopying an original document; re-encoding is like retyping the document on a new computer. Photocopying is instant but can't change content; retyping is slow but you can edit anything. Choose based on need, not habit.

Extending the options: -c:v selects the video codec, -c:a selects the audio codec. Example of re-encoding video only, keeping audio copied:

Video re-encode, audio copy
ffmpeg -i sample.mp4 -c:v libx264 -crf 23 -c:a copy sample-h264.mp4

Reading Media with ffprobe

Before typing any command, a good technician inspects the raw material first. That's the job of ffprobe — the media inspector we met in episode 2. Start with the most concise form:

Lihat format dan durasi
ffprobe -hide_banner sample.mp4
Contoh output
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : isom
  Duration: 00:00:10.00, start: 0.000000, bitrate: 123 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360
  Stream #0:1[0x1](und): Audio: aac (LC) (mp4a / 0x6134706d), 44100 Hz, stereo, fltp

From this output you can directly read duration, bitrate, video resolution, and audio codec — exactly the information needed before deciding on a transcode strategy.

For a more structured form that's easy to use in scripts, combine -show_format with -show_streams:

Format terstruktur untuk script
ffprobe -hide_banner -show_format -show_streams sample.mp4

Controlling FFmpeg Output

These two options you'll use every day to keep the terminal clean and informative:

OptionFunction
-hide_bannerRemove the version banner and build config
-loglevelSet detail level: quiet, error, warning, info, debug

The example most used in production — showing only errors:

Mode senyap, error saja
ffmpeg -hide_banner -loglevel error -i sample.mp4 -c copy sample.mkv

With -loglevel error, the terminal only shouts when there's a problem — perfect for scripts and CI/CD that must stay clean.

Tip

Always test on a small file or a short clip before processing a batch: ffmpeg -ss 00:00:00 -t 10 -i sample.mp4 -c copy test.mp4 grabs the first 10 seconds in an instant — the best companion for trying new options without waiting long.

Conclusion

In episode 3, you've written your first real FFmpeg commands: the basic syntax, MP4-MKV-WebM container conversion, the difference between -c copy and re-encoding, reading metadata via ffprobe, and controlling output with -hide_banner and -loglevel.

Key takeaways:

  • The basic pattern: ffmpeg [opsi-input] -i INPUT [opsi-output] OUTPUT.
  • Pure container conversion: -c copy; change codec: re-encode with -c:v and -c:a.
  • -c copy is a photocopy, re-encode is retyping — choose according to need.
  • ffprobe is a good habit before every transcode: read duration, bitrate, and streams first.
  • -hide_banner and -loglevel error keep output clean.

In the next episode 4, we enter the heart of video quality: video encoding & codecs — understanding H.264, H.265/HEVC, VP9, and AV1, the role of -crf and -preset, two-pass strategy, and setting resolution, fps, and GOP. See you in episode 4!

Learn FFmpeg - Basic Commands & Transcoding | Learn FFmpeg