GithubHelp home page GithubHelp logo

trekky12 / kburns-slideshow Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 15.0 160.6 MB

generate slideshow movies with Ken Burns effect on images

License: MIT License

Python 100.00%
ffmpeg hacktoberfest image kburns-slideshow ken-burns slideshow video zoom-pan

kburns-slideshow's People

Contributors

ch00f avatar trekky12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kburns-slideshow's Issues

Cannot import name 'ImageTk' from 'PIL'

On a Ubuntu 20.10 and following the instructions I receive the following error:

python3 kbvs.py
Traceback (most recent call last):
File "kbvs.py", line 1, in
from gui.app import App
File "~/Downloads/kburns-slideshow-master/gui/app.py", line 12, in
from PIL import Image, ImageTk, ImageDraw
ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/init.py)

GUI AttributeError

The following error was appears in the console when I pressed start video creation button on the GUI:

Note that I installed python version 3.10.4

Error:

Exception in thread Thread-3 (startVideoCreation):
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Program Files\Python310\lib\threading.py", line 946, in run
self._target(*self.args, **self.kwargs)
File "C:\Users\danya\OneDrive\Documents\kburns-slideshow-master\gui\app.py", line 1191, in startVideoCreation
progressPopup = ProgressFrame(self)
File "C:\Users\danya\OneDrive\Documents\kburns-slideshow-master\gui\ProgressFrame.py", line 11, in init
tk.Toplevel.init(self, parent, options)
File "C:\Program Files\Python310\lib\tkinter_init
.py", line 2650, in init
BaseWidget.init(self, master, 'toplevel', cnf, {}, extra)
File "C:\Program Files\Python310\lib\tkinter_init
.py", line 2595, in init
BaseWidget.setup(self, master, cnf)
File "C:\Program Files\Python310\lib\tkinter_init
.py", line 2564, in _setup
self.tk = master.tk
AttributeError: 'dict' object has no attribute 'tk'

any fixes or recommendations ?

Help Getting this to work

Hi, very interested in your project, but I am having trouble running it with the example.json.
How do you pass it via cmd line?

Could you document and add a fully working example with the data to the codebase. Just images would be fine.

Thanks

How Can I Use Zoom and Pan Effects in Python Code

Hi @Trekky12

Thanks for this awesome repository. I am working on a project where i need to implement custom zoom and pan effects on images and stitch them up together to make a video.

I have to implement pan and zoom effects with custom areas in images to be zoomed and panned. There are focus areas in every image i want the zoom and pan effects to highlight.

I am not good with shell scripting or FFMPEG, but i have working knowledge of Python. Any help on how can i implement custom zoom and pan effects on a set of images using only Python would be really appreciated.

It would be a great help if you can spare some time to guide me on implementing KBurns effects on images using Python. Thanks

Creation of temporary files ffmpeg is hardcoded to fixed commandline (ultrafast etc.)

As title. So the general settings for ffmpeg commandline is obsolete. As I don't think it's intentionally I file this as an issue.
For example I'm using: "output_parameters": "-preset p7 -tune hq -profile:v high -multipass qres -rc vbr -cq 16 -qmin 16 -qmax 16 -b:v 0k", along with "output_codec": "h264_nvenc",
which is working fine working without temporary files for 3-4 pictures.
But with a bigger pictures count it soon gets out of memory (log shows FFMPEG cancel) so using temporary files gets mandatory and - as said - user's custom ffmpeg quality commandline obsolete, unfortunately.

In slideshow/Queue.py: snippet.txt

could not initiate slide show manager

Screenshot (10)

i'm trying to integrate your plugin to my application so i created a button that opens your slideshow app and after i run the code it initiate slideshow app but when i'm trying to add new slide or open an exist .json file (previously saved) the attached error appears,

any idea ?

Subtitles and Slides sync option

@Trekky12 Hi! I am using the cli version of this app as back-end for my use case. I see there is an option to explicitly sync videos and background music, but there seems to be no such option to explicitly sync slides with their corresponding titles/subtitles. Is there a way I can ensure that if slide 1 runs for 5 seconds, then its corresponding title also run for 5 seconds?

Thanks for making such a useful app/repository!

Sync Video to audio button

Hi,

in my slideshow i added around 5 pictures and a long music ( with duration 00:02:22) so when i tried to use sync video to audio button, below error generated :

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\tkinter_init_.py", line 1921, in call
return self.func(*args)
File "C:\Users\user\Documents\application\kburns\gui\app.py", line 1163, in syncToAudio
self.sm.adjustDurationsFromAudio()
File "C:\Users\user\Documents\application\kburns\slideshow\SlideManager.py", line 693, in adjustDurationsFromAudio
timestamps = self.getTimestampsFromAudio()
File "C:\Users\user\Documents\application\kburns\slideshow\SlideManager.py", line 681, in getTimestampsFromAudio
timestamps = timestamps + [float(timestamp) + offset for timestamp in track.getTimestamps(self.config["aubio"])]
File "C:\Users\user\Documents\application\kburns\slideshow\AudioFile.py", line 17, in getTimestamps
timestamps = subprocess.check_output(["%s" % (aubio), "-i", self.file, "-O", "kl"],
File "C:\Program Files\Python310\lib\subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\Program Files\Python310\lib\subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\Users\user\Documents\aubio-0.4.6-win64-ffmpeg\bin\aubioonset.exe', '-i', 'C:/Users/user/Desktop/music.mp3', '-O', 'kl']' returned non-zero exit status 3221225781.

btw i'm using python 3.10
any idea ?

Can`t start project in cli

Hi @Trekky12 ! Pls help me to start it with cli

My bat
http://joxi.ru/YmEDbxpSw4Bv5r.jpg

@echo off

call %~dp0venv\Scripts\activate

cd %~dp0

python kbvs-cli.py out.mp4 -f example.json

pause

example.json

{
    "config": {
        "output_width": 1920,
        "output_height": 1080,
        "slide_duration": 3,
        "slide_duration_min": 1,
        "fade_duration": 1.0,
        "transition": "random",
        "transition_bars_count": 10,
        "transition_cell_size": 100,
        "fps": 25,
        "zoom_rate": 0.1,
        "zoom_direction_x": "random",
        "zoom_direction_y": "random",
        "zoom_direction_z": "random",
        "scale_mode": "auto",
        "loopable": false,
        "overwrite": true,
        "generate_temp": false,
        "delete_temp": false,
        "sync_to_audio": false,
        "sync_titles_to_slides": false,
        "is_synced_to_audio": false
    },
    "slides": [

        {
            "file": "data\\1.jpg",
            "slide_duration": 5,
            "overlay_text":{
                "title": "Title 1",
                "font": "Bauhaus.ttf",
                "font_size": 200,
                "duration": 2,
                "transition_x": "left-to-center",
                "transition_y": "center",
                "offset": 0
            },
            "overlay_color":{
                "color": "black",
                "opacity": 0.8,
                "duration": 2,
                "offset": 0
            }
        },

        {
            "file": "data\\2.jpg",
            "title": "subtitle"
        },

        {
            "file": "data\\3.jpg"
        }
    ],
    "audio": [
        "data\\music\\1.mp3"
    ]
}

result:
http://joxi.ru/DmBDwORSJVg11A.jpg

  Duration: 00:00:00.04, start: 0.000000, bitrate: 11631 kb/s
  Stream #1:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 853x1280 [SAR 120:120 DAR 853:1280], 25 fps, 25 tbr, 25 tbn
Input #2, image2, from 'data\3.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 108609 kb/s
  Stream #2:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 900x1200 [SAR 1:1 DAR 3:4], 25 fps, 25 tbr, 25 tbn
Input #3, mp3, from 'data\music\1.mp3':
  Metadata:
    encoder         : Google
  Duration: 00:04:05.76, start: 0.025057, bitrate: 320 kb/s
  Stream #3:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
    Metadata:
      encoder         : Lavf
Fontconfig error: Cannot load default config file: No such file: (null)
[Parsed_drawtext_6 @ 0000026cbc3ef140] Using "C:/Windows/fonts\mingliub.ttc"
[subtitles @ 0000026cbc3fb240] Unable to parse option value "Pythonprojectskburns-slideshowtemptemp-kburns-subs.srt" as image size
[subtitles @ 0000026cbc3fb240] Error setting option original_size to value Pythonprojectskburns-slideshowtemptemp-kburns-subs.srt.
[Parsed_subtitles_53 @ 0000026cbc40ca40] Error applying options to the filter.
[AVFilterGraph @ 0000026cbc31bf40] Error initializing filter 'subtitles' with args 'D:Pythonprojectskburns-slideshowtemptemp-kburns-subs.srt'
Error initializing complex filters.
Invalid argument

"loopable": true creates ffmpeg error

First - a huge thanks for this fantastic project.
All is working well, apart from if I specify "loopable": true in my config.json

If I do that, I get the following error from ffmpeg:

Stream specifier 'v-1end' in filtergraph description [0:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1281, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1.1,zoom-0.0003333333333333334)':x='iw-iw/zoom':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=2[v0out-end][v0out-main]; [v0out-main]fifo,trim=start_frame=0:end_frame=210,setpts=PTS-STARTPTS[v0main]; [v0out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v0end]; [1:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1252, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1,zoom+0.0003333333333333334)':x='0':y='0':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v1out-start][v1out-end][v1out-main]; [v1out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v1start]; [v1out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v1main]; [v1out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v1end]; [2:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), pad=w=3290:h=1851:x='(ow-iw)/2':y='(oh-ih)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1.1,zoom-0.0003333333333333334)':x='iw-iw/zoom':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v2out-start][v2out-end][v2out-main]; [v2out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v2start]; [v2out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v2main]; [v2out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v2end]; [3:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), pad=w=3223:h=1813:x='(ow-iw)/2':y='(oh-ih)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1,zoom+0.0003333333333333334)':x='0':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v3out-start][v3out-end][v3out-main]; [v3out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v3start]; [v3out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v3main]; [v3out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v3end]; [4:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1280, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1,zoom+0.0003333333333333334)':x='0':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v4out-start][v4out-end][v4out-main]; [v4out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v4start]; [v4out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v4main]; [v4out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v4end]; [5:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), pad=w=3555:h=2000:x='(ow-iw)/2':y='(oh-ih)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1.1,zoom-0.0003333333333333334)':x='iw-iw/zoom':y='0':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v5out-start][v5out-end][v5out-main]; [v5out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v5start]; [v5out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v5main]; [v5out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v5end]; [6:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), pad=w=3557:h=2001:x='(ow-iw)/2':y='(oh-ih)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1.1,zoom-0.0003333333333333334)':x='iw-iw/zoom':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v6out-start][v6out-end][v6out-main]; [v6out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v6start]; [v6out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v6main]; [v6out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v6end]; [7:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1280, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1,zoom+0.0003333333333333334)':x='iw-iw/zoom':y='0':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v7out-start][v7out-end][v7out-main]; [v7out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v7start]; [v7out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v7main]; [v7out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v7end]; [8:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1080, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1,zoom+0.0003333333333333334)':x='0':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v8out-start][v8out-end][v8out-main]; [v8out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v8start]; [v8out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v8main]; [v8out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v8end]; [9:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1280, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1,zoom+0.0003333333333333334)':x='iw-iw/zoom':y='0':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=3[v9out-start][v9out-end][v9out-main]; [v9out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v9start]; [v9out-main]fifo,trim=start_frame=90:end_frame=210,setpts=PTS-STARTPTS[v9main]; [v9out-end]fifo,trim=start_frame=210:end_frame=300,setpts=PTS-STARTPTS[v9end]; [10:v]format=pix_fmts=yuva420p, crop=w=2*floor(iw/2):h=2*floor(ih/2), scale=w=1920:h=1281, crop=w=1920:h=1080:x='(iw-ow)/2':y='(ih-oh)/2', scale=7680x4320,zoompan=z='if(eq(on,0),1.1,zoom-0.0003333333333333334)':x='iw-iw/zoom':y='ih-ih/zoom':fps=30:d=30*10.0:s=1920x1080, setpts=PTS-STARTPTS, setsar=1, format=rgba, split=2[v10out-start][v10out-main]; [v10out-start]fifo,trim=start_frame=0:end_frame=90,setpts=PTS-STARTPTS[v10start]; [v10out-main]fifo,trim=start_frame=90:end_frame=300,setpts=PTS-STARTPTS[v10main]; [v0end] [v1start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v1trans]; [v1end] [v2start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v2trans]; [v2end] [v3start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v3trans]; [v3end] [v4start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v4trans]; [v4end] [v5start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v5trans]; [v5end] [v6start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v6trans]; [v6end] [v7start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v7trans]; [v7end] [v8start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v8trans]; [v8end] [v9start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v9trans]; [v9end] [v10start] blend=all_expr='A*(1-T/3)+B*(T/3)':shortest=1 [v10trans]; [v-1end][v0start][v0main][v1trans][v1main][v2trans][v2main][v3trans][v3main][v4trans][v4main][v5trans][v5main][v6trans][v6main][v7trans][v7main][v8trans][v8main][v9trans][v9main][v10trans][v10main] concat=n=23:v=1:a=0,format=yuv420p[out] matches no streams.

Here is the cmd line I am using to trigger:

python3 kbvs-cli.py out.mp4 -i data/1.jpeg data/2.jpeg data/3.jpeg data/4.jpeg data/5.jpeg data/6.jpeg data/7.jpeg data/8.jpeg data/9.jpeg data/10.jpeg

Thanks

Can't run on macOS

$ python main.py out.mp4 -f example.json
Traceback (most recent call last): File "main.py", line 8, in <module> from slideshow.SlideManager import SlideManager File "/Users/eph/Desktop/kburns-slideshow-master/slideshow/SlideManager.py", line 13, in <module> from .ImageSlide import ImageSlide File "/Users/eph/Desktop/kburns-slideshow-master/slideshow/ImageSlide.py", line 4, in <module> from PIL import Image, ExifTags ImportError: No module named PIL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.