mlt icon indicating copy to clipboard operation
mlt copied to clipboard

SDL2 on Windows crash/hang

Open jamesc2048 opened this issue 6 years ago • 5 comments

Hi,

I've been trying to get an MLT build working on Windows. I can get it to build but the build is not functional when using the C API. SDL consumer displays a window and then hangs, and the avformat producer/consumer crashes. GDB output in this pastebin: https://pastebin.com/ByUfFPE8

The code I am using to test is derived from the first API examples on the documentation, and does compile and work as expected on Ubuntu 16.04 (of course, changing code to use Linux specific sleep function): https://pastebin.com/TwB7uTH5

I've tried these build hosts with same results:

  • Windows 7, MSYS2, GCC 7.1.0 32 bit and 64 bit
  • Windows 7, MinGW (Qt installer) 5.3.0 32 bit
  • Ubuntu 14.04 cross compiled following https://www.shotcut.org/notes/cross-compile/
  • Windows 7, Shotcut prebuilt SDK https://www.shotcut.org/notes/windowsdev/

The built melt.exe does seem to work fine, I've tried avformat, color and sdl producers/consumers and they work (e.g. "melt.exe color:red out=60 -consumer avformat:test.mp4"). I am running melt.exe and my built binary from the same folder to ensure it has access to the same plugins and dlls.

Could you tell me if there is anything wrong with the code, or is there any sort of change I need to make to get my code to work on Windows? I've looked at the melt Makefile and I can't see any Windows specific compiler flags which I may have missed.

Thanks in advance. -James

jamesc2048 avatar Jul 26 '17 10:07 jamesc2048

The SDL integration on Windows sucks and is flaky. I have no intention of fixing or improving it. Shotcut builds, including the SDK, even sets the define "MELT_NOSDL" in CFLAGS that basically means: I give up and do not use or support using the sdl consumer as Shotcut does not need it. You can use another consumer. You can try to fix it yourself and submit a patch. It might be more interesting to replace it with a SDL2 consumer and see if that integrates any better.

ddennedy avatar Jul 26 '17 16:07 ddennedy

Hey Dan,

First of all, I was having crashes not just with SDL but also with avformat producer/consumer, which is quite a lot more needed to use Mlt.

But I have narrowed down the issue. I scoured the melt code to understand why melt worked, but my code didn't. I noticed I was not creating an explicit profile to pass into the factory producer/consumer calls.

I found that if one does not pass in a mlt_profile pointer to mlt_factory_producer call, it causes an Mlt crash in the avformat producer. It was my understanding that Mlt is supposed to use a default profile, in that case (as per the API docs). This only happens on Windows, Linux is fine in this case.

So now I am passing in a default instance of a profile, and it works. mlt_profile profile = mlt_profile_init(NULL);

I'll try and narrow down why this is happening, if I can figure it out, I'll try and fix it and send you a patch. At least there's a code workaround.

Oh and yes SDL still doesn't work right on Windows. An SDL2 backend would probably work better.

Here's the backtrace of the crash if anyone is still interested/curious: https://gist.github.com/jamesc2048/9b7f39cc8da1e5ec1e74b49435a99712

Thanks. -James

jamesc2048 avatar Jul 28 '17 08:07 jamesc2048

SDL2 has been integrated into MLT v6.6.0. Now, melt can display video; however, you still cannot interact with the window (size, position, or defocus). Doing so makes it crash even when using a simple color or noise producer. At this time, SDL window output of melt on Windows is simply not a priority. It is more important that it behaves well as a console-only app such as for use with avformat consumer. The avformat producer and consumer generally work fine on Windows as demonstrated by Shotcut. I will change the subject of this to be about SDL.

ddennedy avatar May 10 '18 18:05 ddennedy

why not author do not realse a .exe version?

MAYBreath avatar Mar 21 '19 18:03 MAYBreath

why not author do not realse a .exe version?

It comes with Shotcut.

ddennedy avatar Mar 21 '19 18:03 ddennedy