wargio / Twitch-Streamer-Linux

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

I have no clue what I'm doing wrong #22

Open jelly-rolls opened 10 years ago

jelly-rolls commented 10 years ago

I set up the stream key, I don't have a webcam and I'm not worrying about audio yet.

This is probably user error, but I'm not sure what's going wrong

Here is what happens when run in terminal.

Twitch Streamer for Linux Copyright (c) 2013, Giovanni Dante Grazioli (deroad)

Click, with the mouse, on the Window that you want to Stream

Please setup the Audio Output (something like 'pavucontrol') 74

Webcam NOT found!! (/dev/video1) You should be online! Check on http://twitch.tv/ (Press CTRL+C to stop) avconv version 0.8.10-6:0.8.10-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers built on Feb 6 2014 20:59:46 with gcc 4.8.1 [x11grab @ 0x8638080] device: :0.0+627,110 -> display: :0.0 x: 627 y: 110 width: 538 height: 386 [x11grab @ 0x8638080] shared memory extension found [x11grab @ 0x8638080] Estimating duration from bitrate, this may be inaccurate Input #0, x11grab, from ':0.0+627,110': Duration: N/A, start: 1392762601.018494, bitrate: 199361 kb/s Stream #0.0: Video: rawvideo, bgra, 538x386, 199361 kb/s, 30 tbr, 1000k tbn, 30 tbc [alsa @ 0x8642b00] capture with some ALSA plugins, especially dsnoop, may hang. [alsa @ 0x8642b00] Estimating duration from bitrate, this may be inaccurate Input #1, alsa, from 'pulse': Duration: N/A, start: 1392762600.995823, bitrate: N/A Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s Incompatible pixel format 'bgra' for codec 'libx264', auto-selecting format 'yuv420p' [buffer @ 0x8644a40] w:538 h:386 pixfmt:bgra [scale @ 0x8654ba0] w:538 h:386 fmt:bgra -> w:1336 h:768 fmt:yuv420p flags:0x4 ./twitch.sh: line 82: 16088 Segmentation fault (core dumped) avconv -f x11grab -s $INRES -r "$FPS" -i :0.0+$TOPXY -f alsa -ac 2 -i pulse -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b $CBR -minrate $CBR -maxrate $CBR -s $OUTRES -preset $QUALITY -tune film -qscale:v 1 -threads:v $THREADS -acodec libmp3lame -ar 44100 -threads $THREADS -qscale:a 1 -bufsize $CBR -f flv "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"

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 ffmpeg script.

jelly-rolls commented 10 years ago

tried to run ffmpeg

Twitch Streamer for Linux Copyright (c) 2013, Giovanni Dante Grazioli (deroad)

Click, with the mouse, on the Window that you want to Stream

Please setup the Audio Output to sink null (something like 'pavucontrol') 174

Webcam NOT found!! (/dev/video1) You should be online! Check on http://twitch.tv/ (Press CTRL+C to stop) ./twitch_ffmpeg.sh: line 85: ffmpeg: command 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

install ffmpeg and try again.

jelly-rolls commented 10 years ago

re-installed ffmpeg

Twitch Streamer for Linux Copyright (c) 2013, Giovanni Dante Grazioli (deroad)

Click, with the mouse, on the Window that you want to Stream

Please setup the Audio Output to sink null (something like 'pavucontrol') 184

Webcam NOT found!! (/dev/video1) You should be online! Check on http://twitch.tv/ (Press CTRL+C to stop) ffmpeg version 0.8.10-6:0.8.10-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers built on Feb 6 2014 20:59:46 with gcc 4.8.1 * THIS PROGRAM IS DEPRECATED * This program is only provided for compatibility and will be removed in a future release. Please use avconv instead. [x11grab @ 0x825e080] device: :0.0+284,172 -> display: :0.0 x: 284 y: 172 width: 794 height: 595 [x11grab @ 0x825e080] shared memory extension found [x11grab @ 0x825e080] Estimating duration from bitrate, this may be inaccurate Input #0, x11grab, from ':0.0+284,172': Duration: N/A, start: 1392768255.897162, bitrate: 453532 kb/s Stream #0.0: Video: rawvideo, bgra, 794x595, 453532 kb/s, 30 tbr, 1000k tbn, 30 tbc [alsa @ 0x8268a20] capture with some ALSA plugins, especially dsnoop, may hang. [alsa @ 0x8268a20] Estimating duration from bitrate, this may be inaccurate Input #1, alsa, from 'pulse': Duration: N/A, start: 1392768254.989441, bitrate: N/A Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s [buffer @ 0x826a960] w:794 h:595 pixfmt:bgra [scale @ 0x8278a60] w:794 h:595 fmt:bgra -> w:1280 h:720 fmt:yuv420p flags:0x4 ./twitch_ffmpeg.sh: line 82: 19052 Segmentation fault (core dumped) ffmpeg -f x11grab -s $INRES -r "$FPS" -i :0.0+$TOPXY -f alsa -i pulse -f flv -ac 2 -ar 44100 -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv420p -s $OUTRES -preset $QUALITY -tune film -acodec libmp3lame -threads $THREADS -strict normal -bufsize $CBR "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"

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

This is a correct output. your is segfaulting on the x264 lib. have you installed it? is it not broken? check also if you have libmp3lame installed.

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

Click, with the mouse, on the Window that you want to Stream

Please setup the Audio Output to sink null (something like 'pavucontrol')

Webcam NOT found!! (/dev/video1)
You should be online! Check on http://twitch.tv/ (Press CTRL+C to stop)
ffmpeg version 0.8.9-6:0.8.9-0ubuntu0.13.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Nov  9 2013 19:09:48 with gcc 4.7.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[x11grab @ 0x1a1dd40] device: :0.0+851,423 -> display: :0.0 x: 851 y: 423 width: 940 height: 362
[x11grab @ 0x1a1dd40] shared memory extension  found
[x11grab @ 0x1a1dd40] Estimating duration from bitrate, this may be inaccurate
Input #0, x11grab, from ':0.0+851,423':
  Duration: N/A, start: 1392800017.783750, bitrate: 326668 kb/s
    Stream #0.0: Video: rawvideo, bgra, 940x362, 326668 kb/s, 30 tbr, 1000k tbn, 30 tbc
[alsa @ 0x1a18640] capture with some ALSA plugins, especially dsnoop, may hang.
[alsa @ 0x1a18640] Estimating duration from bitrate, this may be inaccurate
Input #1, alsa, from 'pulse':
  Duration: N/A, start: 1392800017.819086, bitrate: N/A
    Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[buffer @ 0x1a18d20] w:940 h:362 pixfmt:bgra
[scale @ 0x1a4af20] w:940 h:362 fmt:bgra -> w:1280 h:720 fmt:yuv420p flags:0x4
[libx264 @ 0x1a19600] lookaheadless mb-tree requires intra refresh or infinite keyint
[libx264 @ 0x1a19600] using cpu capabilities: MMX2 SSE2Slow SlowCTZ
[libx264 @ 0x1a19600] profile Constrained Baseline, level 3.1
[libx264 @ 0x1a19600] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:-1:-1 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.15 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=60 keyint_min=30 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=cbr mbtree=0 bitrate=1000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1000 vbv_bufsize=1000 nal_hrd=none ip_ratio=1.25 aq=0
Output #0, flv, to 'rtmp://live-fra.twitch.tv/app/live_xxxxxxxx_yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #0.0: Video: libx264, yuv420p, 1280x720, q=-1--1, 1000 kb/s, 1k tbn, 30 tbc
    Stream #0.1: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 1000 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #1.0 -> #0.1
Press ctrl-c to stop encoding
^Cframe=    7 fps=  0 q=-1.0 Lsize=     190kB time=1.20 bitrate=1294.6kbits/s dup=0 drop=1    
video:142kB audio:47kB global headers:0kB muxing overhead 0.650436%
frame I:1     Avg QP:32.00  size: 78217
[libx264 @ 0x1a19600] frame P:6     Avg QP:34.23  size: 11047
[libx264 @ 0x1a19600] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x1a19600] mb P  I16..4:  6.2%  0.0%  0.0%  P16..4:  9.5%  0.0%  0.0%  0.0%  0.0%    skip:84.2%
[libx264 @ 0x1a19600] coded y,uvDC,uvAC intra: 43.2% 39.5% 38.4% inter: 5.5% 3.2% 2.1%
[libx264 @ 0x1a19600] i16 v,h,dc,p: 69% 23%  5%  3%
[libx264 @ 0x1a19600] i8c dc,h,v,p: 69% 11% 19%  1%
[libx264 @ 0x1a19600] kb/s:456.31
jelly-rolls commented 10 years ago

Just re-installed both, the output appears to be the same

Twitch Streamer for Linux Copyright (c) 2013, Giovanni Dante Grazioli (deroad)

Click, with the mouse, on the Window that you want to Stream

Please setup the Audio Output to sink null (something like 'pavucontrol') 354

Webcam NOT found!! (/dev/video1) You should be online! Check on http://twitch.tv/ (Press CTRL+C to stop) ffmpeg version 0.8.10-6:0.8.10-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers built on Feb 6 2014 20:59:46 with gcc 4.8.1 * THIS PROGRAM IS DEPRECATED * This program is only provided for compatibility and will be removed in a future release. Please use avconv instead. [x11grab @ 0x9f53080] device: :0.0+66,477 -> display: :0.0 x: 66 y: 477 width: 538 height: 386 [x11grab @ 0x9f53080] shared memory extension found [x11grab @ 0x9f53080] Estimating duration from bitrate, this may be inaccurate Input #0, x11grab, from ':0.0+66,477': Duration: N/A, start: 1392842337.115805, bitrate: 199361 kb/s Stream #0.0: Video: rawvideo, bgra, 538x386, 199361 kb/s, 30 tbr, 1000k tbn, 30 tbc [alsa @ 0x9f5da20] capture with some ALSA plugins, especially dsnoop, may hang. [alsa @ 0x9f5da20] Estimating duration from bitrate, this may be inaccurate Input #1, alsa, from 'pulse': Duration: N/A, start: 1392842336.983249, bitrate: N/A Stream #1.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s [buffer @ 0x9f5f960] w:538 h:386 pixfmt:bgra [scale @ 0x9f62580] w:538 h:386 fmt:bgra -> w:1280 h:720 fmt:yuv420p flags:0x4 ./twitch_ffmpeg.sh: line 82: 28556 Segmentation fault (core dumped) ffmpeg -f x11grab -s $INRES -r "$FPS" -i :0.0+$TOPXY -f alsa -i pulse -f flv -ac 2 -ar 44100 -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b $CBR -minrate $CBR -maxrate $CBR -pix_fmt yuv420p -s $OUTRES -preset $QUALITY -tune film -acodec libmp3lame -threads $THREADS -strict normal -bufsize $CBR "rtmp://$SERVER.twitch.tv/app/$STREAM_KEY"

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

unfortunately it's a x264 bug (i've checked on the launchpad) i don't know how to help you. i can't do anything. the only suggestion i can give to you, is build it from the source.

jelly-rolls commented 10 years ago

After doing some testing the problem appears to be with the flv command, do you have any idea how to fix this?

wargio commented 10 years ago

so, there must be some lib from libav that makes ffmpeg & avconv segfaulting.

rodrigograca31 commented 9 years ago

I'm having the same problem, it stream for some minutes and them stops... Output:

Metadata: encoder : Lavf56.4.101 Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1366x768, q=-1--1, 1000 kb/s, 24 fps, 1k tbn, 24 tbc Metadata: encoder : Lavc56.1.100 libx264 Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, s16p, max. 1000 kb/s Metadata: encoder : Lavc56.1.100 libmp3lame Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help [swscaler @ 0x106f220] Warning: data is not aligned! This can lead to a speedloss WriteN, RTMP send error 104 (94 bytes)42kB time=00:03:01.83 bitrate= 632.6kbits/s dup=0 drop=1138

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

wargio commented 9 years ago

have you built it by your self as the How To says?

rodrigograca31 commented 9 years ago

@wargio no.... I'm using my "normal" ffmpeg...

But I will try it....

rodrigograca31 commented 9 years ago

This afternoon worked but with a very low frame rate, now after the "./configure..." command it's the same, low frame rate...

wargio commented 9 years ago

Wait. have you built ffmpeg and then edited the ffmpeg path on the script to use the built one? doing just ./configure [...] isn't enough. you also need to build it with the command make. Once you have built ffmpeg, just change the line of FFMPEG_PATH="ffmpeg" with the correct one, for example: FFMPEG_PATH="ffmpeg" -> FFMPEG_PATH="/home/user/ffmpeg-git/ffmpeg" have you edited the script configuration to make it work with your pc? the script NEEDS to be configured. it works poorly out of box.

rodrigograca31 commented 9 years ago

Humm.... Ok, That is not very clear on the README.md file.... I will do it, and report back...

rodrigograca31 commented 9 years ago

Ok, I've done it.

Notes:

Some screenshots of the output I'm getting:

wargio commented 9 years ago

ok, i've read their commits to see if something has changed, but not that much. First of all, you need to check the FPS value. it might sound stupid but just change it if you haven't. (You have to open the script, is one of the initial lines). Second thing: i don't know how livecoding works, but try to change the server, it might help. Anyway the fps problem can be caused also by something that kills the CPU. for example: the QUALITY that you have chosen is not good for your cpu. try to change it with ultrafast or superfast or veryfast. I saw you are using 6 threads, that might be another problem? too many encoding threads? if yes then it kills the cpu. you have to try to edit the settings, because there are not pre-defined settings that works on all the cpus. if you want to test the stream, try to use the record option.

anyway, open the ffmpeg script and search -threads $THREADS and replace it with -threads $THREADS -thread_queue_size 512

Use an editor to do that automatically, then save the script

Write here next time: https://github.com/wargio/Twitch-Streamer-Linux/issues/45