Although it was a little ropey, older revisions could take a linear input (such as a named pipe) and use that in order to continuously output a live stream.
HLS-5 changed the way that the m3u8 is generated and so we now need to be more explicit about whether or not the stream is live (as it will affect the m3u8 options).
Need to add a simple command line flag to specify that it's linear video and act accordingly
Activity
2015-06-11 12:11:46
2015-06-11 13:57:15
Webhook User-Agent
View Commit
2015-06-11 14:05:19
The -c option is optional and defaults to 0 (infinite). Tested with various values, and ffmpeg correctly increments the EXT-X-MEDIA-SEQUENCE when sliding the playlist window.
Currently, you cannot tell the script to use an RTMP or RTSP stream (directly) as an input as the script checks for whether or not the input file exists. It's possible to do it by using a named pipe, but that's hacky and unpleasant.
So need to adjust the inputfile check so that it's more forgiving if the input type is a stream/remote resource.
I guess the best way to do that is probably to test whether the inputfilename is a path starting with some kind of scheme (i.e. rtmp://foo/bar or http://example.invalid/bar_)
Given that ffmpeg supports a fair few protocols - https://www.ffmpeg.org/ffmpeg-protocols.html - it's probably best to do a simple regex to see if :/ exists in the input filename.
Might need to make a special case for things like cache:URL (tell ffmpeg to cache the URL to a local file and then use it) as it excludes the slash. Similarly file: should be treated as if the user had just specified a path.
Alternatively, as ffmpeg will complain if the file doesn't exist anyway, it might be as simple to just remove the check for the input file (though we may then end up creating an output directory and erroring out just after).
2015-06-12 16:24:16
2015-06-12 16:28:52
2015-06-12 16:39:12
2015-06-14 12:28:01
- RTMP stream
- Reading from named pipe
- Single bitrate HLS (outputting to adaptive)
For the HLS input, can test a few methods - reading from local file system, from remote URL and via a pipe.
2015-06-14 14:37:15
Webhook User-Agent
View Commit
2015-06-15 14:51:21
The file being used is taken from JWPlayer's demo page - technically it's VoD but is at least long enough to run basic tests, will look at setting up a truly live stream later.
Simple RTMP
Watching as it encodes
- Audio is in sync
- video plays without stutter
Single to Multiple Bitrates
vlc appears to get stuck just after the video intro when using the master playlist - lower bitrates play fine, where the 512k stream falls off at the same point, so think it's actually just that the highest bitrate isn't currently keeping up. vlc is obviously parsing the manifest OK as it's playing back video, so think it's just falling off the end of the manifest (more a limitation of the hardware I'm testing on) - it's not switching down a bitrate because it's not experiencing delivery issues, just an EOF
Will drop the higher bitrate from the next set of tests to simplify testing, but worth coming back to
Sliding window, 50 seconds of video per manifest
The two bitrates remain relatively in sync in terms of segment count, though the lower may be a few seconds ahead. The video looks terrible at 36K mind :)
So, all seems to work within the constraints of my test hardware.
General
Because the variant playlist is generated before the encode is started on the bitrates, a player arriving early may try to load the video before it's ready (for it's part ffmpeg doesn't generate the manifest until one segment has been encoded), so it may be worth looking at moving the variant playlist generation.
Using a non-local resource obviously works, though the streams may currently go out of sync. That's not an issue for VoD (as the encoding will likely be done before the media is available for delivery) but is a potential headache for live streams - you don't want there to be too big a difference when using a sliding Window.
If the 36k stream in test 3 where to get 50 seconds ahead (unlikely, but possible) a player switching down a bitrate might find it's current position simply isn't available in the manifest.
2015-06-15 15:32:42
Although technically it can be handled as a linear stream, there are a few complications (if you're wanting to publish an adaptive stream for example) so will raise a separate issue for that - HLS-13.
For a single bitrate output (i.e. a single ffmpeg output) the principle works OK though
The caveat being that ffmpeg needs to know the input stream type, so the FIFO needs to carry a suitable filename extension.
To get multiple output bitrates supported, we'll need some kind of wrapper which can read from the FIFO and make available for multiple processes to read.
2015-06-15 15:45:31
2015-06-15 15:46:31
2015-06-15 15:46:31
2015-06-15 15:46:31
2015-06-15 15:46:35