Skip to content

Scaling incorrect when using SCALE_NONE and scale_x / scale_y #754

@jeffski

Description

@jeffski

When using SCALE_NONE and then applying scale_x and/or scale_y it appears as if images and videos are scaled twice. For example an image that is 1000px x 500px with a scale of 0.5 will result in an image displaying in the rendered video at 250px x 125px, not 500px x 250px.

The code below demonstrates:

Clip clip1(new QtImageReader("wave-1000x500.jpg"));
clip1.Position(0);
clip1.Layer(1);
clip1.Start(0);
clip1.End(5);
clip1.scale = openshot::SCALE_NONE;

Clip clip2(new QtImageReader("wave-1000x500.jpg"));
clip2.Position(5);
clip2.Layer(1);
clip2.Start(0);
clip2.End(5);
clip2.scale = openshot::SCALE_NONE;
clip2.scale_x.AddPoint(0.5);
clip2.scale_y.AddPoint(0.5);

Timeline timeline(1280, 720, Fraction(25,1), 44100, 2, LAYOUT_STEREO);
timeline.AddClip(&clip1);
timeline.AddClip(&clip2);
timeline.Open();

FFmpegWriter writer("output.mp4");
writer.SetAudioOptions(true, "aac", 44100, 2, LAYOUT_STEREO, 128000);
writer.SetVideoOptions(true, "libx264", Fraction(25, 1), 1280, 720, Fraction(1,1), false, false, 0);
writer.PrepareStreams();
writer.SetOption(VIDEO_STREAM, "crf", "23" );
writer.WriteHeader();
writer.Open();
freopen("/dev/null", "w", stderr);
writer.WriteFrame(&timeline, 1, 10 * 25);

writer.Close();
timeline.Close();

This is the test image used (1000px x 500px)
wave-1000x500.jpg

The output video is here (1280px x 720px):
output.mp4

  • The first clip renders at a size of 1000 x 500px as expected.
  • The second clip renders at 1/4 the size at 250 x 125px - I would expect the video to be half the size of the original (scale: 0.5) at 500 x 250px

I have tested this with FFMpegReader and the issue is the same.

Somewhere the scale must be being run twice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleThis issue has not had any activity in 90 days :(

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions