Photo to Full HD video crop and scale width rounding error

Bug #1264653 reported by Michael Paul Korthals
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenShot Video Editor
New
Undecided
Unassigned

Bug Description

Architecture (64 bits or 32 bits) : 32 bits
Operating System & version: Ubuntu 13.10 "saucy"
Installation Method : via Ubuntu Software Center
Version of Openshot installed : 1.4.3
BZR Revision used (if any) : None
MLT/melt version: I do not know, what this mean
FFmpeg (i.e.libavcodec) version : avconv version 0.8.9-6:0.8.9-0ubuntu0.13.10.1
FFmpeg installation : Not installed.

This bug can be by 100% reproduced through following actions:
1) Set the project default size in the preferences to 1080p 25 fps
2) Set the default clip length in the prefernces to 7 seconds
3) Create a new project
4) Create 3 tracks
5) Import a soundfile of adequate length seconds duration to track 0
6) Import 2 black images and a photo (5184x3456 18 megapixel) into the project (track 1 and 2) incl. cross-fades
7) Edit the clip layout keyframes to zoom in or zoom out the photo in every clip
8) Export the video using the mp4 (h.264) codec at high quality
9) Play the buggy video in vlc video player in full screen mode: vlc "<FilePath>" -f

On the right side of the player pixel column 1920 disappears and reappears frequently. If the still file name is displayed by vlc player you can see that the whole frame is freqently chattering by one pixel from the left to the right and back again.

This chattering reduces the subjective enjoyment of the viewer by more than 66 %. From my point of view, a failure like this is not an option. So I ask you to solve this problem before you launch OpenShot V.2.0.

avprobe version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2007-2013 the Libav developers
  built on Nov 9 2013 19:15:22 with gcc 4.8.1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Test1.mp4':
  Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf53.21.1
  Duration: 00:00:11.72, start: 0.000000, bitrate: 7170 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 6973 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Stream #0.1(und): Audio: ac3, 44100 Hz, stereo, s16, 191 kb/s

This problem is also visible while playing the timeline (preview) within OpenShot.

This may be a problem within the libav library you use in the OpenShot crop and scale function.

Please have a look on the crop and scale function in my own application KeyframeEditor:
https://launchpad.net/keyframeeditor

I detected and reproduced the the same libav problem, when cropping and scaling with avconv in KeyframeEditor.

PROPOSED WORKAROUND:
I worked around this problem in KeyframeEditor by using ImageMagick for cropping and scaling and to
give the position and size parameters as exact float values to ImageMagick.

Test script:
#!/bin/bash
#
# Custom crop and scale method
#
# Interface
echo "Image input path ....: $1"
echo "Crop width ..........: $2"
echo "Crop height .........: $3"
echo "Crop x ..............: $4"
echo "Crop y ..............: $5"
echo "Project width .......: $6"
echo "Project height ......: $7"
echo "Image output path ...: $8"
#
# Note: This script must be capable to overwrite the output path without user interaction.
# Note: This script must be capable to to overwrite the input path by the output path.
#
# Action
# Using ImageMagick
convert "$1" -crop "$2x$3+$4+$5" -resize "$6x$7" "$8"
EXITCODE=$?
if [ ! "$EXITCODE" == "0" ]; then
   echo "ERROR: convert canceled with exit code $EXITCODE."
   exit 1
fi
echo "Complete."
# Exit
exit 0

Inside Keyframe editor I call "convert" only one time and order to render the whole clip in one pass. This is more efficient than to call convert at cropping every frame.

See KeyframeEditor.py / object ExportVideoFrame / thread handler CropImagesFromPhoto / after elif self.sCropScaleTool == "ImageMagick".

Currently I bypass this problem within OpenShot 1.4.3 by using the methods I described in Chapter III and IV of the KeyframEditor tutorial, which is available in the KeyframeEditor README file.

Revision history for this message
Michael Paul Korthals (michael-paul-korthals) wrote :
Revision history for this message
Olivier Girard (eolinwen) wrote :

Hi Michael,

Several interesting things here.

I've not yet tested and I'am not sure to reproduce it because I don't have a picture so big.....

I'm not sure that you choice the good project at the beginning. You should create your own with the tool created for this task and try again with this one. When you use a preset at the beginning, it is for the type of clips that you will use in this one. It doesn't concern the export, it is two different things.

Interresting application (i.e. Keyframeeditor) that we don't know his existence.

Until now and until the 2.0.0, OS does'nt have a goog keyframe editor (i.e not precise). This situation will change with our own video framework (i.e Libopenshot) => we have a really nice keyframe editor very powerful and then the 2.0.0 version.

Another word on this one =< he is based on Imagemagick too.

I can't watch the video (i.e the video file seems to be corrupted !!!!!)

I'm not sure that the fact to use avconv instead of FFmpeg is a good solution. You should try to use FFmpeg (i.e the sven PPA =>http://openshotusers.com/forum/viewtopic.php?f=12&t=1261 and http://openshotusers.com/forum/viewtopic.php?f=12&t=1261)

Thanks a lot for the interest that you have in OS.

Revision history for this message
Michael Paul Korthals (michael-paul-korthals) wrote :
Download full text (3.8 KiB)

Hi Cenwen,
thanks for your reply.

I add the copyright protected original photo to this posting for you for testing purposes only.
Copyright (c) 2013 Michael Paul Korthals. All rights reserved.

