[FFmpeg-user] Quick (I hope) CLI question

Cley Faye cleyfaye at gmail.com
Tue Jul 25 00:09:05 EEST 2017

2017-07-24 22:24 GMT+02:00 Eric Downing <ripeart at gmail.com>:

> Hi!
> I have a folder of mixed format video files. I would like to:
> • copy video format
> • apply "ffmpeg-normalize" to the audio track(s), whilst preserving
> encoding
> • batch process so I can run the same command on the root folder
> For example:
> video1.mp4 (aac 5.1)
> video2.mkv (2 ch stereo)
> The issue is that I have a bunch of video files in varying video and audio
> formats that need loudness normalization. They number into the hundreds so
> running a single command to accommodate each files particular encoding is
> cumbersome. I want to preserve formatting for audio and video and apply
> normalization to the audio - in batch. Surely there must be a way to script
> this.
> I have found and understand the CLI language to do these things one by one,
> however I'm having a hard time concatenating these commands into a one
> liner. It seems that each time the CLI wants me to define an output format
> for the audio.
> Thank you for any suggestions.

​I'm not sure what you mean exactly, but if I understand correctly, here
are some pieces that might help you:

- If you don't specify an output codec (for either video or audio), it will
use some default settings
- If you specify "-c:a copy" (for audio) or "-c:v copy" (for video), you
can't use filtering as it will copy the stream as-is
- You can get file informations using ffprobe, in a script-friendly format
(like json)

By combining that, you can make a script that take a file, pass it to
ffprobe, get the audio codec and settings, and replicate an ffmpeg command
line that will copy video "-c:v copy" and use the appropriate audio codec.

More information about the ffmpeg-user mailing list