Skip to content

Instantly share code, notes, and snippets.

View krzemienski's full-sized avatar

Nick Krzemienski krzemienski

View GitHub Profile
@krzemienski
krzemienski / ffmpeg.go
Created February 8, 2024 22:21 — forked from aperture147/ffmpeg.go
fix make buffer
package main
import (
"bytes"
"io/ioutil"
"log"
"os"
"os/exec"
)
@krzemienski
krzemienski / main.go
Created January 25, 2024 15:48 — forked from tehmoon/main.go
Download from s3 in a streaming fashion
package main
import (
"net/url"
"fmt"
"github.com/tehmoon/errors"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/aws/aws-sdk-go/service/s3"
"io"
@krzemienski
krzemienski / install-nginx-rtmp-module.sh
Created December 31, 2023 22:04 — forked from afriza/install-nginx-rtmp-module.sh
Install NGINX RTMP module with HLS support on Ubuntu 18.04
sudo apt install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt update
NGINX_VERSION=$(apt show nginx | grep "^Version" | cut -d " " -f 2 | cut -d "-" -f 1)
# take note of the nginx version in the "stable" release. e.g. 1.14.2
echo NGINX version $NGINX_VERSION
wget https://hg.nginx.org/pkg-oss/raw-file/default/build_module.sh
chmod a+x build_module.sh
@krzemienski
krzemienski / install-nginx-rtmp-module.sh
Created December 31, 2023 22:04 — forked from afriza/install-nginx-rtmp-module.sh
Install NGINX RTMP module with HLS support on Ubuntu 18.04
sudo apt install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt update
NGINX_VERSION=$(apt show nginx | grep "^Version" | cut -d " " -f 2 | cut -d "-" -f 1)
# take note of the nginx version in the "stable" release. e.g. 1.14.2
echo NGINX version $NGINX_VERSION
wget https://hg.nginx.org/pkg-oss/raw-file/default/build_module.sh
chmod a+x build_module.sh
@krzemienski
krzemienski / encoding.txt
Created September 14, 2023 19:29 — forked from Andrey2G/encoding.txt
Video Encoding with multiple resolutions
ffmpeg -i "c:/videos/sample.mp4
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0
-c:v libx264 -crf 22 -c:a aac -ar 48000
-filter:v:0 scale=w=480:h=360 -maxrate:v:0 600k -b:a:0 64k
-filter:v:1 scale=w=640:h=480 -maxrate:v:1 900k -b:a:1 128k
-filter:v:2 scale=w=1280:h=720 -maxrate:v:2 900k -b:a:2 128k
-var_stream_map "v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p"
-preset slow -hls_list_size 0 -threads 0 -f hls -hls_playlist_type event -hls_time 3
-hls_flags independent_segments -master_pl_name "name-pl.m3u8"
"c:/videos/encoded/name-%v.m3u8"
@krzemienski
krzemienski / ffmpeg-gnu-parallel-snippets.md
Created June 11, 2023 19:16 — forked from Brainiarc7/ffmpeg-gnu-parallel-snippets.md
Some snippets you can quickly adapt for use with FFmpeg and GNU Parallel for use for standard tasks.

Useful Examples of ffmpeg and GNU parallel on the command-line:

Transcoding FLAC music to Opus:

ffmpeg is a highly useful application for converting music and videos. However, audio transcoding is limited to a a single core. If you have a large FLAC archive and you wanted to compress it into the efficient Opus codec, it would take forever with the fastest processor to complete, unless you were to take advantage of all cores in your CPU.

parallel 'ffmpeg -v 0 -i "{}" -c:a libopus -b:a 128k "{.}.opus"' ::: $(find -type f -name '*.flac')

Transcoding Videos to VP9:

@krzemienski
krzemienski / nvenc-capabilities-ffmpeg.md
Created June 11, 2023 19:16 — forked from Brainiarc7/nvenc-capabilities-ffmpeg.md
See the supported NVENC and NPP capabilities in your FFmpeg build

Quickly check for supported NVENC and NPP hardware acceleration capabilities in FFmpeg on your platform:

Depending on how you built ffmpeg, you may want to check the supported NVENC-based hardware acceleration capabilities in ffmpeg by running:

$ for i in encoders decoders filters; do
    echo $i:; ffmpeg -hide_banner -${i} | egrep -i "npp|cuvid|nvenc|cuda|nvdec"
done

Sample output (as on my testbed):

@krzemienski
krzemienski / nvenc-install.sh
Created June 4, 2023 04:08 — forked from lucaspar/nvenc-install.sh
Installation script of CUDA-accelerated `ffmpeg` with NVIDIA Encoder
#!/bin/bash
# ==================================================================
# This script will compile and install a static ffmpeg build with
# support for NVENC in Ubuntu. Developed in Ubuntu 22.04 LTS,
# with NVIDIA Drivers v510.73 and CUDA v11.6
# It assumes NVIDA drivers are installed and that you have a
# CUDA-compatible GPU. You can check installed drivers with:
# $ apt list *nvidia-driver-* | grep installed
# $ nvidia-smi
# ==================================================================
@krzemienski
krzemienski / install_golang.sh
Created April 5, 2023 03:17 — forked from jniltinho/install_golang.sh
Install Golang on Linux
#!/bin/bash
## Install Golang 1.19 64Bits on Linux (Debian|Ubuntu|OpenSUSE|CentOS)
## http://www.linuxpro.com.br/2015/06/golang-aula-1-instalacao-da-linguagem-no-linux.html
## Run as root (sudo su)
## Thank's @geosoft1 | @gwmoura
GO_URL="https://go.dev/dl"
GO_VERSION=${1:-"1.19"}
GO_FILE="go$GO_VERSION.linux-amd64.tar.gz"
@krzemienski
krzemienski / docker-api-port.md
Last active March 27, 2023 17:37 — forked from styblope/docker-api-port.md
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}