Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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...