Re: Playing Video. mjpeg decoder in pure lua. With audio!
Posted: Thu Aug 09, 2012 6:39 am
Wow! Thanks a lot! This is what this code needed so musch!NÖÖB wrote:Then the memory usage gets much lower -- 25mb
You can easily add this features.Roland_Yonaba wrote:But, what if we need some full video playing features ? go forth, go back , stop, resume, etc...
For example, this is all you need for play/pause with space bar:
Code: Select all
function love.keypressed(key)
if key == " " then
if sound:isPaused() then
sound:resume()
else
sound:pause()
end
end
end
This is because video depends on position in played audio.
Rewind and fast forward a little bit tricky. When changing position of audio with sound:seec(25, "seconds") you also should update all player values: img1, img2, first_image, cur_frame, next_load, curent_quad. But again, all this values depends on adio position and your video configuration (frames per image, frame rate)
Idea was simple:Roland_Yonaba wrote:@flashkot : For what reason did you used love.thread, by the way ?
Loading image with frames for one second of video takes (just for example) 0.5 seconds. so this can't be done in one loop, you video will be laggy:
0.5s loading, 1s video, 0.5s loading, 1s video, 0.5s loading, 1s video...
With loader thread it runs like this:
Code: Select all
Player thread: | 1s video | 1s video | 1s video | 1s video | 1s video |
Loader thread: | 0.5s loading | 0.5s loading | 0.5s loading | 0.5s loading | 0.5s loading |
It's already works as you described. Frames are loaded in background. Code keeps only what it plays right now. Right, it's some sort of streaming.Roland_Yonaba wrote:Plus, did you envision some sort of streaming ? I mean, load some frames, display them, and progressively load the next frames in background while playing the video. It may reduce the reduce the memory usage, but i don't know if that would be faster. That's jus some random ideas I am throwing on the table, so that we can all learn from that.
You're welcome!Roland_Yonaba wrote:Thanks for the amazing work, though.