1

Essentially, what I'd like to do is to have ffmpeg continuously stream to an RTMP server using an empty pipe, then when I want to stream something, add data to the pipe.

My reasons for doing this are, I'm piping videos from an external source. Whenever the video has finished, ffmpeg crashes because it's receiving no data and I have to open it again.

Is this possible? If not, is there another way around this?

My current command is:

ffmpeg -i pipe:0 -re -c copy -f flv rtmp://mystream.com/key

pipe:0 is an instance of ytdl.

4
  • Which operating system? Does the source close the pipe when the video has finished or can it be set to continuous operation?
    – harrymc
    Apr 16, 2015 at 15:46
  • @harrymc Ubuntu 14.10. The source closes the pipe when it's finished. Apr 16, 2015 at 15:48
  • Would it be possible to use ffserver for this? Apr 19, 2015 at 16:47
  • @BlacklightShining Probably, since it can act as an RTMP server. It just made more sense to use nginx since I already use it. Apr 21, 2015 at 12:35

1 Answer 1

2

The way I got around this was using my own RTMP server to stream the video to the host.

I pipe my video to the local RTMP server using

mkfifo x
ytdl http://youtube.com/watch?v=12345 > x
ffmpeg -re -i x -c copy -f flv rtmp://mylocalRTMPserver/stream

Then create a stream from that to the host using

ffmpeg -re -i rtmp://mylocalRTMPserver/stream -c copy -f flv rtmp://mystream.com/key

If the above stream receives no input it stays open for around 30 seconds, allowing me to close the youtube pipe and open it again.

Whilst this works, there's extra overhead of having to run two instances of ffmpeg.

6
  • -re should not be used with live input streams.
    – llogan
    Apr 19, 2015 at 22:19
  • @LordNeckbeard Why not? Seemed to work fine with my streams. Apr 19, 2015 at 22:26
  • The documentation states that it could cause packet loss.
    – llogan
    Apr 20, 2015 at 6:18
  • Documentation says: "Should not be used with actual grab devices or live input streams (where it can cause packet loss)", but at least if the input is an existing HLS stream and you don't use -re Youtube will say "Bad - Video output low" (on Youtube's live control room page) and stream won't even start or will be unwatchable. Jan 30, 2018 at 2:11
  • @BenFortune couldn't it be done with cat and pipe argument of ffmpeg? I am also struggling with this and creating a rtmp server just to proxy it is not a good option for now
    – Jonathan
    Jun 3, 2020 at 21:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .