Skip to content

Instantly share code, notes, and snippets.

@wett1988
wett1988 / ffmpeg-split.py
Last active April 16, 2024 12:28
Split media file with timeline.json by ffmpeg and python
import ffmpeg
import argparse
import os
from datetime import timedelta
import csv
def parse_timeline(timeline_path):
timeline = []
with open(timeline_path, mode='r') as file:
csvFile = csv.DictReader(file, delimiter=',')
@wett1988
wett1988 / merge_video_and_audio.sh
Last active September 8, 2021 17:50
Merge video and audio together with ffmpeg
ffmpeg -i "video.mp4" -i "audio.mp3" -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 "output.mp4"
@wett1988
wett1988 / make_video.sh
Last active May 4, 2021 18:50
Create video from image and audio with ffmpeg
ffmpeg -loop 1 -i image.jpg -i audio.mp3 -vf "scale='min(1280,iw)':-2,format=yuv420p" -c:v libx264 -preset medium -profile:v main -c:a aac -shortest -movflags +faststart output.mp4
@wett1988
wett1988 / onJSClient.js
Created November 24, 2016 10:28
Detect if a string is a data URL (PHP, JS)
// For js more info in source: https://gist.github.com/bgrins/6194623
function isDataURL(s) {
return !!s.match(isDataURL.regex);
}
isDataURL.regex = /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i;