Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save christianpetri/a66ba00e0297cebd8b61 to your computer and use it in GitHub Desktop.
Save christianpetri/a66ba00e0297cebd8b61 to your computer and use it in GitHub Desktop.
Streaming from Sony PXW X70 with ffmpeg. Display, save and forward stream to Youtube
## Stream to youtube with ffmpeg
## recieve stream from Sony PXW-X70
## Author: 2015 Philipp Gassmann (phiphi@phiphi.ch)
## Any copyright is dedicated to the Public Domain.
## http://creativecommons.org/publicdomain/zero/1.0/
# Download ffmpeg binary package for windows from here:
# http://ffmpeg.zeranoe.com/builds/
##To enable powerscripts run the following command in a Administrator PowerShell
#set-executionpolicy remotesigned
## Execute this script in Windows PowerShell with .\stream_from_pxw_x70.ps1
$VBR="2500k" # Bitrate to stream
$MAX="4000k" # Max Bitrate
$FPS=25 # Framerate
$QUAL="medium" # FFMPEG Quality
$YOUTUBE_URL="rtmp://x.rtmp.youtube.com/live2" # Youtube Server
$SOURCE="udp://0.0.0.0:1234?fifo_size=1024000&overrun_nonfatal=1" # Listen on port 1234, add buffering and recover from failures
$KEY="<Replace with your key>" # Stream Name from Youtube https://www.youtube.com/my_live_events
$LOGO="logo.png" # Logo only appears on first stream (Youtube)
$SAVETO = "Stream.ts" -replace ' ', '` '
## executable
$ffmpeg = "$HOME\Documents\streaming\ffmpeg-20150717-git-8250943-win64-static\bin\ffmpeg.exe" -replace ' ', '` '
# Display the video, save it to disk, add logo in upper right corner and stream it to youtube.
Invoke-Expression "$ffmpeg -thread_queue_size 1024 ``
-i '$SOURCE' ``
-i $LOGO -filter_complex '[0:v] [1:v] overlay=W-w-10:10'``
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -maxrate $MAX -b:v $VBR ``
-acodec libmp3lame -ar 44100 -threads 6 -crf 28 -b:a 712000 -bufsize 2000k ``
-f flv '$YOUTUBE_URL/$KEY' ``
-vcodec rawvideo -pix_fmt yuv420p -f sdl 'Live Preview' ``
-c copy -f mpegts $SAVETO"
## Just display:
# Invoke-Expression "$ffmpeg ``
# -i $SOURCE ``
# -vcodec rawvideo -pix_fmt yuv420p -f sdl 'Live Preview'"
#! /bin/bash
#
# Stream to youtube with ffmpeg
# recieve stream from Sony PXW-X70
#
# Author: 2015 Philipp Gassmann (phiphi@phiphi.ch)
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
VBR="2500k" # Bitrate to stream
MAX="4000k" # Max Bitrate
FPS="25" # Framerate
QUAL="medium" # FFMPEG Quality
YOUTUBE_URL="rtmp://x.rtmp.youtube.com/live2" # Youtube Server
SOURCE="udp://:1234?fifo_size=1024000&overrun_nonfatal=1" # Listen on port 1234, add buffering and recover from failures
KEY="<Replace with your key>" # Stream Name from Youtube https://www.youtube.com/my_live_events
LOGO="logo.png" # Logo only appears on first stream (Youtube)
SAVETO = "Stream.ts"
# Display the video, save it to disk, add logo in upper right corner and stream it to youtube.
ffmpeg \
-i "$SOURCE" \
-i $LOGO -filter_complex "[0:v] [1:v] overlay=W-w-10:10"\
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -maxrate $MAX -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -crf 28 -b:a 712000 -bufsize 2000k \
-f flv "$YOUTUBE_URL/$KEY" \
-vcodec rawvideo -pix_fmt yuv420p -f sdl "Live Preview" \
-c copy -f mpegts $SAVETO
# Just display:
# ffmpeg \
# -i "$SOURCE" \
# -vcodec rawvideo -pix_fmt yuv420p -f sdl "Live Preview"
## Just stream and display:
#ffmpeg \
# -i "$SOURCE" \
# -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -maxrate $MAX -b:v $VBR \
# -acodec libmp3lame -ar 44100 -threads 6 -crf 28 -b:a 712000 -bufsize 2000k \
# -f flv "$YOUTUBE_URL/$KEY" \
# -vcodec rawvideo -pix_fmt yuv420p -f sdl "Live Preview"

Streaming from Sony PXW-X70

Streaming from Sony PXW X70 with ffmpeg. Display, save and forward stream to Youtube

Camera Settings

requires Firmware 2.0

  • Configure your camera to connect to the same network as your Computer (Network > Wi-Fi SET)
  • Go to the Network -> Streaming Menu
  • Configure the Preset,
    • Set SIZE to 1280x720
    • In DESTINATION SET enter the IP of your Computer as Host Name (You can use the Touchscreen)
    • Leave Port on 1234
  • Set PRESET SELECT to the Preset you just configured
  • Select EXECUTE and choose Wi-Fi
  • Press the [THUMBNAIL] button to start sending the stream.

Script Settings

  • Go to Youtube and prepare your livestream https://www.youtube.com/my_live_events
  • Edit the Script to your liking
    • e.g. Remove logo filter line
    • e.g. remove copy stream line
  • Replace the placeholder with your Youtube stream name
  • Execute the script

Execution on Windows

To enable execution of local PowerShell scripts run the following command in a Administrator PowerShell

set-executionpolicy remotesigned

Start PowerShell, navigate to the folder of the script and execute the script.

cd .\Downloads
.\stream_from_pxw_x70.ps1

View Stream with VLC

Open Network Stream Ctrl+N and enter udp://:1234

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