Skip to content

Instantly share code, notes, and snippets.

View samirsaci's full-sized avatar

Samir Saci samirsaci

View GitHub Profile
@samirsaci
samirsaci / stack.py
Created November 1, 2022 13:53
Automate Video Design - Stack
# Third Video
start_time = '00:01:10'
end_time = '00:01:25'
t1, t2 = convert_seconds(start_time), convert_seconds(end_time)
video_unload5 = myclip.subclip(t1, t2)
# Fourth Video
start_time = '00:01:47'
end_time = '00:02:02'
t1, t2 = convert_seconds(start_time), convert_seconds(end_time)
@samirsaci
samirsaci / concat.py
Created November 1, 2022 13:50
Automate Video Editing - Concat
# Second video
start_time = '00:00:43'
end_time = '00:00:58'
t1, t2 = convert_seconds(start_time), convert_seconds(end_time)
video_unload3 = myclip.subclip(t1, t2)
# Concat
video_unload4 = concatenate_videoclips([video_unload1, video_unload3])
video_unload4.write_videofile("step_12.mp4", fps=25)
@samirsaci
samirsaci / mute.py
Created November 1, 2022 13:44
Automate Video Editing - Mute
# Remove the sound
video_unload2 = video_unload1.volumex(0)
video_unload2.write_videofile("step_1_mute.mp4", fps=25)
@samirsaci
samirsaci / cut_video.py
Created November 1, 2022 13:35
Automate Video Editing - Cut
# First Video
start_time = '00:00:15'
end_time = '00:00:30'
t1, t2 = convert_seconds(start_time), convert_seconds(end_time)
video_unload1 = myclip.subclip(t1, t2)
video_unload1.write_videofile("step_1.mp4", fps=25)
@samirsaci
samirsaci / convert_seconds.py
Created November 1, 2022 13:33
Automate Video Editing - Convert
def convert_seconds(tstamp):
# Format 'hh:mm:ss'
s = int(tstamp[6:8])
m = int(tstamp[3:5])*60
h = int(tstamp[0:2])*3600
total = s + m + h
return total
@samirsaci
samirsaci / import.py
Created November 1, 2022 13:27
Automate Video Editing - Import
from moviepy.editor import VideoFileClip, CompositeVideoClip, concatenate_videoclips , clips_array, vfx, AudioFileClip
from functions import *
# Import Video
filename = '15-12-2021.mp4'
myclip = VideoFileClip(filename)
@samirsaci
samirsaci / location number.py
Created October 1, 2022 16:54
Graphic Automation
# Add location number
img_draw = ImageDraw.Draw(bg)
font = ImageFont.truetype('arial', 60)
img_draw.text((140, 135),'{}'.format(row['Location']),(0,0,0),font=font, stroke_width=1,
stroke_fill="black")
@samirsaci
samirsaci / barcode.py
Last active October 1, 2022 16:52
Graphic Automation
# Create a function to generate and save a barcode image
def create_ean(number):
my_code = EAN13(number, writer=ImageWriter())
my_code.save("Img/barcode")
# Import the bar code
create_ean(str(row['SKU Code']))
bcode = Image.open('Img/barcode.png').convert("RGBA")
bcode = bcode.resize((int(bcode.size[0]*0.5),int(bcode.size[1]*0.5)))
# Add barcode
@samirsaci
samirsaci / add_icons.py
Last active October 1, 2022 16:39
Graphic Automation
# Open Arrow
arr = Image.open('Img/arrow/{}.png'.format(row['arrow'])).convert("RGBA")
arr = arr.resize((int(arr.size[0]*1.35),int(arr.size[1]*1.35)))
# Paste with Coordinates
bg.paste(arr, (-40, 0), arr)
# Icon 1
zone = Image.open('Img/log/{}.png'.format(row['log'])).convert("RGBA")
perc_size = 0.45
l1, l2 = int(zone.size[0]*perc_size), int(zone.size[1]*perc_size)
@samirsaci
samirsaci / loop.py
Created October 1, 2022 16:32
Graphic Information
# Import libaries
from PIL import Image
import pandas as pd
from PIL import Image, ImageOps, ImageDraw
from PIL import ImageFont
from barcode import EAN13
from barcode.writer import ImageWriter
# Import the file
df = pd.read_excel('label information.xlsx')