Skip to content

Instantly share code, notes, and snippets.

View ClimenteA's full-sized avatar
Open to contracts!

Alin Climente ClimenteA

Open to contracts!
View GitHub Profile
ClimenteA /
Created June 18, 2023 13:19
Useful python script which can be used to organize your archive of photos, videos, documents etc
import os
import shutil
fileFormat = {
"Picture": [
ClimenteA /
Last active June 20, 2023 11:23
Re-encode videos to mp4 1080p 24 fps in case videos are corrupted
import os
import subprocess
input_folder = "./vids"
output_folder = "./reencoded"
# Create the output folder if it doesn't exist
os.makedirs(output_folder, exist_ok=True)
# Get a list of all the .mp4 files in the input folder
ClimenteA /
Created June 10, 2023 08:17
Concat with FFmpeg videos from a folder
import os
# Assuming video files are in this format: "1.mp4"
filepaths = [f for f in os.listdir() if f.endswith(".mp4")]
sorted_filepaths = sorted(filepaths, key=lambda val: int(val.split(".")[0]))
allvids = [f'file {os.path.abspath(f)}' for f in sorted_filepaths]
with open("vids.txt", "w") as f:
ClimenteA /
Created May 29, 2023 07:16
Use auto-editor over videos in a folder to "magic cut" silent moments
import os
mp4files = [f for f in os.listdir() if f.endswith(".mp4") and "ALTERED" not in f]
if __name__ == "__main__":
for f in mp4files:
os.system(f"auto-editor {f} --no-open")
ClimenteA /
Created May 27, 2023 07:29
FFmpeg + Python split big video in 30 minutes chunks
import subprocess
def split_video(input_file, output_prefix, duration=1800):
command = [
'-i', input_file,
'-c', 'copy',
'-segment_time', str(duration),
'-f', 'segment',
'-reset_timestamps', '1',
ClimenteA /
Created May 26, 2023 10:34
Use ffmpeg and python to increase volume of some videos and after that concat
import os
from datetime import datetime
# Assuming video files are recorted with OBS in this format: "2023-04-11 08-11-11.mp4"
def parse_date(filepath):
date_str = filepath[:19]
return datetime.strptime(date_str, "%Y-%m-%d %H-%M-%S")
filepaths = [f for f in os.listdir() if f.endswith(".mp4")]
ClimenteA / svelte-tailwind-svelte-spa-router config.txt
Last active November 12, 2020 09:29
How to configure svelte with tailwind and svelte-spa-router
npx degit sveltejs/template project-name
cd project-name
npm install
npm install svelte-spa-router
// Temporary issue postcss works only with: autoprefixer@9.8.6 (remove @9.8.6 if the issue was solved)
ClimenteA /
Last active May 10, 2018 15:48
Auto respond to new incoming messages on your android phone using qpython3 and sl4a library
import sl4a
droid = sl4a.Android()
print("Can't initialize sl4a module!")
import re
import random
import time
import itertools
ClimenteA /
Created May 9, 2018 05:27
Iterate thru a very big list, to be used in case you iterate over a list and you get memory error
def genumerate(li):
#using a generator not to kill memory
for item in li:
yield li.index(item), item
#use case
for idx, val in genumerate(biglist):
pass #do_something()