Stream to youtube linux

olasd / stream_to_youtube.sh

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n’est pas scalée.
VBR= » 2500k » # Bitrate de la vidéo en sortie
FPS= » 30 » # FPS de la vidéo en sortie
QUAL= » medium » # Preset de qualité FFMPEG
YOUTUBE_URL= » rtmp://a.rtmp.youtube.com/live2 » # URL de base RTMP youtube
SOURCE= » udp://239.255.139.0:1234 » # Source UDP (voir les annonces SAP)
KEY= » . » # Clé à récupérer sur l’event youtube
ffmpeg \
-i » $SOURCE » -deinterlace \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(( $FPS * 2 )) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
-f flv » $YOUTUBE_URL / $KEY «

Hey everyone ( @dedaloodak , @shikagemew ) ! For those who want to make a youtube radio, I made a little script which plays all .mp4 files in a folder.
For a radio, you could heavily imporve it by randomizing the order of the files in the for loop (I don’t know if it’s feasible), or by having a continuous stream with a fifo or something (I don’t master it really well). By the way, here is where I found the trick : https://trac.ffmpeg.org/wiki/Concatenate#filter

#! /bin/bash # # Diffusion youtube avec ffmpeg # Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée. VBR="2500k" # Bitrate de la vidéo en sortie FPS="30" # FPS de la vidéo en sortie QUAL="medium" # Preset de qualité FFMPEG YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube FOLDER="videos" # Dossier source KEY="PUT YOUR KEY THERE" # Clé à récupérer sur l'event youtube SOURCE="" n=0 filter="" for f in $FOLDER/*.mp4 do SOURCE="$SOURCE -i $f" filter="$filter [$n:v:0] [$n:a:0]" ((n++)) done filter="$filter concat=n=$n:v=1:a=1 [v] [a]" echo "ffmpeg $SOURCE -filter_complex '$filter'" ffmpeg \ $SOURCE -filter_complex "$filter" \ -map "[v]" -map "[a]" -deinterlace \ -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \ -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \ -f flv "$YOUTUBE_URL/$KEY" 

Let me know if you do any improvement, I’ll be glad to use them

@p4ulolol how to keep script repeatedly? for example 1 folder there are 10 videos. then 10 videos are playing and will be played back until I stopped ffmpeg process by myself. How ?

@dokomade9921 well I don’t really know. You can either add an infinite while loop arround the ffmpeg command, but I think you won’t be ablento stop it until you stop the script using a command from another terminal. Else you can add a while loop or for loop around these lines :

with a lot of iterations, that should generate a very long playlist, probably longer than you need. But in this case I don’t know what is the character limit of a variable or of a command if there is one.

That’s also why I hope people will improve it 🙂
By the way people, you can fork it right here (and also comment for help, if you don’t want to flood this gist) :
https://gist.github.com/p4ulolol/e4192f58e738446f3491d839eaa50ed7

Читайте также:  What is tty terminal in linux

@p4ulolol I also can not overcome this. because I do not understand the script so I am confused. so can you load this script to run on linux?

: Batch Render Youtube Video Reup
: Settings for x264 video and mp3 Audio

@echo OFF
Setlocal EnableDelayedExpansion

: path to ffmpeg
set ffmpeg=C:\FMPEG\bin\ffmpeg.exe

: path to ffmpeg
set INPUT=C:\input
set OUTPUT=C:\output

: encode video
for %%i in (*.mp4) DO «%ffmpeg%» -re -i «%%i» -vcodec libx264 -preset veryfast -maxrate 2500k -bufsize 3368k -vf «format=yuv420p» -g 60 -acodec libmp3lame -b:a 198k -ar 44100 -metadata title=»» -metadata artist=»» -metadata album_artist=»» -metadata album=»» -metadata date=»» -metadata track=»» -metadata genre=»» -metadata publisher=»» -metadata encoded_by=»» -metadata copyright=»» -metadata composer=»» -metadata performer=»» -metadata TIT1=»» -metadata TIT3=»» -metadata disc=»» -metadata TKEY=»» -metadata TBPM=»» -metadata language=»eng» -metadata encoder=»» -f flv -s 1280×720 «rtmp://a.rtmp.youtube.com/live2/3xd5-9yeg-mw0z-29k7»

