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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

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

Post 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)
Attachments
test.love
(406.87 KiB) Downloaded 107 times
Last edited by 4aiman on Mon Aug 30, 2021 9:27 am, edited 2 times in total.
monolifed
Party member
Posts: 188
Joined: Sat Feb 06, 2016 9:42 pm

Re: video:play() issues

Post 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
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: video:play() issues

Post 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.
Last edited by 4aiman on Mon Aug 30, 2021 9:17 am, edited 1 time in total.
monolifed
Party member
Posts: 188
Joined: Sat Feb 06, 2016 9:42 pm

Re: video:play() issues

Post 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
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: video:play() issues

Post 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:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 50 guests