[Kdenlive-devel] Pixel aspect ratio as fraction

Dan Dennedy dan at dennedy.org
Sun Jan 25 18:58:06 UTC 2009


On Fri, Jan 23, 2009 at 5:27 AM, jb <jb at kdenlive.org> wrote:
> On Friday 23 January 2009 08.32:15 Simon Eugster wrote:
>> Hi together,
>>
>> In the IRC madsdyd and me have been discussing about the Clip
>> properties dialog. The pixel aspect ratio is given as float here, but
>> in the Profiles manager the user has to set a fraction. I tried to
>> understand where the value for the PAR comes from, but I couldn't find
>> the source o.O
>>
>> Where is it? I'd like to make it displaying a fraction as exercise to
>> get used to kdenlive and C++.
>
> The clip properties are fetched when a clip is inserted by:
>
> void Render::getFileProperties(const QDomElement &xml, const QString &clipId)
> in file renderer.cpp
>
> Here we build a QMap <QString, QString> which lists all the clip properties
>
>
> At line 571, you can see:
>
>        filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio");
>
>        frame is the MLT frame for the clip, which has an "aspect_ratio" property.
>
>        Not sure we can get the info from MLT as a fraction here...
>

It should be a fraction aka rational. Part of the problem was that
there is not rational property type. We were too lazy and lacking
foresight to add it in the beginning of MLT. Now, this "aspect_ratio"
property is used in a lot of places through MLT. Recursively grep the
source for it (inlcuding double quotes) to see what I mean. I could
change this to aspect_ratio_num and aspect_ratio_den much like the
profile does. However, I am hesitant to heap a half-ass solution onto
something that was half-ass to begin with (in hindsight). If I have to
touch this much code, I may as well introduce a proper rational type
and property. I have just added this to the MLT ToDo list.

Perhaps a simple workaround for the GUI exists in the meantime. It is
not too difficult to convert between fractions and float. The less
trivial is float-to-rational if you want the most reduced form. See
this FFmpeg code:
http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/rational_8c-source.html

The inverse is a simple matter of casting and dividing.

-- 
+-DRD-+




More information about the Kdenlive mailing list