Skip to content

Instantly share code, notes, and snippets.

View aksinghdce's full-sized avatar

Amit Kumar Singh aksinghdce

View GitHub Profile
@aksinghdce
aksinghdce / blender-add-english-subtitles.md
Created March 31, 2023 18:43
blender bpy | add english subtitles

A method extracted from the class

from collections.abc import Mapping
from bpy import context, ops, data
from dataclasses import dataclass
from collections import OrderedDict
from pathlib import Path

@aksinghdce
aksinghdce / bpy-circular-frame-overlay-video.md
Created March 27, 2023 20:20
Blender Python | Add "Mask Image" made with the InkScape tool to overlay video. Example Video in Circular Frame

SVG Image for the Mask PNG

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="1920px"
   height="1080px"
   viewBox="0 0 1920 1080"
@aksinghdce
aksinghdce / video-hiding-mask-blender-python.md
Last active March 25, 2023 03:39
Chat-GPT answer to - "How to create mask in blender video editor with python code to partially hide and show content in lower channels?"

Question

How to create mask in blender video editor with python code to partially hide and show content in lower channels?

Answer

To create a mask in the Blender Video Editor using Python, you can use the following steps:

Create a new video sequence editor in Blender and load in the video you want to apply the mask to.

import bpy
@aksinghdce
aksinghdce / hindi-subtitle-for-video.md
Created March 21, 2023 02:32
Create Hindi subtitles for your Video with Semi-Automation

Challenge

'''In blender tool I noticed that adding subtitles with English language is convenient. But when it comes to Hindi subtitles all sorts of font related configuration changes would be required. I wasn't able to add Hindi Text with Blender interface.'''

Solution

'''Write Subtitles in Hindi using Audacity tool. Select portion of the audio in Audacity interface, Press Ctrl+B and type what you hear. After you have finished writing the subtitles for the audio imported from video in Audacity, export the audio and the Label to be later used in generating subtitle images with transparent background and text from the label file. Create SVG images with Hindi text from the label file exported from Audacity tool by using this Code: [Look at

@aksinghdce
aksinghdce / blenderpy-add-multiple-sorted-videos.md
Last active April 24, 2023 17:40
In blender, with python, add multiple video files in Video Sequence Editor

Video input from multiple camera sources super-imposed on each other

  1. Take videos from back-facing-camera and put it in channel 2. Add audio but keep it mute.
  2. Take videos from front-facing-camera in to channel 1 of blender's sequence editor. Make sure that the two channels have videos of same time duration.
import bpy
from pathlib import Path
from datetime import datetime
@aksinghdce
aksinghdce / svg-with-hindi-text.py
Created March 10, 2023 18:56
generate svg pages with hindi text
'''Question: To create SVG pages with text written in Hindi language provided as input in Unicode,
you can use the svgwrite library in Python. Here is an example code snippet:'''
'''Answer: '''
import svgwrite
# create a new SVG drawing
dwg = svgwrite.Drawing('hindi_text.svg')
@aksinghdce
aksinghdce / context-or-area-selector-blender.py
Created March 10, 2023 18:26
choose right context during blender python programming for video content creation.
# Question : In blender python API, provide python code for changing context to sequence editor video editing area.
# Answer (chatGPT) : To change the context to the sequence editor in Blender's Python API,
# you can use the bpy.context.area.type property to set the context to the 'SEQUENCE_EDITOR' area type.
# Here's an example code snippet:
import bpy
# get a reference to the sequence editor area
sequence_editor_area = None
for area in bpy.context.screen.areas:
if area.type == 'SEQUENCE_EDITOR':
@aksinghdce
aksinghdce / create-waveform-videos-with-ffmpeg-for-audio
Created February 22, 2023 14:00
Use this to generate video waveform for an audio. This can be useful add-on for generating Youtube Assets
ffmpeg -i input.mp4 -filter_complex \
"[0:a]showfreqs=mode=line:fscale=log,format=yuv420p[v]" \
-map "[v]" -map 0:a output.mp4
#--------------------------------------------------------------------------#
ffmpeg -i input.mp4 -filter_complex \
"[0:a]showcqt,format=yuv420p[v]" \
-map "[v]" -map 0:a output.mp4
@aksinghdce
aksinghdce / get-duration-of-media-file
Created January 22, 2023 19:10
get duration in hour, minutes and seconds to framerate calculation
ffprobe -i <file> -show_entries format=duration -v quiet -of csv="p=0" -sexagesimal
@aksinghdce
aksinghdce / extract_text.md
Last active January 3, 2023 13:45
extract text from pdf using python automation

Dockerfile

View the File in RAW mode

`FROM python COPY ${pdffile} . COPY requirements.txt . RUN pip install -r requirements.txt COPY code.py .