-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom input #31
Comments
Yes, this is indeed on my TODO list for version 1.0.0. Currenly under construction, in fact. |
Great! Thanks a bunch. |
I made a function to create a source with a custom IO. Seems to work well. Feel free to use this or ignore as you see fit. :) Changes...
and
In kitsource.c
and Bob's your uncle! :) |
Well, I finally got to it and cleaned up my custom source branch, it should now be in master. I was wondering, is there a reason why you scan the incoming stream yourself before opening? I couldn't find any documentation about that (ffmpeg docs being what they are :( ) |
The example I worked from said that libav will scan up to 5MB of the file unless you do it yourself, so unless you allocate a 5MB buffer, it fails by overwriting memory. Now maybe that got fixed since the example was made. If so, then all the code can be removed. Oh, and a friend of mine was trying to compile this in MSVC and found that when passing the functions, the int64_t in the h file is not accepted. She had to change them to long long to get kitchensink to compile. Weird, huh? |
OKay, I checked out the new code... nice work on the custom input! Really clean and easy to follow. However, I'm getting an exception from Kit_CloseSource()... double free or corruption (!prev)
Apparently, one of the memory blocks getting freed got walked on... maybe that issue with checking the file I mention above? Maybe that's not fixed yet. |
Aaha, for some reason I couldn't get this to happen on Windows but happened first time on Ubuntu :) Alright, looks like avformat_close_input does all the frees when it's called, so extra free calls are not needed. I committed a fix to master for this, did not yet run valgrind or clean up the code. And yeah... when it comes to MSVC, MS does not guarantee C99 compliancy :( |
Yeah, it'd be great to see them meet a standard instead of trying to get what they do called a standard. That's just lazy programming... "I can't fix these bugs, so let's make a new standard where the bugs ARE standard!" It's good that you caught that. That must be a change in libav as all of the (older) examples I've looked at do the frees manually. The dangers of going by old example code... Well, I'll pull the latest and try it out. |
Working great! I think that's another issue resolved. :) |
Actually, I think there might still be an issue with the video probing walking on memory. If I try some arbitrary mp4, I get this: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x55ac63e38520] moov atom not found But if I bump the buffer to 8MB, I only get this: I think those extra free()s are needed, and simply not doing them suppressed the exception in the case of play the mkv I was testing before. |
On the other hand, I don't get any memory leaks in valgrind when I leave the extra free calls out, which in my mind says that they /shouldn't/ be needed :/ Okay, a shot in the dark: what happens if you comment out these from Kit_CreateSourceFromCustom?
Edit: Actually, never mind, I'm stupid. That's buggy code, src->format_ctx is not yet set >_< |
Okay, so I realized there is this: https://www.ffmpeg.org/doxygen/3.4/avio_reading_8c-example.html so then I implemented this: 62bdf31 At least doesn't crash on my computer and I can't get anything to die horribly in gdb :/ |
Well, I'll call it good until I can find something traceable. :) It works properly on the project I'm using it in. |
Okay. I couldn't get those errors with any of the videos I tried :/ I'll close this ticket as resolved, and if you run into those problems again, just open up a new one :) Thanks for comments and testing! |
The current library will create a source from a URL, but what would be handy is another function that created a source using custom read and seek routines. Looking at the source for Kit_CreateSourceFromUrl and at examples of creating a custom ffmpeg io context (like this one: https://www.codeproject.com/Tips/489450/Creating-Custom-FFmpeg-IO-Context ), it seems like that should be fairly easy. This would be a major boon to people doing things like reading files through PHYSFS or the like.
The text was updated successfully, but these errors were encountered: