Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
# Usage: ./stream.sh <input-video>

# Ensure there's a clean HLS directory
mkdir -p /dev/shm/hls;
rm /dev/shm/hls*

ffmpeg -re -i "$1" -vf "bwdif=mode=send_field:parity=tff,crop=692:554:14:8,format=yuv420p" \
    -loglevel repeat+info \
    -preset ultrafast -vcodec libx264 -tune zerolatency -flags +cgop -g 50 -b:v 5700k \
    -c:a aac -b:a 192k -ar 48000 -strict 2 \
    -movflags +faststart \
    -f hls \
    -hls_time 1\
    -hls_list_size 1 \
    -hls_wrap 20 \
    -hls_delete_threshold 1 \
    -hls_flags delete_segments \
    -hls_start_number_source datetime \
    -start_number 10 \
    /dev/shm/hls/stream.m3u8

UDP stream

# Re-stream a PAL 50i file to UDP
ffmpeg -re -i "$1" -vf "bwdif=mode=send_field:parity=tff,crop=692:554:14:8,format=yuv420p" \
    -preset ultrafast -vcodec libx264 -tune zerolatency -flags +cgop -g 50 -b:v 5700k \
    -c:a aac -b:a 192k -ar 48000 -strict 2 \
    -movflags +faststart \
    -f mpegts \
    'udp://127.0.0.1:5333/?pkt_size=1024&buffer_size=65535'
ffmpeg -re -i "$1" -c:v libx264 -preset ultrafast -crf 25 -flags +cgop -g 17 -c:a aac -b:a 192k -ar 48000 -strict 2 -f mpegts 'udp://127.0.0.1:5333'
@Balance134
Copy link

Balance134 commented May 9, 2022

gid:e6nHPL2cNZnqABwgHg4trP

@sfahadshahzad
Copy link

sfahadshahzad commented May 9, 2022

Hi,

How to create UDP CBR MPEGTS stream using decklink SDI input ?

Regards,

Fahad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment