Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageMagick error - Ubuntu 16.04 #831

Closed
marty331 opened this issue Jul 18, 2018 · 3 comments
Closed

ImageMagick error - Ubuntu 16.04 #831

marty331 opened this issue Jul 18, 2018 · 3 comments

Comments

@marty331
Copy link

I know this has been reported but I've gone through every issue and can't resolve it.

  1. Yes ImageMagick is installed, version:
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP 
Delegates (built-in): bzlib djvu fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib```

2.  In config_defaults.py I've specified where both FFMPEG_BINARY and IMAGEMAGICK_BINARY are located:
```#FFMPEG_BINARY = os.getenv('FFMPEG_BINARY', 'ffmpeg-imageio')
#IMAGEMAGICK_BINARY = os.getenv('IMAGEMAGICK_BINARY', 'auto-detect')
FFMPEG_BINARY = r"/usr/bin/ffmpeg"
IMAGEMAGICK_BINARY = r"/usr/bin/convert"

And when I run, I'm getting the error below (any help will be greatly appreciated!):

OSError: MoviePy Error: creation of None failed because of the following error:

[Errno 2] No such file or directory: 'unset'.

.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windo$
[pid: 3040|app: 0|req: 1/1] 73.6.152.180 () {48 vars in 2619 bytes} [Wed Jul 18 03:35:01 2018] GET /$

@Zulko
Copy link
Owner

Zulko commented Jul 21, 2018

Can you share your code, or at least the last lines in which you write a video file ?

@marty331
Copy link
Author

marty331 commented Jul 21, 2018

Doing this from my phone so I apologise for formatting.

def create_hightlights(assets):
    logger.debug('create highlights fun')
    print('create highlights fun')
    #global user_path
    #print('user path = {}'.format(user_path))
    #logger.debug('user path = {}'.format(user_path))
    #time.sleep(30)
    logger.debug('crate highlights assets ={}'.format(assets))
    logger.debug('music = {}'.format(assets['music']))
    audio = (path + 'music/5150.mp3')
    logger.debug('create hightlights ={} {}'.format(assets, audio))
    new_clips = []
    bumper = VideoFileClip(path + 'assets/FRbumper.mp4', audio=False)
    new_clips.append(bumper)
    #video length = 5 sec bump + 5.5 sec out
    video_length = 10.5
    for c in assets['clips']:
        logger.debug('c ={}'.format(c))
        logger.debug('center ={}'.format(c['annotate']))
        video_length = video_length + (c['stop'] - c['start']) + 2
        wip = VideoFileClip(path + 'assets/' + c['clip'] + '.mp4', audio=False).subclip(c['start'], c['stop'])
        clip_name = c['clip']
        print('show = {}'.format(c['annotate']['show']))
        logger.debug('show = {}'.format(c['annotate']['show']))
        if (c['annotate']['show'] == 'True'):
            print(c['annotate']['time'])
            print(c['start'])
            freeze_time = float(c['annotate']['time']) - float(c['start'])
            print('freeze time = {}'.format(freeze_time))
            wipa = vfx.freeze(wip, t=freeze_time, freeze_duration=2.0)
            logger.debug('center ={}'.format(c['annotate']['centerPosition']))
            logger.debug('cp 0 {}'.format(c['annotate']['centerPosition'][0]))
            logger.debug('cp 1 {}'.format(c['annotate']['centerPosition'][1]))
            img_width = c['annotate']['topLeft'][0] - c['annotate']['bottomRight'][0]
            img_height = c['annotate']['topLeft'][1] - c['annotate']['bottomRight'][1]
            position = ((c['annotate']['centerPosition'][0] + (img_width/2)), ((c['annotate']['centerPosition'][1])+(img_height/2)))
            # position = (c['annotate']['topLeft'][0], c['annotate']['topLeft'][1])
            clip_circle = create_png(c['annotate'], clip_name, user_path)
            about = ImageClip(clip_circle).set_start((float(c['annotate']['time']) - float(c['start']))).set_duration(2.0).set_position(position)
            wipx = CompositeVideoClip([wipa, about], size=wipa.size)
            new_clips.append(wipx)
        else:
            wipx = CompositeVideoClip([wip], size=wip.size)
            new_clips.append(wipx)
    credits = (TextClip(txt_credits, color='white',
                        font="Ubuntu-bold", fontsize=35, kerning=-2,
                        interline=-1, bg_color='black', size=wipa.size)
               .set_duration(5.5)
               .fadein(.5)
               .fadeout(.5))
    new_clips.append(credits)
    video = concatenate_videoclips(new_clips)
    # video = wipx
    logger.debug('video length ={}'.format(video_length))
    video = video.set_audio(AudioFileClip(path + 'music/5150.mp3').set_duration(video_length, change_end=True))
    logger.debug('user path ={}'.format(user_path))
    video.write_videofile( user_path + assets['videoTitle'] + '.mp4')
    clip = svc.save_clip(assets['videoTitle'], user_path, userid)
    print('clip = {}'.format(clip.id))
    getClips = svc.get_clip(clip.id)
    print('get clip = {} path = {}'.format(getClips.name, getClips.url))

def annotate(clip):
    logger.debug('annotate clip ={}'.format(clip))
    clip = clip.add_mask()
    w,h = clip.size
    clip.mask.get_frame = lambda t: circle(screensize=(clip.w, clip.h),center=(220,550),radius=500*(t*2),col1=1,col2=0.5,blur=4)
    return clip

def create_png(annotate, name, path):
    square_width = math.fabs(annotate['bottomRight'][0] - annotate['topLeft'][0])
    square_height = math.fabs(annotate['bottomRight'][1] - annotate['topLeft'][1])
    logger.debug('width {} height {}'.format(square_width, square_height))
    distance = math.sqrt((annotate['topLeft'][0] - square_width) ** 2 + (annotate['topLeft'][1] - square_height) ** 2)
    logger.debug('distance = {}'.format(distance))
    if (min(square_width, square_height) == square_width):
        xcenter = square_width/2
        radius = square_width -xcenter - 10
    else:
        xcenter = square_height/2
        radius = square_height - xcenter - 10
    logger.debug('radius ={}'.format(radius))
    d = svgdraw.Drawing(square_width, square_height, origin='center')
    d.append(svgdraw.Circle(0, 0, radius, fill='none', stroke_width=5, stroke='yellow'))
    circlpng = path + name + '.png'
    print('circlpng ={}'.format(circlpng))
    d.savePng(circlpng)
    return circlpng

@marty331
Copy link
Author

So I've worked on this for a damn week and finally got it figured out. I was trying to deploy with uwsgi and nginx. uwsgi could not handle the permissions correctly, so I finally implemented gunicorn and supervisor in the same manner that Miguel Grinberg describes in the below link. If anyone else has this issue I advise you to follow Miguel's blog post and use gunicorn and supervisor.

https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants