Discussion:
[FFmpeg-user] Switching live streams without interruption?
Felix E. Klee
2014-10-25 19:35:57 UTC
Permalink
I'm streaming to Wowza:

$ ffmpeg -re -i sintel_trailer-480p.mp4 -c copy -f flv \
rtmp://192.168.56.1/live/myStream

*How do I switch to another stream once playback has finished?*

Note that when playback of the first stream starts, it is not clear
what will be the next stream. So something like a playlist won't work.
DopeLabs
2014-10-25 19:48:14 UTC
Permalink
you might want to check out the stream class controller

http://www.wowza.com/forums/content.php?187

there is also

http://www.wowza.com/forums/content.php?145-How-to-schedule-streaming-with-Wowza-Streaming-Engine-(StreamPublisher)

and

http://www.wowza.com/forums/content.php?468-How-to-loop-a-pre-roll-until-a-live-stream-starts
Post by Felix E. Klee
$ ffmpeg -re -i sintel_trailer-480p.mp4 -c copy -f flv \
rtmp://192.168.56.1/live/myStream
*How do I switch to another stream once playback has finished?*
Note that when playback of the first stream starts, it is not clear
what will be the next stream. So something like a playlist won't work.
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Felix E. Klee
2014-10-25 19:53:50 UTC
Permalink
http://www.wowza.com/...
Thanks for the links, but: *Can't I do that from ffmpeg?*

Thing is, I want to script switching of streams, and I want to have
the option to later use another server for broadcasting.
Luke Davis
2014-10-25 20:41:41 UTC
Permalink
Post by Felix E. Klee
Thanks for the links, but: *Can't I do that from ffmpeg?*
Thing is, I want to script switching of streams, and I want to have
the option to later use another server for broadcasting.
Unless I am mistaken (I have only done this with audio, icecast, etc.), your
problem is that any break in the stream will disconnect clients, or at least
inconvenience them rather a bit.

Thus, the solution has to be server side, in which case you need a
fallback stream to fill the gaps. Even if only used briefly, if your server
supports it, you fall back to a holding pattern stream (company logo looped or
something), and then stream in your new content from the script. Even that will
make discontinuities, and I have no idea if Wowza or anything else supports it.
Unless your server supports holding client connections open during a disconnect-reconnect cycle of the source client, which is what will happen here.

One possible ffmpeg-only solution comes to mind. This is a bit out there.

Feed your ffmpeg source client from a segmented MpegTS stream. In other words,
feed it from HLS generated locally.

Ffmpeg instance one generates a segmented stream for five minutes, then exits.

Meanwhile, ffmpeg two (source client) takes that stream and sends it to
Wowza/whatever server.

When ffmpeg one stops, with maybe eight seconds left in the last segment
(assuming ffmpeg two is keeping up, and 10 second segments):
Ffmpeg three starts, generating segments with numbering starting where ffmpeg
one left off (you'll likely need to `tail` the .m3u8 file to figure out where to
start).

I believe that ffmpeg two, which is taking the segments and compiling them to
send as a stream to the server, will not know the difference between one origin
stream and another, since their all just segments as far as it's concerned.

Not having tried this, my only worry at the moment is catch-up. Every time
you do this, the source client (ffmpeg two in the above plan) will get a little
closer to falling off the end of your segments.

Good luck.

The entirety of this email is speculative, and could be punctured with a dull pin.

Luke
Felix E. Klee
2014-10-25 20:54:14 UTC
Permalink
Thanks Luke! Hm, I thought it was standard feature. But being not, I
guess I'll first look at Wowza which seems to be scriptable with
ActionScript. Fortunately, I've used ActionScript before: Many years
ago, I wrote a streaming video player, based on AMS.

Anyhow, there must be a smooth solution. l just can't believe that
it's not possible to run something akin to a TV station on the
Internet.
Luke Davis
2014-10-25 21:36:49 UTC
Permalink
Post by Felix E. Klee
Thanks Luke! Hm, I thought it was standard feature. But being not, I
Of ffmpeg? The ability to add to the list of sources after the process has
started? I highly doubt it.
I have never seen a feature like that in ffmpeg described. Maybe you need the
ability to read a list of sources from STDIN on an as-needed basis?

But don't take my word for it Felix, I could still be quite wrong.

The requirement for continuous video is how I *think* it works, and that weird
segmenting idea is the only way I can think of using only ffmpeg to do it.

I would imagine that if there is another way to have ffmpeg stream from a file,
and add to that file dynamically, you could accomplish the same thing, but I
still think you would need a headerless format (I.E. MPEGTS) to make it work.

I am no authority on this, I just wanted to present a possible answer that
nobody else mentioned.
Post by Felix E. Klee
guess I'll first look at Wowza which seems to be scriptable with
ActionScript. Fortunately, I've used ActionScript before: Many years
ago, I wrote a streaming video player, based on AMS.
If I recall, Wowza has a JAVA API as well, if you want to get really serious
about it. But your problem hasn't changed, you just moved it from the source to
the server. It may be that Wowza already has a connection keeping feature for
this. Present it on their list and see what you get.
Post by Felix E. Klee
Anyhow, there must be a smooth solution. l just can't believe that
it's not possible to run something akin to a TV station on the
Internet.
I'm sure you can, as long as you can avoid interrupting the stream. Which was
my whole point. You would seem to need a constant stream, with ability to
switch sources in and out of it on the fly. But there always has to be
something streaming, even in the short gap between sources. Someone correct me
if I'm wrong please.

Luke
DopeLabs
2014-10-25 23:26:52 UTC
Permalink
i have the publisher/controller/loop until live all setup/automated with ffmpeg providing 4 live streams which rotate

this allows me to have a ‘main stream’ in which the wowza server rotates content on a time based schedule. the cut between streams is very subtle.

the 2 modules im using are stream publisher and loop until live


in wowza/conf/live/Application.xml

<Module>
<Name>ModuleStreamPublisher</Name>
<Description>ModuleStreamPublisher</Description>
<Class>com.wowza.wms.plugin.collection.module.ModuleStreamPublisher</Class>
</Module>
<Module>
<Name>ModuleLoopUntilLive</Name>
<Description>ModuleLoopUntilLive</Description>
<Class>com.wowza.wms.plugin.collection.module.ModuleLoopUntilLive</Class>
</Module>



<Property>
<Name>streamPublisherSmilFile</Name>
<Value>streamschedule.smil</Value>
</Property>
<!-- This property is the name of the dj stream or streams that will be published to your application. -->
<Property>
<Name>loopUntilLiveStream</Name>
<Value>djstream</Value>
</Property>
<!-- This property is the name of the server-side stream or streams that the live stream(s) will be inserted into. -->
<Property>
<Name>loopUntilLiveOutStream</Name>
<Value>dubstepfm</Value>
</Property>
<!-- Reload the entire stream playlist when switching back to the filler video. -->
<Property>
<Name>loopUntilLiveReloadEntirePlaylist</Name>
<Value>true</Value>
</Property>
<!-- Handle MediaCasters properly by only switching the stream when the MediaCaster is ready. -->
<Property>
<Name>loopUntilLiveHandleMediaCasters</Name>
<Value>true</Value>
</Property>


in wowza/content/streamschedule.smil

<smil>
<head>
</head>
<body>
<stream name=“dubstepfm"></stream>
<playlist name=“audioviz" playOnStream=“dubstepfm" repeat="true" scheduled="2014-01-01 12:59:59">
<video src="spectrum1.stream" start="-2" length="86400"/>
<video src="spectrum2.stream" start="-2" length="86400"/>
<video src="wavesline.stream" start="-2" length="86400"/>
<video src="wavespoint.stream" start="-2" length="86400"/>
</playlist>
</body>
</smil>


in wowza/content/wavespoint.stream
udp://127.0.0.1:10040

in wowza/content/wavesline.stream
udp://127.0.0.1:10030

in wowza/content/spectrum2.stream
udp://127.0.0.1:10020

in wowza/content/spectrum1.stream
udp://127.0.0.1:10010


and finally the ffmpeg instances that create the audio viz


ffmpeg -i http://stream.dubstep.fm:5000 -filter_complex showwaves=s=1280x720:mode=point,drawtext=fontfile=d3.ttf:fontsize=28:fontcolor=white:textfile=dsfm.tv.txt:y=10:x=10 -c:v libx264 -b:v 3000k -pix_fmt yuv420p -c:a copy -preset ultrafast -bsf h264_mp4toannexb -f mpegts udp://127.0.0.1:10040?pkt_size=1316

ffmpeg -i http://stream.dubstep.fm:5000 -filter_complex showwaves=s=1280x720:mode=line,drawtext=fontfile=/d3.ttf:fontsize=28:fontcolor=white:textfile=dsfm.tv.txt:y=10:x=10 -c:v libx264 -preset ultrafast -b:v 3000k -pix_fmt yuv420p -c:a copy -bsf h264_mp4toannexb -f mpegts udp://127.0.0.1:10030?pkt_size=1316

ffmpeg -i http://stream.dubstep.fm:5000 -filter_complex showspectrum=mode=separate:s=1280x720,drawtext=fontfile=d3.ttf:fontsize=28:fontcolor=white:textfile=dsfm.tv.txt:y=10:x=10 -c:v libx264 -b:v 3000k -pix_fmt yuv420p -c:a copy -preset ultrafast -bsf h264_mp4toannexb -f mpegts udp://127.0.0.1:10020?pkt_size=1316

ffmpeg -i http://stream.dubstep.fm:5000 -filter_complex showspectrum=s=1280x720,drawtext=fontfile=d3.ttf:fontsize=28:fontcolor=white:textfile=dsfm.tv.txt:y=10:x=10 -c:v libx264 -preset ultrafast -b:v 3000k -pix_fmt yuv420p -c:a copy -bsf h264_mp4toannexb -f mpegts udp://127.0.0.1:10010?pkt_size=1316


to sum it all up im generating 2 spectrograms and 2 waveforms using the audio from a shoutcast server. each one plays for 24 hours before switching to the next one in the list. if a stream is published with the name djstream, it will immediately switch to that content… once djstream is finished it goes back to the schedule again, rotating once every 24 hours to the next stream… the single

i believe the app type has to be ‘live’ for most of this stuff to work, and i dont think you can switch to a stream published to a different app.


results -> http://dsfm.tv

ok enough wowza on the ffmpeg list.. let me know if you have any q’s, etc

cheers!
Post by Felix E. Klee
Thanks Luke! Hm, I thought it was standard feature. But being not, I
guess I'll first look at Wowza which seems to be scriptable with
ActionScript. Fortunately, I've used ActionScript before: Many years
ago, I wrote a streaming video player, based on AMS.
Anyhow, there must be a smooth solution. l just can't believe that
it's not possible to run something akin to a TV station on the
Internet.
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Felix E. Klee
2014-10-26 01:41:14 UTC
Permalink
I’ve been thinking: For gapless playback, it’s probably best to have two
video streams running, and then switch between these with some kind of
mixer. As I’ve just found out, software implementations of mixers for
video are called [Software vision mixers][1].

[1]: http://en.wikipedia.org/wiki/Software_vision_mixer
Felix E. Klee
2014-10-26 16:42:11 UTC
Permalink
In the meantime I discovered [FreeJ][1], which should be able to do
what I want. However, it's limited to Ogg Theora, so would require
live reencoding before sending the stream to the broadcasting
software.

Also, I asked on one of the GStreamer mailing lists if that tool could
be a solution. There actually is a videomixer plugin for GStreamer.

[1]: http://freej.org/

Loading...