Skip to content

Instantly share code, notes, and snippets.

View lyarinet's full-sized avatar

Asif Agaria lyarinet

View GitHub Profile
<?php
session_start();
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
if( !is_array($_SESSION['speed']) )
{
$_SESSION['speed'] = array('updated' => time(), 'old' => file_get_contents('/sys/class/net/eth0/statistics/rx_bytes'));
@zpea
zpea / html5_video_conv.bash
Created July 21, 2012 03:00
little shell script to convert video files to the various HTML5 video formats/codecs using ffmpeg. Also generates the line for embedding the video using the videoJS plugin for wordpress.
#!/bin/bash
#
# video conversion script for publishing as HTML 5 video, via videojs (with hd button extension)
# 2011 by zpea
# feel free to use as public domain / Creative Commons CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/)
#
FFMPEG=/usr/bin/ffmpeg
HD_SUFFIX='_hd'
@mbrowne
mbrowne / Test.php
Created March 6, 2013 17:08
SSH Connection from CodeIgniter
<?php
class Test extends CI_Controller
{
public function deploy_test() {
$connection = ssh2_connect("123.45.67.890", 23);
if(!$connection) {
echo json_encode('Connection failed');
}
@csparker247
csparker247 / ffmpeg-progress
Last active August 21, 2023 11:59
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] &
@mustafaturan
mustafaturan / latest-ffmpeg-centos6.sh
Last active October 25, 2022 20:14
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@turtlix
turtlix / ffmpeglib.php
Last active September 7, 2021 17:32
Library for FFMPEG Converter from: http://ellislab.com/forums/viewthread/58362/#537296
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Rick Ellis
* @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://www.codeignitor.com/user_guide/license.html
@tott
tott / ip_in_range.php
Created November 27, 2013 22:46
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@ssmereka
ssmereka / plexDatabaseBackupScript.sh
Last active April 16, 2024 16:42
Plex Media Server database backup script.
#!/bin/bash
# Backup a Plex database.
# Author Scott Smereka
# Version 1.0
# Script Tested on:
# Ubuntu 12.04 on 2/2/2014 [ OK ]
# Plex Database Location. The trailing slash is
@seblavoie
seblavoie / makeWebm.sh
Created February 6, 2014 18:57
Bash aliases to create webm
makeWebm() {
FILE=$1
BITRATE=${2:-'3450'}
SIZE=${3:-'1280x720'}
FILENAME=${FILE%%.*}
ffmpeg -i ${FILE} -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b ${BITRATE}k -s ${SIZE} ${FILENAME}.webm
}
makeWebms() {
BITRATE=${1:-'3450'}
@svagionitis
svagionitis / Create_Iframe_Index_M3U8.bash
Last active June 21, 2024 22:54
Segment an mp4 file to HLS streaming files
#!/bin/bash
# Create an Iframe index from HLS segmented streams
# $1: Filename to be created
# $2: Location of segmented ts files
# Check how many arguments
if [ $# != 2 ]; then
echo "Usage: $0 [Input filename] [Location of segmented streams]"
exit 1;
fi