Extract audio from a YouTube video file
ffmpeg -i INPUT.mp4 -ab 256k OUTPUT.mp3
Cut 3s length
ffmpeg -y -ss 00:00:03 -i INPUT.mp4 -codec copy OUTPUT.mp4
# Don't use FFmpeg for metadata extraction. Use FFprobe. | |
# Its output is geared toward parsabilty. | |
# Container and stream information in JSON format: | |
ffprobe -show_format -print_format json 'Serenity - HD Trailer.mp4' | |
ffprobe -show_streams -print_format json 'Serenity - HD Trailer.mp4' | |
# Human-readable values: | |
ffprobe -show_format -pretty -print_format json 'Serenity - HD Trailer.mp4' | |
# Trim video to first 30 seconds, without transcoding. |
<?php | |
$timeout = 300; // 5 minutes | |
$time = time(); | |
$ip = $_SERVER["REMOTE_ADDR"]; | |
$file = "users.txt"; | |
$arr = file($file); | |
$users = 0; | |
for ($i = 0; $i < count($arr); $i++){ | |
if ($time - intval(substr($arr[$i], strpos($arr[$i], " ") + 4)) > $timeout){ |
Extract audio from a YouTube video file
ffmpeg -i INPUT.mp4 -ab 256k OUTPUT.mp3
Cut 3s length
ffmpeg -y -ss 00:00:03 -i INPUT.mp4 -codec copy OUTPUT.mp4
<?php | |
/** | |
* Simple code for executing commands on a remote Linux server via SSH in PHP | |
* | |
* @author Phil Kershaw (In collaboration with Philip Mott) | |
* | |
* Note: ssh2_connect requires libssh2-php which is a non-standard PHP lib. | |
* Debian: apt-get install libssh2-php | |
* Redhat: yum install libssh2-php ???? I've no idea for redhat, sorry. | |
*/ |
# Run the last command as root | |
sudo !! | |
# Serve current directory tree at http://$HOSTNAME:8000/ | |
python -m SimpleHTTPServer | |
# Save a file you edited in vim without the needed permissions | |
:w !sudo tee % | |
# change to the previous working directory | |
cd - | |
# Runs previous command but replacing | |
^foo^bar |
# Get video duration in frames | |
duration=$(ffmpeg -i [filename] 2>&1 | sed -n "s/.* Duration: \([^,]*\), start: .*/\1/p") | |
fps=$(ffmpeg -i [filename] 2>&1 | sed -n "s/.*, \(.*\) tbr.*/\1/p") | |
hours=$(echo $duration | cut -d":" -f1) | |
minutes=$(echo $duration | cut -d":" -f2) | |
seconds=$(echo $duration | cut -d":" -f3) | |
FRAMES=$(echo "($hours*3600+$minutes*60+$seconds)*$fps" | bc | cut -d"." -f1) | |
# Start ffmpeg, use awk to flush the buffer and remove carriage returns | |
ffmpeg -i [filename] [options] [outputfile] 2>&1 | awk '1;{fflush()}' RS='\r\n'>[errorlog] & |
#!/bin/bash | |
# (C) Karl Mitchell 2017, GPL: https://www.gnu.org/licenses/gpl-3.0.en.html | |
# Best run once daily, e.g. using launchd or cron job, during quiet time | |
# Converts Channels DVR to a Plex & iOS-friendly m4v (h.264) format | |
# Pre-requisites: | |
# HandBrakeCLI (video transcoding application) | |
# Optional pre-requisites: | |
# MP4Box (part of GPAC, use MacPorts or similar) for marking commercials start/end as chapters | |
# Curl and an IFTTT Maker Key for phone statusnotifications. | |
# FFMPeg (a part of channels DVR, but you'll need to point to it) for commercial trimming |
These are some ffmpeg command lines used when developing VHS dubbing controller.
#!/bin/bash
# Stream a PAL 50i capture, cropped and de-interlaced using ffmpeg
#!/bin/bash | |
while true; do | |
currTime=`date +%Y%m%d%H%M` | |
if [ "$currTime" -ge 201507081658 -a "$currTime" -le 201507082300 ]; then | |
echo "$currTime: Stream should be on. Start ffmpeg if the process does not exist" | |
if [ "$(pidof ffmpeg)" ]; then | |
echo "$currTime: ffmpeg already running." | |
sleep 10 | |
else |