Skip to content

Instantly share code, notes, and snippets.

@megasaturnv
megasaturnv / CreateTimestampSrtForVideo.py
Last active August 18, 2022 23:56
A python 3 script to generate an srt file containing the video\'s timestamp. Start time is parsed from the video\'s metadata. srt file will be placed in the same directory as the specified video file. Requires ffprobe
#!/usr/bin/python3
# CreateTimestampSrtForVideo.py by MegaSaturnv
#Todo:
# * Decide between subprocess.Popen or subprocess.run or something else entirely
# * More error checking - try except
# * Test compatibility with Windows
# * Check for ffprobe before running
# * Implement a batch mode for processing all video files in a Folder? Or, just use find and -exec...
@megasaturnv
megasaturnv / discord-video.sh
Created June 20, 2022 19:40
An attempt to take any size video file and reduce in size to 8MB or less by re-encoding, using ffmpeg
#!/bin/bash
# 64 000 000 bits / video length = target bitrate
#MAX_VIDEO_SIZE="60000000"
#MAX_VIDEO_SIZE="66108900"
MAX_VIDEO_SIZE="55000000"
#MAX_AUDIO_SIZE="4000000"
MAX_AUDIO_SIZE="1000000"
@megasaturnv
megasaturnv / ffmpeg_clip.sh
Last active September 1, 2022 10:27
Simple script to extract a clip from an video with ffmpeg
#!/bin/bash
# Usage: ./ffmpeg_clip.sh <filename> <start mm:ss> <end mm:ss>
# Example: ./ffmpeg_clip.sh file.mp4 01:15 01:45
# Output file is <filename>_clip.mp4
FILE=$1
START_TIME=$2
END_TIME=$3
@megasaturnv
megasaturnv / sshNoCheck.sh
Created May 20, 2018 10:44
SSH without checking known hosts file
#!/bin/sh
alias sshNoCheck='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
@megasaturnv
megasaturnv / download_and_display_image_imgtag.php
Created January 16, 2018 14:52
Download and display image from remote webpage. No temp file. Image in <img> tag
<?php //Megasaturnv 2018-01-16 Use curl -u username:password for http auth if required ?>
<img src="data:image/jpeg;base64, <?php echo base64_encode(shell_exec("curl http://192.168.1.50/cgi-bin/snapshot.cgi?channel=0 2> /dev/null")) ?>">
@megasaturnv
megasaturnv / download_and_display_image.php
Last active January 16, 2018 14:49
Download and display image from remote webpage. No temp file
<?php
//Megasaturnv 2018-01-16
header("Content-type: image/jpeg");
echo shell_exec("curl http://192.168.1.50/cgi-bin/snapshot.cgi?channel=0 2> /dev/null");
//Use curl -u username:password for http auth if required
?>
@megasaturnv
megasaturnv / webcam_snapshot_imgtag.php
Created January 16, 2018 14:43
Display snapshot from usb webcam camera /dev/video0 on a webpage. No temp file. Uses avconv command. Image is in an <img> tag
<?php //Megasaturnv 2018-01-16 Change this resolution to match your camera \/ ?>
<img src="data:image/jpeg;base64, <?php echo base64_encode(shell_exec("avconv -f video4linux2 -i /dev/video0 -vframes 1 -s 1920x1080 pipe:.jpg 2>/dev/null")); ?> ">
@megasaturnv
megasaturnv / webcam_snapshot.php
Last active January 16, 2018 14:42
Display snapshot from usb webcam camera /dev/video0 on a webpage. No temp file. Uses avconv command
<?php
//Megasaturnv 2018-01-16
header("content-type: image/jpeg");
// Change this resolution to match your camera \/
echo passthru("avconv -f video4linux2 -i /dev/video0 -vframes 1 -s 1920x1080 pipe:.jpg 2>/dev/null");
?>
@megasaturnv
megasaturnv / mjpeg_Snapshot_img_tag.php
Last active January 17, 2018 16:24
PHP motion jpeg mjpeg snapshot single frame with or without http auth. Puts image in <img> tag with no temp file
<?php
//Megasaturnv 2018-01-16
$camurl="http://192.168.1.100:8081/"; // Mjpeg URL
//$camurl="http://username:[email protected]:8081/" // HTTP Auth mjpeg URL (optional)
$boundary="--BoundaryString"; // $boundary = The boundary string between jpegs in an mjpeg stream
//NOTE: $boundary changes between mjpeg stream providers. For example, https://github.com/Motion-Project/motion uses '--BoundaryString'. https://github.com/ZoneMinder/ZoneMinder uses '--ZoneMinderFrame'. To find out $boundary for your stream you will need to save 1 or more frames of the mjpeg and open it with a text editor. --<boundary string> should be visible on the first line
$f = fopen($camurl, "r"); // Open mjpeg url as $f in readonly mode
$r = ""; // Set $r to blank variable
if($f) {
@megasaturnv
megasaturnv / mjpeg_Snapshot.php
Last active December 13, 2019 10:33
PHP motion jpeg mjpeg snapshot single frame with or without http auth. No temporary file needed
<?php
//Megasaturnv 2018-01-12
$camurl="http://192.168.1.100:8081/"; // Mjpeg URL
//$camurl="http://username:[email protected]:8081/" // HTTP Auth mjpeg URL (optional)
$boundary="--BoundaryString"; // $boundary = The boundary string between jpegs in an mjpeg stream
//NOTE: $boundary changes between mjpeg stream providers. For example, https://github.com/Motion-Project/motion uses '--BoundaryString'. https://github.com/ZoneMinder/ZoneMinder uses '--ZoneMinderFrame'. To find out $boundary for your stream you will need to save 1 or more frames of the mjpeg and open it with a text editor. --<boundary string> should be visible on the first line
$f = fopen($camurl, "r"); // Open mjpeg url as $f in readonly mode
$r = ""; // Set $r to blank variable
if($f) {