pyffstream¶
A CLI wrapper for ffmpeg to stream files over SRT/RTMP. Also supports the api for a not (yet) open sourced pyffserver endpoint.
Installation¶
To install pyffstream download a binary from Github releases, or run this command in your terminal:
$ pip install pyffstream
CLI Usage¶
pyffstream¶
CLI frontend for streaming over SRT and RTMP.
usage: pyffstream [-h] [--config FILE] [--show-config-dirs] [-v]
[--logfile FILE] [-b BITRATE] [-M BITRATE] [-A BITRATE]
[--aencoder {aac,libfdk_aac,libopus}] [-o] [-p] [-i]
[-t TIMESTAMP] [-I OPT] [--pyffserver | --no-pyffserver]
[-y] [--srt-passphrase PASSWORD] [--srt-latency SEC]
[--protocol {rtmp,srt}] [-U URL] [-k KEY]
[-E DOMAIN[:PORT][PATH]] [-w] [-B]
[--hwaccel | --no-hwaccel] [-e] [--subfile FILE] [-s N]
[--suboffset TIMESTAMP] [-a N] [--vindex N] [--live]
[--fix-start-time | --no-fix-start-time]
[--soxr | --no-soxr] [--fifo | --no-fifo]
[--zscale | --no-zscale] [--fdk] [-f FILE] [-T LENGTH] [-D]
[--copy-audio] [--copy-video] [-c COPY] [-H] [-8]
[--h264-nvenc] [-x] [--preset PRESET] [--tune TUNE]
[--realtime | --no-realtime] [--pass N] [--passfile FILE]
[--vgop | --no-vgop]
[--vencoder {h264_nvenc,hevc_nvenc,libaom-av1,librav1e,libsvtav1,libvpx-vp9,libx264,libx265}]
[-u] [--slowseek] [-d]
[--framerate-multiplier FRAMERATE_MULTIPLIER] [-C]
[--croptime TIMESTAMP]
[--cleanborders LEFT RIGHT TOP BOTTOM]
[--croplength DURATION] [-V | --vulkan | --no-vulkan]
[--trust-vulkan | --no-trust-vulkan] [--vulkan-device NUM]
[--sw-filters FILTER] [-P OPT] [--vencoder-params PARAM]
[-z] [--subfirst | --no-subfirst] [--picsubscale ALGORITHM]
[--nodecimate | --paldecimate | --sixtyfps]
[--audio | --no-audio] [-n] [-N FILE | -Q]
[--height HEIGHT | -4 | -2 | -7] [-K SEC] [--mono]
[--startdelay] [--endpad | --no-endpad] [--tempdir DIR]
[--shaders PATH_TO_SHADER]
[--system-ffmpeg | --downloaded-ffmpeg] [--redownload]
[--dltype {git,stable}] [--write]
[FILES ...]
optional arguments¶
- -h, --help¶
show this help message and exit
- --config <file>¶
Path to config file
- --show-config-dirs¶
Print out config search locations
- -v, --verbose¶
increase verbosity level
- --logfile <file>¶
path to logfile to send output to
- -p, --playlist¶
make ffconcat playlist from input files
- -i, --print-info¶
print information about input file(s) instead of streaming
- -t <timestamp>, --timestamp <timestamp>¶
timestamp to start stream from
- -I <opt>, --preinput-opts <opt>¶
pass option ffmpeg before input (specify once/item)
- -w, --wait¶
wait for keypress before starting stream
- --fix-start-time, --no-fix-start-time¶
Fix start_time of streams (default: True)
- -c <copy>, --copy <copy>¶
pass a/v to copy audio/video
- --slowseek¶
use slow ffmpeg seeking
- --startdelay¶
delay stream start by 30 seconds
- --endpad, --no-endpad¶
Pad end of stream with nothing to prevent early stream cutoff. (default: True)
- --tempdir <dir>¶
directory to use for storing temporary files
- --shaders <path_to_shader>¶
shader to use with vulkan (specify once for each shader to add) (default: [])
- --system-ffmpeg¶
use system ffmpeg binaries instead of configured (default is system if unconfigured)
- --downloaded-ffmpeg¶
Use downloaded local Windows ffmpeg instead of configured or system ffmpeg (default is to only use as a fallback)
- --redownload¶
Redownload stored local Windows ffmpeg binaries
- --dltype {git,stable}¶
Type of Windows ffmpeg binary to download (default: git)
- --write¶
write chosen arguments as defaults to config if not already default
input arguments¶
- files¶
list of input files and directories; if last argument is file already contained in input list, start list from that file
- -o, --obs¶
get input from OBS pipe
- -B, --bluray¶
input directory is bluray
- --hwaccel, --no-hwaccel¶
Attempt to automatically use hw accelerated decoding if available (default: True)
- --live¶
hint that input is live
- -D, --deep-probe¶
pass extra args to probe input file deeper
- --nodecimate¶
don’t decimate 30 fps obs input to 24 fps
- --paldecimate¶
decimate 30 fps obs input to 25 fps
- --sixtyfps¶
don’t halve 60 fps obs input to 30 fps
video arguments¶
- -b <bitrate>, --vbitrate <bitrate>¶
encoding video bitrate (ffmpeg num) (default: 6M)
- -M <bitrate>, --max-vbitrate <bitrate>¶
max encoding video bitrate (ffmpeg num) (default: vbitrate)
- --vindex <n>¶
subindex of video stream to use (default: 0)
- --zscale, --no-zscale¶
Use zimg library for scaling instead of ffmpeg’s scale (default: False)
- --copy-video¶
copy video stream from input
- -H, --hevc-nvenc¶
encode with NVENC HEVC
- -8, --eightbit¶
encode with 8-bit HEVC (default 10-bit)
- --h264-nvenc¶
encode with NVENC H264
- -x, --x264¶
encode with x264
- --preset <preset>¶
preset to use for encoding
- --tune <tune>¶
tune parameter to use for supported encoders
- --realtime, --no-realtime¶
tune for realtime encoding on encoders that support it (default: False)
- --pass {1,2,3}¶
encoder pass
- --passfile <file>¶
multipass statistics file to use
- --vgop, --no-vgop¶
use variable GOP length and treat keyframe target as max (default: False)
- --vencoder {h264_nvenc,hevc_nvenc,libaom-av1,librav1e,libsvtav1,libvpx-vp9,libx264,libx265}¶
video encoder to use (default: libx264)
- -u, --upscale¶
unconditionally scale video to target size
- -d, --deinterlace¶
deinterlace video
- --framerate-multiplier <framerate_multiplier>¶
fraction to multiply framerate by (e.g. because a filter modifies it)
- -C, --crop¶
automatically crop video
- --croptime <timestamp>¶
timestamp to start crop calculation at (default: 600)
- --cleanborders <left> <right> <top> <bottom>¶
Clean up N pixels of border after crop
- --croplength <duration>¶
duration to estimate crop for (default: 60)
- -V, --vulkan, --no-vulkan¶
use vulkan processing path (default: False)
- --trust-vulkan, --no-trust-vulkan¶
whether to trust ffmpeg vulkan to do the right thing or use workarounds (default: False)
- --vulkan-device <num>¶
GPU device listing to use for vulkan HW context
- --sw-filters <filter>¶
pass software ffmpeg filter to filter chain start (specify once/filter)
- -P <opt>, --placebo-opts <opt>¶
pass option to vf_libplacebo when using vulkan (specify once/opt)
- --vencoder-params <param>¶
pass option to params argument of encoders (specify once/param)
- --height <height>¶
target 16:9 bounding box encode height (default: 1080)
- -4, --res2160¶
set 4k encoding resolution
- -2, --res1440¶
set 1440p encoding resolution
- -7, --res720¶
set 720p encoding resolution
audio arguments¶
- -A <bitrate>, --abitrate <bitrate>¶
encoding audio bitrate (ffmpeg num) (default: 256k)
- --aencoder {aac,libfdk_aac,libopus}¶
audio encoder to use (default: aac)
- -a <n>, --aindex <n>¶
subindex of audio stream to use (default: 0)
- --soxr, --no-soxr¶
Use SoX resampler library instead of ffmpeg’s avresample (default: False)
- --fdk¶
Use libfdk_aac encoder
- --copy-audio¶
copy audio stream from input
- --audio, --no-audio¶
attempt to include audio in output (default: True) (default: True)
- -n, --anormalize¶
normalize audio (implied by -N and -Q)
- -N <file>, --normfile <file>¶
path to file to store audio normalization data
- -Q, --dynamicnorm¶
do one-pass audio normalization
- --mono¶
output audio in mono
subtitle arguments¶
- -e, --subs¶
enable subtitles
- --subfile <file>¶
path to external subtitles
- -s <n>, --sindex <n>¶
subindex of subtitle stream to use
- --suboffset <timestamp>¶
timestamp to offset subtitle timing by
- -z, --cropsecond¶
crop after subtitles are rendered
- --subfirst, --no-subfirst¶
render subtitles and crop video before scaling (default: False)
- --picsubscale <algorithm>¶
algorithm to use for scaling picture subtitles (default: bicubic)
output arguments¶
- --pyffserver, --no-pyffserver¶
use pyffserver as an API to send to (default: False)
- -y, --overwrite¶
overwrite output file if it already exists
- --srt-passphrase <password>¶
optional passphrase to use for SRT when not streaming to a pyffserver
- --srt-latency <sec>¶
SRT latency (default: 5.0)
- --protocol {rtmp,srt}¶
streaming protocol to use (default: srt)
- -U <url>, --api-url <url>¶
pyffserver API URL to use (default: from config)
- -k <key>, --api-key <key>¶
pyffserver API key to use (default: from config)
- -E <domain[:port][path]>, --endpoint <domain[:port][path]>¶
endpoint to stream to without protocol (default: from config))
- --fifo, --no-fifo¶
Use FIFO to try to sustain and stabilize the connection. (default: False)
- -f <file>, --outfile <file>¶
path to an output file to use instead of streaming
- -T <length>, --cliplength <length>¶
clip stream to this length
- -K <sec>, --keyframe-target-sec <sec>¶
target keyframe interval in seconds (default: 5.0)