please help me so i can make sh file for linux. because i am a linux user not windows.

@dokomade9921 Well your script does almost the same thing as mine, just in different way. All you have to do is to set FOLDER to «.» . In any case, your script won’t keep the live stream alive forever, it will only loop once through all the files and play them (I even wonder if it doesn’t stop the stream and restart it between each file, which is not great)

Mine keeps saying the stream is starting but never does. when i look at the «health» of the YouTube stream it says its not receiving data. at the start of the stream the «health» of it is green the a short time later is gray. Any idea on how to fix this?

what is the source for the screen to be casted or is it default

What about if i want to use my shoutcast radio stream, rather than a video source or file source? Is this possible?

Hi, my source url is another rtmp server, how to send stream to youtube from another rtmp server, please help.

ffmpeg -i rtmp:///live/ -f flv rtmp://a.rtmp.youtube.com/live2/key is not working

«Mine keeps saying the stream is starting but never does. when i look at the «health» of the YouTube stream it says its not receiving data. at the start of the stream the «health» of it is green the a short time later is gray. Any idea on how to fix this?»
@Rietveldd

Same problem here. Can someone help?

@2LuckyLuke I had the same problem and I realized that, in my case, youtube didn’t like non-audio streams. If you are using a non-audio source (screen capturing, or testsrc) add a null audio source. These are my ffmpeg arguments (I’m on windows):

ffmpeg ^ -re -f lavfi -i testsrc=size=768x432:rate=30 -deinterlace ^ -f lavfi -i anullsrc ^ -vcodec libx264 -pix_fmt yuv420p -preset veryfast -r 30 -g 60 -b:v "1000k" ^ -acodec libmp3lame -ar 44100 -b:a 128k ^ -f flv "rtmp://a.rtmp.youtube.com/live2/key" 

Why is the speed of the stream so high?
The speed is always 3-5 times faster than normal, how can I fix this?

Читайте также:  Linux nfs server настройка

I wonder if there is away to hide YouTube key from the command line. Running ffmpeg like this can make your key visible to other system users, they can do ps -Af and see your key (if they have enough privileges on the system) in the process list.
A possible solution could be reading the target YouTube url from a file, is it possible?

hi i need to know how to stream or go live to youtube with a downloaded or recorded video 24*7 but without turning the computer on for 24 hours (i.e offline)

@joseph488 This thread already has all you need. If you don’t want to run the stream from your computer 24/7, get a VPS and run the script from there.

Stream no sound. How can I fix this problem? @olasd

i have try the code of @Cyxo but i have a error a anybody to help me ?

Please use -q:a or -q:v, -qscale is ambiguous
Stream mapping:
Stream #0:0 (h264) -> concat:in0:v0
Stream #0:1 (aac) -> concat:in0:a0
Stream #1:0 (h264) -> concat:in1:v0
Stream #1:1 (aac) -> concat:in1:a0
concat:out:v0 -> Stream #0:0 (libx264)
concat:out:a0 -> Stream #0:1 (libmp3lame)
Press [q] to stop, [?] for help
[Parsed_concat_0 @ 0x55652e0b4ca0] Input link in1:v0 parameters (size 1920×1080, SAR 1:1) do not match the corresponding output link in0:v0 parameters (640×480, SAR 1:1)
[Parsed_concat_0 @ 0x55652e0b4ca0] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!

Hey everyone ( @dedaloodak , @shikagemew ) ! For those who want to make a youtube radio, I made a little script which plays all .mp4 files in a folder.
For a radio, you could heavily imporve it by randomizing the order of the files in the for loop (I don’t know if it’s feasible), or by having a continuous stream with a fifo or something (I don’t master it really well). By the way, here is where I found the trick : https://trac.ffmpeg.org/wiki/Concatenate#filter

Here is the script :

#! /bin/bash # # Diffusion youtube avec ffmpeg # Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée. VBR="2500k" # Bitrate de la vidéo en sortie FPS="30" # FPS de la vidéo en sortie QUAL="medium" # Preset de qualité FFMPEG YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube FOLDER="videos" # Dossier source KEY="PUT YOUR KEY THERE" # Clé à récupérer sur l'event youtube SOURCE="" n=0 filter="" for f in $FOLDER/*.mp4 do SOURCE="$SOURCE -i $f" filter="$filter [$n:v:0] [$n:a:0]" ((n++)) done filter="$filter concat=n=$n:v=1:a=1 [v] [a]" echo "ffmpeg $SOURCE -filter_complex '$filter'" ffmpeg \ $SOURCE -filter_complex "$filter" \ -map "[v]" -map "[a]" -deinterlace \ -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \ -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \ -f flv "$YOUTUBE_URL/$KEY" 

Let me know if you do any improvement, I’ll be glad to use them

i am getting this error
[concat @ 0x5573f4b41040] Value 0.000000 for parameter ‘n’ out of range [1 — 2.14748e+09] Last message repeated 1 times [concat @ 0x5573f4b41040] Error setting option n to value 0. [Parsed_concat_0 @ 0x5573f4b2f240] Error applying options to the filter. [AVFilterGraph @ 0x5573f4b24de0] Error initializing filter ‘concat’ with args ‘n=0:v=1:a=1’ Error initializing complex filters. Numerical result out of range

Читайте также:  Kali linux update version

Источник

laurenarcher / livestreamingyoutube

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

Terminal Commands:
One webcam:
ffmpeg -f alsa -ac 2 -i hw:1,0 -f v4l2 -s 1280×720 -r 10 -i /dev/video1 -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -r 25 -g 20 -b:v 2500k -codec:a libmp3lame -ar 44100 -threads 6 -b:a 11025 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/YOURSTREAMNAMEHERE
Two webcam overlay:
ffmpeg -f alsa -ac 2 -i hw:1,0 -f v4l2 -s 1280×720 -r 10 -i /dev/video1 -f v4l2 -s 320×240 -r 10 -i /dev/video0 -filter_complex «[1:v]setpts=PTS-STARTPTS[bg]; [2:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=shortest=1 [out]» -map «[out]» -map 0:a -vcodec libx264 -pix_fmt yuv420p -preset veryfast -r 25 -g 20 -b:v 2500k -codec:a libmp3lame -ar 44100 -threads 6 -b:a 11025 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/YOURSTREAMNAMEHERE
Works as of Nov. 21 2014, with 14.04. As seen here: www.oldhomehandy.com
If you don’t have FFMPEG installed use Jon Severinsson’s FFmpeg PPA:
sudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

Источник

How to Live Streaming on YouTube?

I’m looking for a way to stream to YouTube Live on my computer. I know there are various tools available for Windows, but I haven’t found anything for Linux. I prefer not to use G+ Hangouts, but go right to actual streaming. Does anybody know of any tools for Linux that will stream to YouTube Live, or is there a Windows tool that works without any issues under WINE?

3 Answers 3

This is not gonna be easy, but we can do it. We will stream to Twitch.tv, which can stream to YouTube Live.

Preparing the libraries: Type these commands in Terminal.

sudo apt-get install ffmpeg sudo apt-get install libx264-dev libavcodec-extra-53 

The code required to stream: Open gedit/Text Editor and paste this code: http://shrib.com/ubuntu2twitch

Save the text file as twitch_stream.sh in your /home/ directory.

Obtaining a Twitch Streaming Key: Go to http://www.twitch.tv/broadcast/dashboard/streamkey and get your Streaming key. Open gedit/Text Editor and paste the key into it. Name this file as .twitch_key and save it in your /home/ directory, same as the twitch_stream.sh file.

Going live: Open Terminal and type this:

cd cd /home/ chmod 755 twitch_stream.sh 

If there are no errors, you’ll see your screen on the Twitch Dashboard.

Streaming from Twitch to YouTube: Visit http://www.twitch.tv/settings/connections to setup your YouTube account and got to your live feed to share on YouTube. If Twitch does not allow live streaming to YouTube, why not add a screen to your YouTube feed to ask users to go to Twitch?

Please upvote if you think this helped you.

A big thank you to The Game Engine for the code.

Источник

Оцените статью
Adblock
detector