To play the test video in firefox fails. I do not know why.
Please download the test video to your video folder.
Select Full HD 1920x1080 screen resolution on your system.
The try some of these commands in a terminal, depending on, which video players you have installed on your system:
(replace %s by the absolute path to the test video)
avplay "%s" -fs
ffplay "%s" -fs
mplayer -fs "%s"
totem --fullscreen "%s"
vlc "%s" -f
On my Ubuntu 13.10 'saucy' it works.

I did not not really understand the 3rd paragraph of you posting and I feel that I shoud explain my goals to you:

I'm a hobby photographer. I'm inspired to document the beautiness of nature for the future in a timeless way. Here is my open artwork:
http://www.youtube.com/user/MichaelPaulKorthals

My camera is a Cannon 600D (Photo: 18 megapixels; Video: 1080p 40MB bitrate; Audio: Stereo 16bit PCM uncompressed).

Up to know I produced my videos in windows using ImageMagick, ffmpeg, mencoder using my private production line scripted in AutoIt.

Currently I am working to build up and to maximize the quality of my private video production line in Linux. My current artwork task list contains productions of high quality videos from my basis material from Iceland (a lot of more issues) , South of England, Istanbul and Austria ("Danube Meadows National Park" in four seasons).

I now integrated OpenShot into my production line, because it is easily to use for timeline, crossfades and titles. Thanks for your ingenious work.

The KeyframeEditor I use for the high quality pre production of clips and as high quality video export final stage.

My production quality level for video is 1080p lossless .png image sequence and for audio lossless 16 bit PCM stereo 48 kHz uncompressed .wav. My current video export quality level for the video player is this:

avprobe version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2007-2013 the Libav developers
  built on Nov 9 2013 19:15:22 with gcc 4.8.1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MVI_4911.mp4':
  Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf53.21.1
  Duration: 00:00:27.02, start: 0.000000, bitrate: 39910 kb/s
    Stream #0.0(und): Video: h264 (Main), yuv420p, 1920x1080, 39621 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Stream #0.1(und): Audio: mp3, 48000 Hz, 2 channels, s16, 320 kb/s

Fast rendering is no requirement for me. I have much time to render the end results. Normally I let render overnight and I enjoy my end result videos next day at breakfeast time.

Because OpenShot 1.4.3 does not meet my requirements for a comfortable keyframe editor and the video output quality, I created KeyframeEditor to reach the quality level, I currently imagine.

My strategic goal is: Less coding -> more artwork at maximum quality level Full HD. So I allow you to use the features design and phyton code I produced for the KeyframeEditor and it's video export final stage to enhance OpenS...

Read more...

Revision history for this message
Michael Paul Korthals (michael-paul-korthals) wrote :

Hi Cenwen,
I just tested and the bug is there after installing ffmpeg.
Nothing has changed. The bug is visible in the new Test1a.mp4 (see attachement).

Kind regards
Michael Paul

P.S.: The ffprobe return from Test1a.mp4

ffprobe version 0.10.9-7:0.10.9-1~saucy1 Copyright (c) 2007-2013 the FFmpeg developers
  built on Oct 18 2013 17:31:55 with gcc 4.8.1
  configuration: <Michael Paul Korthals: deleted, because the url was too long for the launchpad server>
  libavutil 51. 35.100 / 51. 35.100
  libavcodec 53. 61.100 / 53. 61.100
  libavformat 53. 32.100 / 53. 32.100
  libavdevice 53. 4.100 / 53. 4.100
  libavfilter 2. 61.100 / 2. 61.100
  libswscale 2. 1.100 / 2. 1.100
  libswresample 0. 6.100 / 0. 6.100
  libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/paul/Videos/Test1a.mp4':
  Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    encoder : Lavf53.32.100
  Duration: 00:00:11.52, start: 0.000000, bitrate: 6978 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 6781 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      handler_name : VideoHandler
    Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 44100 Hz, stereo, s16, 192 kb/s
    Metadata:
      handler_name :

Revision history for this message
Olivier Girard (eolinwen) wrote :

Hi Michael,

Okay for the photo.

I've downloaded the video (the second with FFmpeg). Always impossible to watch this one.

>>>In this way I'm interested in your OpenShot 2.0 phyton library. May be it contains some further possibilities I could integrate in my new private video production line. Where or when I can find it?

Not sure because our library (i.e our new video framework) is created in C++.

>>>Now I hope to finish my next Iceland video "Iceland Elements - Seeds of the Wind" in the next weeks. It will be my first work on my new production line including OpenShot for the first time.

I've just take a quick look until now but I like your work. Earth is so beautiful. The butterffly is a "Tabac d'Espagne" (Argynnis Paphia) Spain tabacco.

I test tomorrow, I hope. Happy New Year Michael.

Revision history for this message
Olivier Girard (eolinwen) wrote :

I would like to know if Black images are in svg format, png and which size ?
I've take a look at your second video with my main player : QMplay2 and I've noticed ........nothing.
I continue my test soon you'll give me more explanations about this black images.
Thanks.

Revision history for this message
Olivier Girard (eolinwen) wrote :

How do you put blacks images and butterfly image on the timeline ?
a black image (on track 1) the butterfly image (ont track 2) and again a black image (on track 1) ?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.