Open ortix opened 9 years ago
First you need to understand and parse the structure/layout of the video container (e.g. MKV or MP4). You can't just randomly get a chunk of the video file and hope to be able to make sense of the data. You will also need a codec to be able to render the video frames (e.g. H.264). Once you've figured this out, you can use the stream api to get the pieces you need.
I understand what you're saying and I kinda did get that far :') I was hoping I could get some of that magic to happen by maybe dissecting peerflix. When seeking in VLC using peerflix, it downloads starting from that chunk. So as soon as I figure out how to do that, I need to figure out where the first I-frame is. Once I have the I-frame, I can pipe it through to ffmpeg. So the hardest part for me right now is to figure out how to start downloading starting from a specific chunk and to figure out where the i-frame is. Perhaps there are some guru's willing to lend a little baby helping hand
So the hardest part for me right now is to figure out how to start downloading starting from a specific chunk
That's actually pretty easy - torrent-stream provides a very nice abstraction: you don't need to worry about the chunks or pieces. If you know the byte offset, you can just request a stream starting from that position. Here's an example: https://github.com/mafintosh/torrent-stream/blob/master/test/storage.js#L34
So I'm trying to write a little script which can extract frames from files which are downloaded with the torrent. However I have no clue how to get the ball rolling. So far I can initiate the download but I'm not quite sure how to download just a part. I set the start and end options to specific locations in the file (10mb and 11mb), but that doesn't work. I assume it has to do with the headers which have to come in first.
So how would I go about doing this? I want to create 10 files, each 1 mb, out of a video.