Hacker News new | past | comments | ask | show | jobs | submit login

As good as thread as any to ask: I have a lot of footage that is recorded continuously over several hours. Most of the time nothing notable happens in the video, but I have a set of timestamps of interesting events. (Think security camera with motion detection events, though this is not that.)

Currently I extract the frame at each interesting timestamp and serve them as JPEGs. I have a web-based playback UI that includes a scrubber and list of events to jump to a particular timestamp.

I would love to upgrade to a real video player that streams the underlying video, allowing the user to replay footage surrounding a timestamp. I have to be able to reliably seek to an exact frame from the event list, though.

I've been looking for something web-based, self-hostable, that doesn't require I transcode my media up front (e.g., break down into HLS chunks). I have few users accessing it at a time so I can transcode on the fly with some caching (though I think it is already H.262 or H.264). Is there anything suitable out there?




What is possible is going to depend a lot on the CPU you have and the media you have.

That said, ffmpeg is going to be the best tool (IMO) to handle this. You may also look at a tool like Vapoursynth or AviSynth if you want to do any sort of preprocessing to the images.

If the video is H.262 (or it is H.264 at a insane bitrate like 50Mbps), I'd encourage transcoding to something not as bitrate heavy. AV1 and HEVC are 2 of the best in class targets (but require a LOT of computational horsepower... OK there is also technically VVC, but nothing really supports that).

If time is of the essence, then I'd suggest looking into what sort of codecs are supported by your CPU/GPU. They won't give you great quality but they will give you very fast transcoding. You'll want to target the latest codec possible.

H.264 is pretty old at this point, H.265 (HEVC) or vp9 will do a better job at a lower bitrate if your card supports either. They are also relatively well supported. VP9 is royalty free.

If your GPU or CPU do not support any recent codec, you might look into the SVT encoders for AV1/VP9, and x264/5 for H.264 or H.265.

All this said, if the codec is fine and at a streamable bitrate, ffmpeg totally supports copying the stream from timeslices. You'll have to play around with buffering some of the stream so you can have ffmpeg do the slicing, but it's not too hard. That's the best option if the stream is streamable (transcoding will always hurt quality).

Oh, and you'll very likely want to compile ffmpeg from source. The version of ffmpeg bundled with your OS is (likely) really old and may not have the encoders you are after. It's a huge PITA, but worth it, IMO. Alternatively you can likely find a build with all the stuff you want... but you'll need a level of trust in the provider of that binary.


Just because a file is encoded as H.264 does not mean it is streamable. The encoding needs to be done in a way that makes streaming realistic.

For the rest of it, I would suggest an ffmpeg solution on a server. You can have it re-encode just the requested times while encoding to a streaming friendly format. There are JS libraries available that allow you to use HLS in the native <video> tag.


I had a similar issue and worked completely around it by using ffmpeg to generate a video file around the point of interest. Instead of serving up the JPEG as in your case, I would serve a small 10s mp4. It was something like (-5s to +5s). Trying to directly stream the file and seek was unreliable for me and I didn't want to get into setting up a full streaming server.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: