heisters / libglvideo

Simple cross-platform MP4/MOV video player for use with OpenGL
Other
28 stars 5 forks source link

Issues getting things up & running #1

Open mattfelsen opened 5 years ago

mattfelsen commented 5 years ago

Hello! I'm having some trouble & wanted to share my efforts thus far and see if you had any insights.

Correct way to build lib on Windows? I couldn't find a CMakeLists.txt for the lib itself -- it looks like there used to be one but things got moved around. I was able to build the lib by building the play & stress examples which build libglvideo as a dependency, but wasn't sure if that was a workaround or the intended way.

Crashes when trying to play videos I get crashes on launch with both the play and stress examples. I noticed that AP4_FileByteStream::Create() was failing, and it looked like an issue with the path being relative, so I got passed it by just using a hardcoded absolute path for now.

With the absolute path, I'm seeing that the AP4_File m_movie doesn't seem to have any valid data, i.e. m_Movie, m_FileType, and m_MetaData are all null pointers. Here's a screenshot:

image

One thing that was curious is the included example videos don't actually play for me in VLC, and I don't get video thumbnails in Windows Explorer. I have some other sample content from here that both plays in VLC and has thumbnails, and is in an mov container rather than avi. I gave that a shot, but it didn't seem to make a difference. I do have the hap DirectShow codecs installed, but I don't think that should matter.

Curious if you've got any ideas about what's up! Thanks!

mattfelsen commented 5 years ago

Ah, I realize the example videos are meant to be checked out with git LFS, which I haven't done.

Curiously, I am now able to get the other sample content I pointed to to work! I'm not sure what changed between before & after opening the issue! I actually get only a blank screen with the play example, but the stress works as expected. Gonna continue poking around and will report any more findings.

On a different note, the submodules failed to clone initially since they use the ssh urls instead of https (except for Bento4). After changing the urls in .gitmodules and running git submodule sync I was then able to pull them all in

heisters commented 5 years ago

Ah, I realize the example videos are meant to be checked out with git LFS, which I haven't done.

I'm accepting README pull requests ;)

I actually get only a blank screen with the play example, but the stress works as expected.

The play example may be out of date. Glad to hear stress works.

On a different note, the submodules failed to clone initially since they use the ssh urls instead of https (except for Bento4). After changing the urls in .gitmodules and running git submodule sync I was then able to pull them all in

Thanks, good to know. I should fix that.

The way I've been building it is by adding it as a module to the client project using the method described here: https://github.com/heisters/libglvideo#cmake But there should be a way to build the lib directly, and there currently is not. It wouldn't be hard to add.

My apologies that this lib is a little dusty. I've mostly been using it through Cinder-FrameGraph, and that's another good place to look if you need examples. Especially:

https://github.com/heisters/Cinder-FrameGraph/blob/master/proj/cmake/Cinder-FrameGraphConfig.cmake#L41 https://github.com/heisters/Cinder-FrameGraph/blob/master/include/cinder/framegraph/GLVideo.hpp https://github.com/heisters/Cinder-FrameGraph/blob/master/src/cinder/framegraph/GLVideo.cpp

heisters commented 5 years ago

TODO:

Does that cover it? Are you able to workaround everything, or is there something else I can address to get you working?

mattfelsen commented 5 years ago

I'm accepting README pull requests ;)

I'll send a PR with the note on LFS for the examples and fixing the gitmodules URLS :)

The way I've been building it is by adding it as a module to the client project using the method described here: https://github.com/heisters/libglvideo#cmake But there should be a way to build the lib directly, and there currently is not. It wouldn't be hard to add.

Ok, good to know I didn't miss something obvious!

Thanks for the quick replies. I'm happy to have gotten a sample working and hope I can use it for an upcoming project. Are the docs still accurate in that there's currently no audio support or for codecs aside from Hap? I tried playing back HapQ and Hap Alpha files that seemed to work (I had to modify decoder::Hap::matches() to return true for Hap1 and Hap5), but I couldn't encode a Hap Q Alpha video to create some test content

mattfelsen commented 5 years ago

Are you able to workaround everything, or is there something else I can address to get you working?

Yes I think I'm good to test out using libglvideo and/or FrameGraph in the fronted framework I regularly use; I'll continue to share some updates šŸ‘ŒšŸ¼

heisters commented 5 years ago

Are the docs still accurate in that there's currently no audio support or for codecs aside from Hap?

Yeah. A couple people have expressed interest in sponsoring the addition of those, but without a sponsor or pull request both features will probably wait until I end up needing them on a project. Are there particular audio and video formats you would be interested in?

Yes I think I'm good to test out using libglvideo and/or FrameGraph in the fronted framework I regularly use; I'll continue to share some updates šŸ‘ŒšŸ¼

Great!

mattfelsen commented 5 years ago

I just sent over two small PRs, one for the gitmodules and another for updating Hap::matches() to work for Hap, HapQ, and HapA files šŸ‘

Re: git lfs, I tried running git lfs fetch and after downloading a GB of data, it fails with this error:

$ git lfs fetch
Fetching master
Git LFS: (3 of 3 files, 1 skipped) 948.44 MB / 948.44 MB, 1.62 GB skipped
[4ce07c37c986bdf98698e4de855969172e3009f1f47567c5320587090116f6ad] Object does not exist on the server: [404] Object does not exist on the server
error: failed to fetch some objects from 'https://github.com/heisters/libglvideo.git/info/lfs'

I'm not sure what's going on, but since I can't pull them down successfully I'll hold off on any readme change there.

Are there particular audio and video formats you would be interested in?

For audio, either wav/aiff and/or mp3s are what I was thinking, nothing unusual. I'm planning to do some testing to see if using libglvideo along with a separate audio file played via cinder::audio will stay in sync, which is hopefully a simple workaround for this. Have you tried that out before on any projects?

And, confirming I was able to get a video playing inside Bluecadet's Views framework, which I'm planning to use on this project šŸ‘Œ

Of note, I was getting link errors regarding a mismatch between static & dynamic builds of the Runtime Library. I had to change the libglvideo, ap4, play, and stress projects to compile the runtime lib with /MT instead of /MD to resolve it. If you weren't intentionally setting that (I'm guessing no since libglvideo and ap4 compile to .libs and not .dlls), there's a cmake flag which can be used. I'm happy to test that out if it's helpful. Some more info I found on SO: https://stackoverflow.com/questions/14172856/cmake-compile-with-mt-instead-of-md

heisters commented 5 years ago

Sorry for the delay, just catching up.

improve error handling when video is invalid or not found

going back to that, I am getting a reasonable error (below) running the play command with the wrong path to the videos. It depends on getting the video files (more below), and setting the right working directory when executing the command. I also notice that if you run it under a debugger, the debugger will catch the originating exception, which can be confusing as it's not quite as descriptive and is buried in Bento.

libc++abi.dylib: terminating with uncaught exception of type glvideo::Error: cannot open input file examples/videos/hap-3840x2160-24fps.mov
Abort trap: 6

not pretty, but sufficient IMO.

Re: git lfs, I tried running git lfs fetch and after downloading a GB of data, it fails with this error:

I'm having issues too. You can also cd videos && ./generate.sh to rebuild the videos. You'll need ffmpeg with Hap support installed. I've updated the README.

I'm planning to do some testing to see if using libglvideo along with a separate audio file played via cinder::audio will stay in sync, which is hopefully a simple workaround for this. Have you tried that out before on any projects?

I haven't. Let me know if it works. I'm going to guess that it will get out of sync, but I'm happy to be proven wrong ;)

And, confirming I was able to get a video playing inside Bluecadet's Views framework, which I'm planning to use on this project šŸ‘Œ

šŸ˜® awesome!

I had to change the libglvideo, ap4, play, and stress projects to compile the runtime lib with /MT instead of /MD to resolve it.

I generally prefer static linking so that I have more portable executables and avoid dependency hell. The additional filesize has never been an issue, especially on the kinds of projects I use Cinder and/or libglvideo for. I haven't tested using any of this as a DLL, but understand that it could be useful in some cases.

Thanks for the pull requests, all merged!

mattfelsen commented 5 years ago

not pretty, but sufficient IMO.

I agree!

I haven't. Let me know if it works. I'm going to guess that it will get out of sync, but I'm happy to be proven wrong ;)

So what I've seen initially is using a FilePlayerNode (which streams from disk) has issues with seeking, but BufferPlayerNode (which loads entirely into memory) performs well! My test was to pause/play, or seek the video around, and use the video's position to set the position of the sound player. I haven't done a longer test yet to see if the two drift apart over time. I'll post on the forums soon to see if anyone's aware of or working on any seek accuracy issues for the file player

I generally prefer static linking so that I have more portable executables and avoid dependency hell

I'm with you šŸ’Æ percent. BUT, /MT IS static linking, /MD is dynamic. Maybe my version of CMake is defaulting the project to dynamic whereas yours didn't? But out of the (Tinder)Box, a new Cinder project is set up for static linking whereas the CMake-generated project for libglvideo was set for dynamic.

heisters commented 5 years ago

I'm with you šŸ’Æ percent. BUT, /MT IS static linking, /MD is dynamic. Maybe my version of CMake is defaulting the project to dynamic whereas yours didn't? But out of the (Tinder)Box, a new Cinder project is set up for static linking whereas the CMake-generated project for libglvideo was set for dynamic.

Right, of course :P Weird.... you're generating a project (Visual Studio?) with CMake? That may be why I haven't hit that issue. I've been using CLion and VSCode, which use CMake directly, rather than generating a Visual Studio project. At one point I was also using Visual Studio's direct support for CMake, introduced in VS 2017 which worked, but was a little harder to use than VSCode + CMake Tools.

mattfelsen commented 5 years ago

Ah interesting. Yes, I was using CMake (cmake-gui, actually) to generate the VS project, and used that to build the examples which in turn built libglvideo & the other dependencies. Then I used TinderBox to create a Cinder project and manually added the libglvideo and ap4 libs. It's a bit roundabout, but I'd prefer to have libglvideo and its deps included as source inside my Cinder project so that I don't need to rebuild everything if I need to do a clean build or such.

heisters commented 5 years ago

If you're willing to switch up your tools, I strongly recommend VSCode + CMake Tools, since Cinder works quite well with that now. Include all libs in your project source tree as git submodules, and CMake will automatically rebuild only as needed.

I haven't seen docs for getting started specifically with VSCode + CMake + Cinder, but you can cobble it together by starting here: https://libcinder.org/docs/branch/master/guides/cmake/cmake.html

mattfelsen commented 5 years ago

Whoops, I meant I prefer to not have libglvideo/ap4 in the project as source, though it looks like having them defined as separate projects that are built as deps and linked against would be supported too (I guess that's what you've got set up with the play/stress examples, yea?).

So you're saying you don't use TinderBox at all, relying only on CMake both for projects that use Cinder and that don't? And can I ask about your preference for VSCode over VS? I imagine it's more than the CMake Tools working better with the latter editor..

heisters commented 5 years ago

Whoops, I meant I prefer to not have libglvideo/ap4 in the project as source, though it looks like having them defined as separate projects that are built as deps and linked against would be supported too (I guess that's what you've got set up with the play/stress examples, yea?).

If you want to build libglvideo and just link it in, it should be pretty simple to write cmake jobs for that by referencing the existing ones. I prefer to include it as source because it makes it easier to incorporate any changes I make.

So you're saying you don't use TinderBox at all, relying only on CMake both for projects that use Cinder and that don't?

Yeah. TinderBox is great for simple projects, but it's never been helpful on more complex ones. I ended up doing everything by hand until Cinder started supporting CMake.

And can I ask about your preference for VSCode over VS? I imagine it's more than the CMake Tools working better with the latter editor..

It's mostly that VSCode has CMake Tools, and that it reads directly from CMake instead of having an intermediary project generation step. VS's direct CMake support was buggy and limited last I checked. Additionally it's lighter weight, easier to use, more similar to other editors, and still has my favorite feature of VS: IntelliSense. Oh, and you can use VSCode to compile with clang on all platforms, so you have really easily cross-platform projects.

mattfelsen commented 5 years ago

Hi again! I'm popping back in to share a few updates. We've been using this lib on a couple apps with various video needs and have been seeing pretty good results, which is awesome. The scrubbing performance is great, which is expected for Hap, and also the performance when playing multiple high-res files is šŸ‘Œ šŸ‘Œ . In one case we're doing playback of a 6K+ file while seeking another in the background without issue, whereas a WMF player with h264 content chokes for a second or two. Thanks again for sharing this lib and helping me get off the ground šŸ™ . Gonna open up a couple issues for things we've been running into...