lettier / gifcurry

😎 The open-source, Haskell-built video editor for GIF makers.
https://lettier.github.io/gifcurry
BSD 3-Clause "New" or "Revised" License
1.36k stars 56 forks source link

wrong placement of text #49

Closed wilx closed 3 years ago

wilx commented 5 years ago

The text added into GIF seems to be placed on the other side. As if it was counted as offset from one side of the frame but the wrong one. See attached screenshot. This was produced with the 6.0.0.0 AppImage.

Screenshot_2019-11-20_00-16-59

lettier commented 5 years ago

Hello @wilx

Unfortunately, I cannot reproduce this.

Screenshot_2019-11-21_05-50-54

If you switch it to the other side, does it still reverse? When centered, is the result centered? Was the result cropped?

:+1:

wilx commented 5 years ago

Yes, I cropped the video to the dude's cam only.

wilx commented 5 years ago

I just tried again and I can reproduced it. Here are the settings printed on console:

  - FILE IO:
    - Input File:    /home/wilx/DS3 crashed-571356927.mp4
    - Output File:   /home/wilx/test.gif
    - Save As Video: No
  - TIME:
    - Start Second: 5.265
    - End   Second: 6.511
  - OUTPUT FILE SIZE:
    - Width:       500px
    - FPS:         60
    - Color Count: 256
    - Dither:      False
  - TEXT:
    - Text: Test
      - Font:
        - Family:  Sans
        - Size:    31
        - Style:   normal
        - Stretch: normal
        - Weight:  400
      - Time:
        - Start Second: 0.000
        - End   Second: 21.061
      - Translation:
        - Origin: Center
        - X:      -0.47000000000000025
        - Y:      0.46000000000000024
      - Rotation:
        - Degrees: 0
      - Outline:
        - Size:  5
        - Color: rgb(0,0,0)
      - Fill:
        - Color: rgb(255,255,255)
  - CROP:
    - Left:   0.000
    - Right:  0.750
    - Top:    0.660
    - Bottom: 0.000
lettier commented 5 years ago

Hello @wilx

I recreated the setup using a still from the screenshot but I still couldn't reproduce the issue.

gif2

Does this occur with other videos or just this one in particular?

:+1:

wilx commented 5 years ago

I just tested with a different video and it still is reproducible. Is it possible it is caused by ImageMagick?

> convert -version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib
lettier commented 4 years ago

Hello @wilx,

ImageMagick is the program used to add the text. I'm not sure what the size of the video is but here are the commands Gifcurry would send:

This command extracts the frames. You'll have to adjust the scale here to match your video and change the extraction folder.

ffmpeg -nostats -loglevel error -an -ss 5.265 -i /home/wilx/DS3 crashed-571356927.mp4 -t 1.246 -r 60 -q:v 31 -vf scale=2000.0:-1,crop=w=iw*(1-0.75):h=ih*(1-0.66):x=iw*0.0:y=ih*0.66:exact=1 -start_number 0 -f image2 /home/wilx/.cache/gifcurry/gifcurry-frames4946/extracted-frames_%010d.png

This command adds the text to each frame. There would be one for each extracted frame. You'll have to change to the extraction folder set up above. The pointsize will have to be adjusted to match the original video size.

convert -quiet /home/wilx/.cache/gifcurry/gifcurry-frames4946/extracted-frames_0000000000.png -family DejaVu Sans -style normal -stretch normal -weight 400 -pointsize 88 -gravity Center -density 96 -strokewidth 5 -stroke rgb(0,0,0) -annotate 0x0-190+145 OH WELL -stroke none -fill rgb(255,255,255) -annotate 0x0-190+145 OH WELL -set colorspace sRGB /home/wilx/.cache/gifcurry/gifcurry-frames4946/extracted-frames_0000000000.png

This command merges all of the frames back together again into a GIF. You'll have to change to the extraction folder set up above.

convert -quiet -delay 2 /home/wilx/.cache/gifcurry/gifcurry-frames4946/extracted-frames_*.png +dither -colors 256 -fuzz 1% -layers OptimizeFrame -layers OptimizeTransparency -loop 0 +map -set colorspace sRGB /home/wilx/test.gif

See if those commands reproduce the issue and at what point in the process.

:+1:

wilx commented 4 years ago

I have reproduced the issue with the middle convert command. I have only changed point size.

convert -quiet /home/wilx/.cache/gifcurry/gifcurry-frames4946/extracted-frames_0000000000.png -family 'DejaVu Sans' -style normal -stretch normal -weight 400 -pointsize 10 -gravity Center -density 96 -strokewidth 5 -stroke 'rgb(0,0,0)' -annotate '0x0-190+145' 'OH WELL' -stroke none -fill 'rgb(255,255,255)' -annotate '0x0-190+145' 'OH WELL' -set colorspace sRGB /home/wilx/.cache/gifcurry/gifcurry-frames4946/test.png

test

gfotiades commented 4 years ago

I'm having the same issue.

@wilx : You said you reproduced the issue, but @lettier seems to not be able to. Which version of imagemagick are you guys running?

I'm using ImageMagick 6.9.10-23 and I have the weird placement issue.

wilx commented 4 years ago

@gfotiades convert -version says ImageMagick 6.9.10-23 Q16 x86_64 20190101.

gfotiades commented 4 years ago

@wilx Mine is exactly the same. I'm guessing you're *buntu based like me (Lubuntu)?

@lettier Curious what your version is? Not sure if this is a bug in imagemagick or if the code here needs to be modified to adapt to new command line for imagemagick.

wilx commented 4 years ago

@gfotiades Yes, it is Ubuntu/Xubuntu.

mynameisbradley commented 3 years ago

I am having this same situation with text placement. Anything with a negative horizontal value seems to end up either at the positive value OR sometimes it just remains centered. The preview shows the text in the correct location, but the final gif is wrong.

Additionally, sometimes the chosen font does not make it onto the final gif that is produced. I'm still investigating why this might be happening, but if anyone has suggestions I am happy to hear them.

gfotiades commented 3 years ago

@lettier I see you closed this. Was this fixed? @wilx said he was able to reproduce with the image magick cmd you gave, pointing to an image magick problem (either a feature change or a bug fix). Perhaps if it's not fixed we need to create a branch in cmd construction to support multiple versions of image magick?