Skip to main content
Photography & VideoVideo Production66 lines

FFmpeg Transcoding and Audio

Use FFmpeg and ffprobe to inspect media, remux or transcode selected streams, normalize program loudness, and validate a playable delivery copy.

Quick Summary19 lines
Start with the source, requested delivery format, and the intended picture, audio and subtitle tracks. Ask for the receiving specification when codecs, channel layout, loudness or frame rate are contractual. Treat the source as read-only. Create a new output path, keep the original basename in a conversion log, and use `-n` to prevent overwrites. Require a new artifact and inspect diagnostics even when the process reports success.

## Key Points

- [FFmpeg stream selection and encoding](https://ffmpeg.org/ffmpeg.html)
- [ffprobe reference](https://ffmpeg.org/ffprobe.html)
- [FFmpeg loudnorm filter](https://ffmpeg.org/ffmpeg-filters.html#loudnorm)

## Quick Example

```sh
ffprobe -v error -show_format -show_streams -of json source.mkv
```

```sh
ffmpeg -n -i source.mkv -map 0:0 -map 0:2 -c copy remux.mp4
```
skilldb get video-production-skills/ffmpeg-transcoding-and-audioFull skill: 66 lines
Paste into your CLAUDE.md or agent config

FFmpeg Transcoding and Audio

Start with the source, requested delivery format, and the intended picture, audio and subtitle tracks. Ask for the receiving specification when codecs, channel layout, loudness or frame rate are contractual. Treat the source as read-only. Create a new output path, keep the original basename in a conversion log, and use -n to prevent overwrites. Require a new artifact and inspect diagnostics even when the process reports success.

Inventory the streams

ffprobe -v error -show_format -show_streams -of json source.mkv

Record the stream index and language of each wanted track. Check video dimensions, rotation, frame rate, pixel format and color tags. Record each audio track’s layout and sample rate. An attached cover image can look like video to a broad selector. Prefer explicit indices when a file has more than one viable picture or audio stream. Write the desired output ordering down before choosing maps.

Choose a remux or transcode

Use stream copy when the receiving container supports the selected streams and their existing encoding meets the delivery spec. Stream copy preserves encoded data and cannot apply scaling, audio normalization or another decoded filter. For a compatible picture and one selected audio track:

ffmpeg -n -i source.mkv -map 0:0 -map 0:2 -c copy remux.mp4

Replace the indexes after probing the actual file. For an SDR, even-sized H.264/AAC compatibility copy using the first real video and first audio, use this starting point:

ffmpeg -n -i source.mkv -map 0:V:0 -map 0:a:0 -c:v libx264 -crf 20 -pix_fmt yuv420p -c:a aac -b:a 192k -movflags +faststart delivery.mp4

Check that the build includes the encoder. For silent sources, omit the audio map deliberately. Specify subtitle selection and convert or deliver separately according to format support. HDR sources, anamorphic sources and non-stereo mixes need an explicit transformation plan. Avoid forcing frame rate, changing color tags or downmixing by default.

Measure and normalize the selected program

For a measured two-pass loudnorm workflow, apply the delivery targets to the intended audio track. This example uses -16 LUFS integrated, LRA 11 and -1.5 dBTP for an illustrative stereo delivery:

ffmpeg -hide_banner -i source.mkv -map 0:a:0 -af loudnorm=I=-16:LRA=11:TP=-1.5:print_format=json -f null -

Read input_i, input_lra, input_tp, input_thresh and target_offset from the filter output. Supply them as measured_I, measured_LRA, measured_TP, measured_thresh and offset in the second-pass filter with the same targets. Set the output audio sample rate explicitly, such as -ar 48000. If measurements are nonfinite, review silence and track selection. Check the reported normalization type because FFmpeg may use dynamic mode when the linear targets are infeasible.

Validate the delivery

Probe the exported file again. Compare stream order, duration, language and channel layout with the specification. When the delivery requires audio, map it explicitly so a missing audio track fails validation.

ffmpeg -nostdin -v error -xerror -i delivery.mp4 -map 0:V:0 -map 0:a:0 -f null -

For an intentionally silent delivery, confirm the probe shows zero audio tracks and decode the picture alone.

ffmpeg -nostdin -v error -xerror -i silent-delivery.mp4 -map 0:V:0 -f null -

For each additional required track, select its stream index explicitly and check it separately. Treat a nonzero decode exit as a failed check. Remeasure encoded audio when the delivery has a loudness tolerance. Sample the beginning, middle and end in the target player for color and subtitles, and for sync and intelligibility when audio is present. Keep logs and report any dropped streams or intentional transformations.

Sources

Install this skill directly: skilldb add video-production-skills

Get CLI access →

Related Skills

Generative Video Shot Consistency

Plan text-to-video and image-to-video shots across providers, anchor recurring subjects with approved references, and verify visual continuity at each edit.

Video Production•34L

Live Streaming

Techniques for producing professional live video streams, from technical setup and encoding to real-time audience engagement. Covers multi-camera workflows, redundancy planning, platform-specific considerations, and the discipline of broadcasting without an edit button.

Video Production•57L

Motion Graphics

Techniques for creating animated graphic elements for video, including titles, lower thirds, transitions, data visualizations, and explanatory animations. Covers design principles, animation timing, and the discipline of enhancing content without overwhelming it.

Video Production•58L

Veo Shot Prompting

Choose a Google Veo text, first-frame or subject-reference mode, write a testable short shot prompt, and verify the resulting video and audio.

Video Production•34L

Video Editing

Techniques for editing video content into compelling visual stories. Covers cutting, pacing, transitions, narrative structure in the timeline, and the editorial judgment that transforms raw footage into focused, emotionally engaging sequences.

Video Production•57L

Video Lighting

Techniques for lighting video productions to create mood, dimension, and focus. Covers three-point setups, practical and motivated lighting, color temperature management, and the craft of making artificial light feel natural while guiding the viewer's eye.

Video Production•57L