Page 1 of 1

video:play() issues [SOLVED] (sorta)

Posted: Mon Aug 30, 2021 12:11 am
by 4aiman
Hey there!

I'm using love2d v 11.4 (built on windows using megasource) and have some weird issue with play() method of a video.
The code is so simple, IDK whether I'm dumb or blind:

Code: Select all

   if not video:isPlaying() then
      video:seek(0)
      video:play()
   end   
The thing is, video gets stuck in zero time position and never plays.
isPlaying reports things just fine, seek(0) works as well, but the video doesn't start to play.

Now, if you're wondering, I'm trying to loop a short video.
The one in the demo is less than 2 seconds in length, so it's doubtful it somehow hogs the memory or is too big to be manipulated quickly.

I've attached a demo project to illustrate the issue.

Does anyone have any ideas?


Edit
I tried different ways to encode the OGV file and it's gotten even weirder.
FFmpeg 4.2 produces a bigger file and corrupts it with artifacts (colored squares all over the video).
FFmpeg 4.4 produces smaller file and the video is just fine.
But the "corrupted" file *does* loop, whereas the "clean" one doesn't.

The command I've used to encode the video looks like this:

Code: Select all

./ffmpeg -i bgv1.mp4 -c:v libtheora -q:v 10 -c:a libvorbis -q:a 5 bgv1.ogv
It definitely has something to do with the way I encode stuff, but I fail to understand what's going wrong.

According to ffprobe, the only difference is "Lavc58.54.100 libvorbis" in 4.2 VS "Lavc58.134.100 libvorbis" in 4.4 (well, and the bitrate)

Re: video:play() issues

Posted: Mon Aug 30, 2021 8:45 am
by monolifed
I don't know what is wrong.
But the following seems to work as a work around.

Code: Select all

local video = love.graphics.newVideo("bgv1.ogv", {audio="true"})
video:seek(0.1) -- added

Re: video:play() issues

Posted: Mon Aug 30, 2021 8:58 am
by 4aiman
Yeah, I tried that.
It works sometimes - just like the original code :(
Will try to make a longer clip, maybe that'll fix the issue.

BTW, I can't do this either

Code: Select all

   if not video:isPlaying() then
      video:release()
      video = love.graphics.newVideo("bgv1.ogv", {audio="true"})
      video:play()
   end   
Despite the release call, memory usage crawls into gigabytes.
It's almost like the video object manipulation is done in a separate thread and it just can't keep up with the rest of the logic :(

Edit
Made a video twice as long (just concatenated the og one 2 times). Now it works.
If anyone has a perfect recipe for making OGV files that love2d will 100% of time play and loop, please, do tell.

Re: video:play() issues

Posted: Mon Aug 30, 2021 9:12 am
by monolifed
It worked with seek(0.1) and bgv1_4.4.ogv everytime I tried.

I also re-encoded your bgv1_4.4.ogv with ffmpeg 4.3.2-0, it seems to work.

Code: Select all

ffmpeg -i bgv1_4.4.ogv -c:v libtheora -q:v 10 -c:a libvorbis -q:a 5 bgv1.ogv

Re: video:play() issues

Posted: Mon Aug 30, 2021 9:19 am
by 4aiman
Wait, is is all about ffmpeg version now?
Thanks for the info!
/me went to search for a reliable encoder

Edit
/me found the -r X FFmpeg option. Enforces X fps on the initial file, resulting in no artifacts and working loops :awesome: