wargio / Twitch-Streamer-Linux

This is a script dedicated to stream to Twitch.tv with Webcam support
217 stars 39 forks source link

Worked with Ubuntu 12.04, but not with 14.04 somehow #35

Open pressure679 opened 10 years ago

pressure679 commented 10 years ago

I'm not sure what goes wrong, tried to install libavcodec-extra-53 along with libavcodec-extra-54 but didn't work out. Runs fine until this red text comes out:

[overlay @ 0x22cfa40] Overlay area (-991,10)<->(310,754) not within the main area (0,0)<->(320,240) or zero-sized
[fifo @ 0x22d13c0] Failed to configure input pad on Parsed filter 4 overlay
Error opening filters!

Stopping Audio (Don't worry if you see errors here)
Failed to unload module: Module module-null-sink not loaded
Exit!
wargio commented 10 years ago

can i see the whole output? (be sure to delete the twitch streaming key from it)

pressure679 commented 10 years ago
Twitch Streamer for Linux (twitch_avconv.sh)
Copyright (c) 2013 - 2014, Giovanni Dante Grazioli (deroad)

Using twitch key located in current running directory
Click, with the mouse, on the Window that you want to Stream

Please setup the Audio Output to sink null (something like 'pavucontrol')
Webcam found!!
You should be online! Check on http://twitch.tv/ (Press CTRL+C to stop)

avconv version 9.13-6:9.13-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on May  9 2014 13:34:03 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[x11grab @ 0x22602c0] device: :0.0+65,310 -> display: :0.0 x: 65 y: 310 width: 802 height: 458
[x11grab @ 0x22602c0] shared memory extension  found
[x11grab @ 0x22602c0] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+65,310':
  Duration: N/A, start: 1401729780.523112, bitrate: 246836 kb/s
    Stream #0.0: Video: rawvideo, bgra, 802x458, 246836 kb/s, 1000k tbn, 21 tbc
[alsa @ 0x226bc20] capture with some ALSA plugins, especially dsnoop, may hang.
[alsa @ 0x226bc20] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1401729780.598342, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2 @ 0x225b280] Estimating duration from bitrate, this may be inaccurate
[overlay @ 0x225e1c0] Overlay area (-492,10)<->(310,468) not within the main area (0,0)<->(320,240) or zero-sized
[fifo @ 0x225fb40] Failed to configure input pad on Parsed filter 4 overlay
Error opening filters!

Stopping Audio (Don't worry if you see errors here)
Failed to unload module: Module module-null-sink not loaded
Exit!
pressure@pressure:~/Twitch-Streamer-Linux$ ./twitch_avconv.sh > error.txt
avconv version 9.13-6:9.13-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on May  9 2014 13:34:03 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[x11grab @ 0x8b72c0] device: :0.0+65,310 -> display: :0.0 x: 65 y: 310 width: 802 height: 458
[x11grab @ 0x8b72c0] shared memory extension  found
[x11grab @ 0x8b72c0] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+65,310':
  Duration: N/A, start: 1401729799.974607, bitrate: 246836 kb/s
    Stream #0.0: Video: rawvideo, bgra, 802x458, 246836 kb/s, 1000k tbn, 21 tbc
[alsa @ 0x8c2c20] capture with some ALSA plugins, especially dsnoop, may hang.
[alsa @ 0x8c2c20] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1401729799.987972, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2 @ 0x8ed000] Estimating duration from bitrate, this may be inaccurate
[overlay @ 0x8eec40] Overlay area (-492,10)<->(310,468) not within the main area (0,0)<->(320,240) or zero-sized
[fifo @ 0x8b34a0] Failed to configure input pad on Parsed filter 4 overlay
Error opening filters!
Failed to unload module: Module module-null-sink not loaded
wargio commented 10 years ago

can you paste your options? because there is a problem with your webcam options.

pressure679 commented 10 years ago
#! /bin/bash 

Copyright (c) 2013, Giovanni Dante Grazioli (deroad)

================================================ OPTIONS =====================================================
Streaming Options
OUTRES="1280x720"     # Twitch Output Resolution
FPS="21"              # Frame per Seconds (Suggested 24, 25, 30 or 60)
THREADS="4"           # Change this if you have a good CPU (Suggested 4 threads, Max 6 threads)
QUALITY="ultrafast"   # ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
CBR="1000k"           # Constant bitrate (CBR) Increase this to get a better pixel quality (1000k - 3000k for twitch)

Webcam Options
WEBCAM="/dev/video0" # WebCam device
WEBCAM_WH="320:240"  # WebCam Width end Height

STREAM KEY
You can find YOUR key here: http://www.twitch.tv/broadcast/ (Show Key button)
Save your key inside the twitch_key file
Or make a global file named ".twitch_key" in your home directory (~/.twitch_key)

Twitch Server list http://bashtech.net/twitch/ingest.php
SERVER="live-fra"    # EU server

Change this to 'true' if you want to go always on FULLSCREEN, this will disable the output.
ALWAYS_FULLSCREEN=false

Change this to 'true' if you want to hide your STREAM_KEY, for security purpose (this will disable most of the output).
This will not affect the ALWAYS_FULLSCREEN option. ALWAYS_FULLSCREEN will always disable the output.
SUPPRESS_OUTPUT=false

Twitch says it MUST have a 44100 rate, please do not change it unless you know what you are doing.
AUDIO_RATE="44100"
wargio commented 10 years ago

Go on the script and find: [WebCam] overlay=main_w-overlay_w-10:10 [out] then change it to [WebCam] overlay=10:10 [out]

Tell me if it works. if it does, please report immediately, and i'll update the script [edit] i've updated the script. check it. it may work better.

pressure679 commented 10 years ago

Great, I'll check it out, although I can see that some people are waiting to use Ubuntu 14.04 because of some missing release or something, so should I probably. Keep up the good work.

steffansluis commented 10 years ago

I got the streaming working under Ubuntu 14.04 GNOME Remix, mostly by following the instructions from the README. I didn't get the webcam overlay working though, I think it's because of my dual-monitor setup but I'm not sure. I can use MPlayer to feed back the video although I think that might cause it to be out of sync. There don't seem to be any missing packages though.

wargio commented 10 years ago

Well, the overlay should not be affected by the number of the screens. I'll try to build the latest ffmpeg/avconv version and see what happens

manofsticks commented 10 years ago

I receive the same error as pressure679 did with the avconv script (except different numbers), even after trying the overlay change you suggested, and after using your most recent updates.

If I don't use a webcam, it seems to work fine.

[overlay @ 0x15b3360] Overlay area (950,10)<->(1902,738) not within the main area (0,0)<->(320,240) or zero-sized
[fifo @ 0x15b4ea0] Failed to configure input pad on Parsed filter 4 overlay
Error opening filters!

Stopping Audio (Don't worry if you see errors here)
Exit!

And for my options (mostly unchanged)

# Streaming Options
OUTRES="1280x720" # Twitch Output Resolution
FPS="24" # Frame per Seconds (Suggested 24, 25, 30 or 60)
THREADS="4" # Change this if you have a good CPU (Suggested 4 threads, Max 6 threads)
QUALITY="ultrafast" # ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
CBR="1000k" # Constant bitrate (CBR) Increase this to get a better pixel quality (1000k - 3000k for twitch)

# Webcam Options
WEBCAM="/dev/video0" # WebCam device
WEBCAM_WH="320:240" # WebCam Width end Height
WEBCAM_XY="" # WebCam Position (in pixel) example: "10:10", if "" (empty) then it will set the standard position

# File to save if you do not want to stream
FILE_VIDEO="my.flv" # File name

# STREAM KEY
# You can find YOUR key here: http://www.twitch.tv/broadcast/ (Show Key button)
# Save your key inside the twitch_key file
# Or make a global file named ".twitch_key" in your home directory (~/.twitch_key)

# Twitch Server list http://bashtech.net/twitch/ingest.php
SERVER="live-fra" # EU server

# Change this to 'true' if you want to go always on FULLSCREEN, this will disable the output.
ALWAYS_FULLSCREEN=false

# Change this to 'true' if you want to hide your STREAM_KEY, for security purpose (this will disable most of the output).
# This will not affect the ALWAYS_FULLSCREEN option. ALWAYS_FULLSCREEN will always disable the output.
SUPPRESS_OUTPUT=false

# Twitch says it MUST have a 44100 rate, please do not change it unless you know what you are doing.
AUDIO_RATE="44100"
wargio commented 10 years ago

Try to change [in] setpts=PTS-STARTPTS, [WebCam] overlay=$WEBCAM_XY [out] to [in] [WebCam] overlay=$WEBCAM_XY [out]

manofsticks commented 10 years ago

I changed it in both instances where that line occurs, since I assume you meant both. No change of result, same thing except different numbers in the error.

[overlay @ 0xf0c940] Overlay area (950,10)<->(1270,250) not within the main area (0,0)<->(952,723) or zero-sized
[fifo @ 0xf0e580] Failed to configure input pad on Parsed filter 3 overlay
Error opening filters!

Stopping Audio (Don't worry if you see errors here)
Failed to unload module: Module module-null-sink not loaded
Exit!
wargio commented 10 years ago

try this: Change -vf "movie=$WEBCAM:f=video4linux2, scale=$WEBCAM_WH , setpts=PTS-STARTPTS [WebCam]; [in] setpts=PTS-STARTPTS, [WebCam] overlay=$WEBCAM_XY [out]" to -i $WEBCAM -f video4linux2 -filter_complex "[2:v] scale=$WEBCAM_WH[WebCam]; [0:v][WebCam] overlay=$WEBCAM_XY [outv]"

i'm not so sure about this [2:v] so, if it do not work (black square) or it says it can't find something, then change that to [1:v]

manofsticks commented 10 years ago

When running with 2:v, I get

[x11grab @ 0x202cb20] shared memory extension  found
[x11grab @ 0x202cb20] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+939,265':
  Duration: N/A, start: 1406651070.294543, bitrate: 532267 kb/s
    Stream #0.0: Video: rawvideo, bgra, 952x728, 532267 kb/s, 1000k tbn, 24 tbc
[alsa @ 0x203cd00] capture with some ALSA plugins, especially dsnoop, may hang.
[alsa @ 0x203cd00] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1406651070.299482, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[flv @ 0x203e9e0] Broken FLV file, which says no streams present, this might fail
Option sample_rate not found.

Stopping Audio (Don't worry if you see errors here)
Failed to unload module: Module module-null-sink not loaded
Exit!

with 1:v I get

[x11grab @ 0xeebb20] shared memory extension  found
[x11grab @ 0xeebb20] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+939,265':
  Duration: N/A, start: 1406651284.531940, bitrate: 532267 kb/s
    Stream #0.0: Video: rawvideo, bgra, 952x728, 532267 kb/s, 1000k tbn, 24 tbc
[alsa @ 0xefbd00] capture with some ALSA plugins, especially dsnoop, may hang.
[alsa @ 0xefbd00] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1406651284.546804, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[flv @ 0xefdfe0] Broken FLV file, which says no streams present, this might fail
Option sample_rate not found.

Stopping Audio (Don't worry if you see errors here)
Failed to unload module: Module module-null-sink not loaded
Exit!
wargio commented 10 years ago

sorry for such late reply, but i had no internet for a week; anyway, try to change the line to

avconv -f x11grab -s $INRES -framerate "$FPS" -i :0.0+$TOPXY -f video4linux2 -i $WEBCAM -f alsa -i pulse -f flv -ac 2 -ar $AUDIO_RATE -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv420p -s $OUTRES -preset $QUALITY -tune film  -acodec libmp3lame -threads $THREADS -filter_complex "[1:v] scale=$WEBCAM_WH[WebCam]; [0:v][WebCam] overlay=$WEBCAM_XY [outv] -strict normal -bufsize $CBR $LOGLEVEL_ARG "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"