Hi Herman,
First let me thank you very much for your clear explanation. However, I am 
still missing something.
I have a video which is .mpg 720X480, 16:9  with the active video centred and 
smaller than the full frame. I tried two things:ffmpeg -i <In.mpg> -s hd720 -b 
8500k <out.mpg>ffmpeg -i <in.mpg> -vf crop=540:304 -vf scale=1280:720 -s hd720 
-b 8500k  <out.mpg>I don't see any difference in the resulting two videos when 
I play them back in any of the LINUX video players on my LINUX distribution, 
nor any of the video players I see in Windows.
What am I missing here?
Murray
--- On Sat, 3/24/12, Ichthyostega <p...@ichthyostega.de> wrote:

From: Ichthyostega <p...@ichthyostega.de>
Subject: Re: [CinCV] Confused about ffmpeg -vf crop=h:w:x:y
To: cinelerra@skolelinux.no
Received: Saturday, March 24, 2012, 3:42 PM

Am 23.03.2012 13:33, schrieb Murray Strome:
> I have read the man pages, looked at lots of descriptions on the net, ....but
> still have not figured out how to do the same thing with the new "-vf
> crop=h:w:x:y".

> I have tried lots of combinations, but everything I have tried so far 
> (especially when original had black bands both vertically and horizontally)
> seems to just move the video around within the larger frame but keeping the
> black bands.

yes, exactly. This is how it's expected to work. The "crop" command does
*only* crop the video (cut away some parts). It does nothing else. The old
style way used to do lots of additional magic stuff, which is considered bad
in software development. My guess it thats the reason why the ffmpeg devs
decided to change that.


> Perhaps I need to do something different to fill the frame. Here is an 
> example of a command I used to try to do this;

> ffmpeg -i input.mpg -vf crop=in_w:in_h-32:0:0  -t 150 -s hd720 -b 8500k 
> output.mpg

> I am using -s hd720 to create a 1280X720 HD video. input.mpg was 720X480 with
> the 16:9 aspect active video centred.in the 4:3 frame with black borders. The
> resulting output was 1280:720 16:9 with the video shifted down, but still not
> filling the frame.



Hello Murray,

so lets first analyse the parameters you gave, in order to understand
why this isn't working. And then lets build up a solution!

First off, you stated that the output frame should have a hd702 size, and
this is what you got. But you didn't specify explicitly how those larger
frames should be filled.

You wired the "crop filter" into the processing pipeline, telling ffmpeg
to make the cropped image the same witdth as the original (720), but to
make it by 32 lines smaller vertically. So your output window should be
720 x 448

Moreover, you stated, that this "crop window" should be located in the
upper left corner of your original, input frame (because you explicitly
set the x:y parameters to "0:0"). Since you're chopping away something
vertically, this effectively means that your image content gets shifted
down (I take it that this simple geometric fact is obvious. If it isn't
please ask, then I'll try to explain it)

To summarise, you somehow chopped away some content, asymmetrically at
the bottom. But you didn't specify anything how the larger output frames
are to be filled. As a result, you rely on some implicit behaviour of
ffmpeg.


Now, what do we actually want to achieve?

You didn't say so explicitly, but I'll assume just the following:
(1) we want to chop away content from the original, so that the
    resulting image has an 16:9 aspect
(2) we want to enlarge the copped video, so it fills the larger hd720 frame

and additionally, I'll assume that the original material is *not interlaced*


To achieve (1):
Lets just state that the cropped hight should comply to 16:9, thus:

in_w            16
----------   =  --
new_height       9

Which results in:

new_height = in_w * 9/16


Moreover, quoting from the manpage:

> The default value of x is "(in_w-out_w)/2", and the default value for y is 
> "(in_h-out_h)/2", which set the cropped area at the center of the input 
> image.

This is exactly what we want (right?), so we don't specify anything here.

Together we get

-vf crop=in_w:in_w*9/16



To achieve (2):
This first step should result in an cropped image of size 720 x 405
But actually we want an output size of 1280 x 720

Which means we have to scale up the cropped image.

-wf scale=1280:720


If I recall correct, ffmpeg will automatically insert such an scale
video filter to reach the output format. Actually I never tried.
I never rely on automagical things, I always try to be explicit,
so to avoid any surprises.

So, just by this reasoning, the command line to try should be

ffmpeg -i input.mpg -vf crop=in_w:in_w*9/16 -vf scale=1280:720  \
       -t 150 -s hd720 -b 8500k output.mpg


hope this helps

Cheers
Hermann V.

Reply via email to