Skip to content

Instantly share code, notes, and snippets.

View lyarinet's full-sized avatar

Asif Agaria lyarinet

View GitHub Profile
@lyarinet
lyarinet / ffmpeg_ffprobe.sh
Created August 8, 2022 10:46 — forked from rbrooks/ffmpeg_ffprobe.sh
FFmpeg & FFprobe Cheatsheet
# 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.
@lyarinet
lyarinet / counter.php
Created January 19, 2022 05:10 — forked from Fysac/counter.php
Database-less, sessionless way to count online users in PHP.
<?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){
@lyarinet
lyarinet / ffmpeg_tuts.md
Created January 14, 2022 07:03 — forked from tingplenting/ffmpeg_tuts.md
ffmpeg cli for youtube

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
@lyarinet
lyarinet / gist:466347e798b86acae311f45ecf20d0eb
Created January 14, 2022 06:25 — forked from PhilKershaw/gist:1389041
Simple code for executing commands on a remote Linux server via SSH in PHP
<?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.
*/
@lyarinet
lyarinet / ffmpeg.md
Created January 14, 2022 06:09 — forked from protrolium/ffmpeg.md
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

@lyarinet
lyarinet / useful-one-liners.sh
Created December 31, 2021 07:14 — forked from johnnypea/useful-one-liners.sh
Useful one liners
# 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
@lyarinet
lyarinet / ffmpeg-progress
Created November 27, 2021 08:44 — forked from csparker247/ffmpeg-progress
Outputs ffmpeg progress to console as percentage of work completed.
# 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] &
@lyarinet
lyarinet / transcode-plex.sh
Created November 27, 2021 06:02 — forked from karllmitchell/transcode-plex.sh
Scripts for transcoding Channels DVR recordings and adding them to Plex
#!/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
@lyarinet
lyarinet / ffmpeg_hls.md
Created November 27, 2021 05:20 — forked from stecman/ffmpeg_hls.md
ffmpeg streaming examples

FFmpeg streaming

These are some ffmpeg command lines used when developing VHS dubbing controller.

HLS Stream (on Linux)

#!/bin/bash

# Stream a PAL 50i capture, cropped and de-interlaced using ffmpeg
@lyarinet
lyarinet / iptv-to-hls.sh
Created October 9, 2021 17:15 — forked from drzax/iptv-to-hls.sh
IPTV to HTTP live streaming
#!/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