3 ms·
Even more instantly, if your file is not in a "fixed" container format like MP4 or AVI but one designed for streaming use like an MPEG TS or PS, you can simply
by userbinator 7y ago
Even more instantly, if your file is not in a "fixed" container format like MP4 or AVI but one designed for streaming use like an MPEG TS or PS, you can simply cut a (suitably large) range of bytes from it using any generic file manipulation tool; on POSIX-like systems, head and tail would work.
After all, it is called a stream for a reason... while there's definitely a lower limit to how small you can cut out a piece and have it still decode, as far as I know, all common audio and video codecs are designed with sync codes and "markers" so that a decoder can easily find a valid data block to start decoding from. Something like a broadcasted signal from a TV channel has no start nor end, so decoders need to be able to just jump in at any point and start decoding.
- verst 7y agoVery cool! I was in particular dealing with MP4s that also had subtitle tracks that I wanted to preserve.
- kd5bjo 7y agoThis is essentially how we broke apart long streams into manageable archive files at Justin.tv. You can get slightly better decoder behavior if you’re careful about where you make the cut: some frames are encoded as a difference from the previous frame and others are self-contained. If you cut before one of the self-contained frames, the decoder can start immediately instead of throwing away some data.
- milankragujevic 7y agoYes, indeed, I had worked on a small project of mine and needed a really efficient and cheap way to serve terabytes of data to a lot of users, fast. I was poor and young (15 years old). I re-created (I haven't invented this, obviously) a way to split the video file into keyframe segments and mark down the start byte offsets of the keyframes, and then I could "virtually" split the file for streaming, so that a user wouldn't 1) buffer the whole file, 2) need to have the whole file to share to others (P2P in the browser), 3) need to restart the stream and sharing if the connection broke. This could've obviously been done with HLS or DASH, but that required remuxing the files and keeping lots of them. I instead remuxed files into TS container, indexed all the files, made JSON manifests, and had a network of reverse proxy "CDN" servers on continents that would pull the files from a few central servers, cache the small virtual chunks, which were created by reading byte offsets from the file and serving it as a "file" with PHP. In the end, the project collapsed due to non-technical issues, and me loosing interest and doing more legitimate and useful things. I then resold the technology a few times to some people who wanted the similar thing but wouldn't have the issues I had, then I moved on and forgot it all. It's history, it's made my career in some way, at least from my side, it was innovative for it's time, and made me nerdy-cool in school, both with other kids and the school staff. - If someone wants to know a bit more, read this: https://www.theverge.com/2015/10/21/9585984/browser-popcorn-returns-new-developer https://www.theverge.com/2015/10/21/9585984/browser-popcorn-... (It's cringe, I was young and stupid, LOL)
- pault 7y agoAre you the author of popcorn time, or did you just operate a popcorn time web service?
- milankragujevic 7y agoJust the web service. Thankfully 5 years ago, so the statute of limitations in Serbia expired.