Video-to-texture plugin with audio support and everything

Thanks!
I have considered that, but was hoping I could have it support the 4 major platforms first. I guess if this doesn’t happen soonish, I’ll just give up and submit it to the directory anyway.

Thanks!
Yeah, for the pull request I made, I mostly left things intact except for a few files I renamed. In this plugin however, I’ve deleted lots of unnecessary files (mostly encoding related) and tried hard to optimize for decoding. Also a few modifications to theoraplay to make audio work.

The source files are quite many especially for the vorbis and theora codecs, but I think it’s quite straightforward to build them, haven’t had any issues there. I think a good way to go about it would be to build the them as static libraries first (that’s what I did).

I was lucky enough to find OpenAL already built for win32 here.

The audio API seems like quite the challenge :smile:. Maybe I’ll look into it in the future when I have more time

Agreed, the build itself was smooth. Just a chore to set up.

Whoops, saw the fork but not the PR. Just pulled it.

A great plugin.

Thanks.

Very impressive. Working nicely with FilterViewer too.

I just built the plugin for Corona Simulator macOS. The simulator crashes at exiting (cmd+q) while playing video.

Hi, from the screenshot provided, it seems like a segmentation fault is causing the crash. Does the crash also occur with a built project?

I’ve tried exiting the simulator while video was playing to see if I could replicate your issue on windows, but there was no crashing. Did you perhaps modify the code before compiling the plugin?

Perhaps you could share the XCode project files so I could look around for any potential problems?

This might be helpful for finding the exact cause of the crash: https://stackoverflow.com/a/66450019

I forked your plugin_movie to GitHub - kwiksher/plugin_movie at macOS

the crash is not 100% reproducible. Sometimes the simulator finishes without crashing.

I changed plugin_movie.lua to calls plugin_movieLib.dylib. For instance, there is lib.newMovieCircle(opts) in plugin_movie.lua. I don’t think this is the cause.

libogg libtheora libvorbis are from GitHub - ggcrunchy/solar2d-plugins: Source for various Solar2D plugins. :slight_smile:

In your xcode project, there’s references to a plugin_movie.h which doesn’t exist in my repo. I’m not sure how you ended up with that.

Also, your code is quite confusing, but I think your lib.newMovieCircle(opts) addition might be the problem somehow. I suggest building the plugin with no modifications and testing to ascertain the exact problem.

I’d recommend using the ogg, theora and vorbis code provided in the /libraries folder to build the static libraries instead of using external libraries as I made some tweaks to these libraries that I’ve provided in the repo.

Thank you for the review. Now the ogg, theora and vorbis code are provided in the /libraries folder and removed plugin_movieLib.dylib. And plugin_movie.dylib is built with your original files.

But I can not resolve the runtime error that symbol not found in flat namespace ‘_CoronaPluginLuaLoad_plugin_movie’, when I run it in the simulator

I don’t know why extern “C” is not working. Why?

If I rename plugin_movie.c to plugin_movie.h to include it into PluginMovie.cpp, it resolves this issue but another runtime error appears

symbol not found in flat namespace '_th_comment_clear'

plugin_movie.h was an experiment while attempting to resolve the symbol not found error. I forgot to delete it before putting into my repo. Then I thought ggcrunchy/solar2d-plugins might be doing different with macosx, so I used the ogg, theora and vorbis of solar2d-plugins, and ended up to build plugin_movieLib.dylib that was not a lua/native hybrid.

The error symbol not found in flat namespace '_CoronaPluginLuaLoad_plugin_movie' is most likely because you aren’t building the file shared/generated/plugin_movie.c. This file is the compiled version of shared/plugin_movie.lua and must be built for the plugin to be usable. Instead of adding the entire /generated folder you should add the file directly to the build pipeline.

Regarding symbol not found in flat namespace '_th_comment_clear', I think adding the files theora.exp and theora.def to your build is what is causing the problem. They’re only needed when building with visual studio.

@ymmtny I don’t think I did anything special with the plugin libraries. There is a theora plugin in that solar2d_plugins directory (just a much more primitive iteration of this idea), but it doesn’t do anything special, just dump all the files into a project.

As far as the crash… looking at the report, I think I have an idea:

From some other conversations, I believe you’re comfortable with the Solar source code? If you look at the array destructor and follow the logic a bit, it looks like it calls the item destructors in turn, so I suppose, if something has the misfortune of attempting to be created or updated just as you’re relaunching, you might get a double free.

Does it still happen it you go to the Renderer destructor and add, say:

fCreateQueue.Clear();
fUpdateQueue.Clear();

?

This might explain some issues I’d been having with my Bytemap plugin, as well…

Now the link errors are fixed. I updated my macos branch.

I tested it for 10 times and no crash today. I look into Renderer destructor later.

Thank you for the comments, @devex, @StarCrunch

2 Likes

That’s great! With your permission, I can update my repo and add the macos build project files as well as the .dylib binaries. It might be a good idea to make a pull request.

Also, if you or anyone else is able to build the plugin for iOS, that would be appreciated.

Sure you can use it.

My commit history is not clean. Instead of a pull request, it would be better to pick the files in macos folders . XCode project files are originally from ggcrunchy/solar2d-plugins

I built it for iOS by changing the SDK maxOS to iOS in XCode settings and it worked in the XCode simulator. I have not tested it yet with my old iPad Pro. It is in my ios branch.

Ok, I’ll look into adding the files manually, but since I can’t build them myself as I do not have access to a mac, I’m kindly asking you to share your build outputs (plugin_movie.dylib and libplugin_movie.a) so I can craft a release and finally add the whole plugin to the Solar2D plugin directory. I will credit you for the apple builds.

You can get the libraries in my ios branch.

  • maxosxlibs/plugin_movie.dylib
  • ioslibs/Release-iphoneos/libplugin_movie.a

It played well on iPad Pro(10.5 inch, 15.4.1).

1 Like

Many thanks to @ymmtny for the macOS and iOS builds, the plugin is now live on the solar2D plugin repository here

I have added a simple usage example here. Include the plugin in your project like so and you’ll be ready to go:

plugins = {
    ["plugin.movie"] = {
        publisherId = "com.ansh3ll"
    },
},

Windows, macOS, Android and iOS are all supported. In case of any issues, don’t hesitate to reach out. Have a nice day.

2 Likes

I got an error on Corona Simulator(Mac) when I relaunch it.

Blockquote
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 Corona Simulator 0x10279a05d Rtt::ArrayRtt::CPUResource*::Remove(int, int, bool) + 81
1 Corona Simulator 0x1027c1050 Rtt::Renderer::~Renderer() + 326
2 Corona Simulator 0x1027bf45c Rtt::GLRenderer::~GLRenderer() + 14
3 Corona Simulator 0x1027497ef Rtt::Display::~Display() + 291
4 Corona Simulator 0x102749844 Rtt::Display::~Display() + 14
5 Corona Simulator 0x102796e7a Rtt::Runtime::~Runtime() + 286
6 Corona Simulator 0x1026c4938 Rtt::PlatformPlayer::~PlatformPlayer() + 40
7 Corona Simulator 0x1026c4bfb Rtt::PlatformSimulator::~PlatformSimulator() + 37
8 Corona Simulator 0x1026b3bb0 Rtt::MacSimulator::~MacSimulator() + 14
9 Corona Simulator 0x102697b05 -[AppDelegate closeSimulator:] + 24

@pickerel Same spot as you see in @ymmtny’s crash above. I do think it just needs that fix I mentioned, or alternatively to make those LightPtrArrays. Maybe I can submit a PR in the near future.