When a movie is converted ffmpeg_converter keeps the ratio of the source video. I would like the option to override this and make ffmpeg convert the video to the exact size I want.

Quick fix is to comment these lines out in the conversion and snapshot generation functions:

$pad = ffmpeg_converter_get_padded_size($input_file, $size, 'padding');
$size = ffmpeg_converter_get_padded_size($input_file, $size, 'size');

Comments

zoo33’s picture

That's probably a good idea. It's officially on the to do-list.

jax’s picture

Well, I've also changed my mind somewhat. There should be a third option that the generated video is the size you want and the video respects the ratio. The rest should be padded. I'm not sure what the original idea of the module was but currently my video's aren't getting padded.

jax’s picture

StatusFileSize
new1.22 KB

Apparently the original code in ffmpeg_converter intended to do what I want but it didn't work because of a typo. Please find a patch attached which fixed the type.

jax’s picture

Status: Active » Needs work
StatusFileSize
new1.39 KB

That doesn't work. Padding size must also be a multiple of 2. New patch, but it needs some refactoring.

zoo33’s picture

Oh, that's a bad typo. Good catch.

Are you sure the padding needs to be a multiple of 2? In that case I think I should revert the code to what we had a couple of revisions ago:

<?php

      // Calculate new output size and padding.
      if ($orig_q > $dest_q) {
        // Width is the determining factor.
        $padding = round(($dest_y - ($dest_x / $orig_q)) / 2);
        // Make sure padding is divisible by 2, otherwise ffmpeg freaks out.
        $padding &= ~1;
        $pad = sprintf('-padtop %d -padbottom %d', $padding, $padding);
        $dest_y = round($dest_x / $orig_q);
      }
      elseif ($dest_q > $orig_q) {
        // Height is the determining factor.
        $padding = round(($dest_x - ($dest_y * $orig_q)) / 2);
        // Make sure padding is divisible by 2, otherwise ffmpeg freaks out.
        $padding &= ~1;
        $pad = sprintf('-padleft %d -padright %d', $padding, $padding);
        $dest_x = round($dest_y * $orig_q);
      }


?>

That doesn't take care of width and height being multiples of 2 though, but that's easy enough to add in.

jax’s picture

Yes, please try to convert a file with ffmpeg and an odd padbottom/padtop. It will spew an error, that is how I catched it. This is with ffmpeg:

FFmpeg version SVN-r18141, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libfaac --enable-libfaad --enable-libgsm --enable-libx264 --enable-libxvid --enable-libmp3lame
zoo33’s picture

Title: Provide option to choose whether to obey ratio » Output size and padding calculation broken
Category: feature » bug
Status: Needs work » Needs review
StatusFileSize
new1.75 KB

Please try this patch. It's supposed to make all calculated values multiples of 2.

zoo33’s picture

Status: Needs review » Fixed

I went ahead and committed this patch, even though it hasn't been properly tested. I think it's an improvement to the current situation in any case. Testing of the -dev version would be greatly appreciated!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.