M
M
MMMYIWW2017-02-14 13:45:38
YouTube
MMMYIWW, 2017-02-14 13:45:38

ffmpeg stream from looped video and audio to youtube(rtmp)?

Hello! How to start a stream on youtube, while having a video file lasting 3 seconds and mp3 audio? I know how to stream just over a video file with sound, and from a webcam, but I'm powerless here. At random, I realized that in order for the stream to go without stopping, the video or picture must be looped. I am aware of stream_loop -1, however, the error "Operation not allowed" comes out, after that I made ts from my mp4 and tried to start the stream (also with stream_loop), this error did not exist and ffmpeg started the stream, only here youtube it did not pick up - "broadcast is started".
In general, there is an mp4 file and mp3, you need to endlessly loop the video and start mp3, then send it to rtmp:youtube.
Help me please
I figured it out halfway - the stream passes, you can see the picture and hear the audio, but not for long - about a second, then the download on the player just spins and that's it.
Simplified as much as possible:
ffmpeg -stream_loop -1 -i video.gif -i audio.mp3 -c:v libx264 -f flv rtmp://a.rtmp.youtube.com/live2/key

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2017-02-14
@MMMYIWW

stackoverflow.com/questions/16174755/ffmpeg-live-s...

T
Timtaran, 2021-05-27
@Timtaran

stream.sh (stream in 1080p):

value=`cat mylist.txt`
ffmpeg -stream_loop -1 -thread_queue_size 1500 -i stream.mp4 -stream_loop -1 -i "$value" -shortest -map 0:v:0 -map 1:a:0? -acodec aac -pix_fmt yuv420p -vcodec libx264 -b:v 500k -crf 35 -intra-refresh 1 -g 1 -filter:v "scale=-1:1080" -r 5 -preset ultrafast -tune zerolatency -err_detect ignore_err -truncate 0 -f flv "rtmp"

The file mylist.txt contains a link to the stream obtained by the following code (Python):
from youtube_dl import YoutubeDL
from os import system 
while True: 
  with YoutubeDL({}) as ydl: 
    file = open('url.txt', 'r')
    url=file.read()
    file.close()
    song_info = ydl.extract_info(url, download=False)
    su=song_info["formats"][0]["url"]
    file = open('mylist.txt', 'w')
    file.write(su)
    file.close()
    system('sh stream.sh')

url.txt contains a link to the stream

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question