A service which will generate thumbnails from a live HLS stream.
MIT License
A service which will generate thumbnails from a live HLS stream.
Can be either used as a library, run as a service and controlled with http requests, or standalone for handling a single stream.
ffmpeg
at a command prompt.npm install -g hls-live-thumbnails
to install globally.Run hls-live-thumbnails https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
.
This will generate thumbnails from a HLS stream and emit a newThumbnail
event whenever a thumbnail is generated.
This uses ThumbnailGenerator
but will also remove thumbnails when their segments are removed from the playlist, or when the playlist no longer exists.
You can configure a time to wait before removing thumbnails after their segments are removed using the expireTime
option.
This generates a JSON manifest file with information about the generated thumbnails.
If you never want the manifest or thumbnails to be deleted use the neverDelete
option.
You can run this as a service which will expose a http API for control, or standalone.
If run standalone the program will terminate with exit code 0 once all thumbnails have been generated and the stream has ended, or 1 if there was an error.
These are the options:
expireTime
. Defaults to false
.targetThumbnailCount
.E.g. Service: hls-live-thumbnails --secret "super-secret" --targetThumbnailCount 20 --width 300
E.g. Standalone: hls-live-thumbnails https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8 --width 300
Start generating thumbnails for a stream.
The following parameters are allowed:
width
option. (Optional)height
option. (Optional)interval
option. (Optional)initialThumbnailCount
option. (Optional)targetThumbnailCount
option. (Optional)The response is {id: <id which represents this generator>}
The manifest file will be called "thumbnails-[id].json".
Get information about the provided generator. A 404 will be returned if a generator no longer exists, e.g. if all thumbnails have expired.
The response is {ended: <true if the stream has ended, no more thumbnails will be generated>}
This counts as a 'ping'. Look at the 'pingInterval' option.
Terminate the generator with id
. All of its thumbnails will be removed.
This is the structure of the manifest file. It will be called "thumbnails-[id].json".
{
"ended":<true if the stream has ended>,
"segments": [{
"sn": <segment sequence number>,
"removalTime": <The time the segment was removed from the playlist, or null>,
"thumbnails": [
{
time: <time into the segment that the thumbnail was taken (seconds)>,
name: <thumbnail filename>
},
{
time: <time into the segment that the thumbnail was taken (seconds)>,
name: <thumbnail filename>
}
]
}]
}