Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Right now I'm using this to try and scale a 720p video down to 480p, the problem is the automatic width is selecting an odd number.

I am currently using -vf "scale=trunc(oh*a*2)/2:480 and it still selects 853 for the width. Any tips?

share|improve this question
1  
Never mind, solved it myself with -vf "scale=trunc(oh*a/2)*2:480" –  Peter Jun 24 '13 at 12:52
1  
You should post that as an answer below. Self-answering is encouraged here. –  Karan Jun 27 '13 at 1:21

1 Answer 1

The problem

The scale filter in ffmpeg can be provided just one dimension and it can automatically calculate the undeclared dimension if you use -1 as a value, such as with -vf scale=640:-1, but that can end of being an odd number.

ffmpeg uses libx264 to encode H.264 video. This encoder requires mod2 for width and height for 4:2:0 chroma subsampling; meaning that the width and height must be divisible by 2.

The solution

Use -2. It will:

  • Automatically calculate the correct value in relation to the declared dimension while preserving the aspect ratio.

  • Make the output divisible by 2. It will adjust the output if necessary.

Example

ffmpeg -i input.avi -vf scale=-2:480 output.mp4

Also see

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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