Search code examples
amazon-web-servicesffmpeghttp-live-streamingm3u8

Getting a screenshot from a protected m3u8 live stream using FFmpeg


I am trying to get a screenshot from a local pay-toll in order to use image recognition to find out how congested it is. I am trying to use ffmpeg to extract a screenshot every time a command is run from AWS Lambda. My issue is that I cannot extract any sort of image from the m3u8 file.

http://roads.mk/315/video-kameri

When I open one of the cameras, the live stream appears as normal, but when I right-click to copy the address, i get a blob link

blob:http://roads.mk/cb301be0-3e70-4d09-af2b-3f3d44ee8f4f

Luckily, on the mobile version of the site, it immediately downloads the m3u8 file once the link is clicked. Once put into ffmpeg with command

ffmpeg -i "gradsko_1.m3u8" -vf fps=1/3600 grad%04d.jpg

I get the response


[hls @ 000000ce3d26d700] Skip ('#EXT-X-VERSION:3')
[hls @ 000000ce3d26d700] Opening 'gradsko_1-586008.ts' for reading
[hls @ 000000ce3d26d700] Failed to open segment 586008 of playlist 0
[hls @ 000000ce3d26d700] Opening 'gradsko_1-586009.ts' for reading
[hls @ 000000ce3d26d700] Failed to open segment 586009 of playlist 0
[hls @ 000000ce3d26d700] Opening 'gradsko_1-586010.ts' for reading
[hls @ 000000ce3d26d700] Failed to open segment 586010 of playlist 0
[hls @ 000000ce3d26d700] Skip ('#EXT-X-VERSION:3')
    Last message repeated 3 times
[hls @ 000000ce3d26d700] Error when loading first segment 'gradsko_1-585991.ts'
gradsko_1.m3u8: Immediate exit requested
Exiting normally, received signal 2.```

From what I could tell, the stream seems to be protected. 
Any way to get inside this? I would only need a single screenshot with no audio since the program would run once an hour/on command for a very general estimate. I'm just starting out with ffmpeg so any tips would be greatly appreciated.

Solution

  • This works for me: ffmpeg -i http://streaming1.neotel.net.mk:8080/hls/romanovce_3.m3u8 -vframes 1 -q:v 2 output.jpg

    FYI: If you first download the playlist (m3u8) to a local drive and then try to use it - you will run into two problems.

    1. The URLs in the playlist are now invalid since they were relative to the server.
    2. The playlist is out dated relative quickly since this is live and the server keeps only a few segments around.