6

I'm currently using the following batch script to run an ffmpeg command:

@echo off
title Convert videos to Mp4 h.264 with FFMPEG. 
echo This script will find all video files of a given extension then make an mp4 h.264 file out of them.
set /p folder="Enter the folder path (cannot contain spaces; must have trailing slash \): "
set /p ft="Enter file type extension: "
set /p abitrate="Enter the audio bitrate in kbps (usually 48): "
set /p size="Enter video width and height (w:h) (usually 852:480): "
set /p vcrf="Enter the video crf value (usually 24): "
for %%f in (%folder%*.%ft%) do ffmpeg -i "%%f" -vf "scale=%size%,setsar=1" -crf %vcrf% -c:a aac -b:a %abitrate%k -ac 1 -movflags +faststart "%folder%%%~nf.mp4"
pause

The script says what it does in the description at the top. I built it to convert HDV .m2t files to web-ready mp4 files. If I extract the ffmpeg command from the script loop, it looks like this:

 ffmpeg -i input.m2t -vf "scale=852:480,setsar=1" -crf 24 -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4

I have some videos that need color correction, so I just want to toss a filter on them before I encode. I've fiddled with ffplay and determined that the look I want will require the following command, which has been modified from this answer:

 -vf eq=brightness=0.1:saturation=1.5

The issue I'm having is integrating this new -vf line into the main command. If I put it separately, ffmpeg ignores the first one for the second one. If it put them together in the quotes, it throws errors. I assume this is a syntax issue, but maybe not. The main command seems to be using commas for separators, but this new command uses colons.

0

2 Answers 2

7

Filter complex isn't needed. When a series of filters are to be applied to a single input in sequence, they are to be separated with a comma and passed along as a single filterchain (-vf, -af). You already did that with the setsar. So,

 ffmpeg -i input.m2t -vf "scale=852:480,setsar=1,eq=brightness=0.1:saturation=1.5" -crf 24 -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4
2
  • Hmmm. I thought I tried that one, but I'll double check. What would be the difference in using -vf instead of -filter_complex?
    – user3643
    Commented Apr 19, 2018 at 5:34
  • 2
    filter_complex is meant for filtering multiple streams in a combination of serial and/or parallel sequences. You can also combine those multiple streams, like when using overlay filter. For this specific case, ther's no difference, but the correct answer for your issue isn't that filter_complex is needed.
    – Gyan
    Commented Apr 19, 2018 at 6:03
0

Through trial and error, imitating different people's syntax used in similar commands, plus at the suggestion of an ffmpeg error message, I've come up with the following, and it worked as expected:

 ffmpeg -i input.m2t -filter_complex "scale=852:480,setsar=1","eq=brightness=0.1:saturation=1.5" -crf 24 -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4

The first change is -vf needed to be changed to -filter_complex. ffmpeg suggested this in an error message. After that, just separating the two commands with a comma, then also quoting the new command did the trick. So the syntax is very much like a csv.

If you have more insight, please post an answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.