Skip to content
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

Cannot send a packet to the decoder. Error code: -1094995529 : Invalid data found when processing input #132

Open
Khhs167 opened this issue Jul 26, 2023 · 5 comments

Comments

@Khhs167
Copy link

Khhs167 commented Jul 26, 2023

Hello!

I am currently working on a system to allow me to integrate video support in my lil' game engine, and I decided to use FFMediaToolkit for decoding, since it seemed to fit my purposes.

Now, decoding works fine and dandy(some exceptions, which are most likely due to my own jank), for a couple seconds. Sometimes, it's 1 second, sometimes it's 6 seconds, and I don't know why.

The error log I've been getting(if you ignore the ALERROR, I've messed up some deinitialization stuff for OpenAL)

[vp9 @ 0x5567eb9d2a80] Not all references are available
[Error/AudioThread(11)] (ConsoleErr): AL ERROR: IllegalCommand:  at Close
[Fatal/Main(1)] (Engine): FFMediaToolkit.FFmpegException: Cannot send a packet to the decoder. Error code: -1094995529 : Invalid data found when processing input
   at FFMediaToolkit.Decoding.Internal.Decoder.DecodePacket()
   at FFMediaToolkit.Decoding.Internal.Decoder.ReadNextFrame()
   at FFMediaToolkit.Decoding.Internal.Decoder.SkipFrames(Int64 targetTs)
   at FFMediaToolkit.Decoding.MediaStream.GetFrameByTimestamp(Int64 ts)
   at FFMediaToolkit.Decoding.VideoStream.TryGetFrame(TimeSpan time, IntPtr buffer, Int32 bufferStride)
   at Soul.Engine.Video.Step(Single delta) in /home/khhs/RiderProjects/Soul/SoulEngine/Soul.Engine/Resources/Videos/Video.cs:line 73
   at Soul.UIScreens.DanceScreen.Update(Single delta) in /home/khhs/RiderProjects/Soul/Soul/UIScreens/DanceScreen.cs:line 24
   at Soul.Engine.UI.ComponentUI.Update(Single delta) in /home/khhs/RiderProjects/Soul/SoulEngine/Soul.Engine/UI/ComponentUI.cs:line 39
   at Soul.Engine.UI.UIScreen.UpdateCurrent(Single delta) in /home/khhs/RiderProjects/Soul/SoulEngine/Soul.Engine/UI/UIScreen.cs:line 28
   at Soul.Engine.Engine.OnUpdateFrame(Entity rootEntity) in /home/khhs/RiderProjects/Soul/SoulEngine/Soul.Engine/Core/Engine.cs:line 209
   at Soul.Engine.Engine.Loop() in /home/khhs/RiderProjects/Soul/SoulEngine/Soul.Engine/Core/Engine.cs:line 151

I can also attach Video.cs, and I hope it is understandable!
Video.cs.txt

If any further info is needed, feel free to contact me.

I'm using the latest FFMPEG binaries available in that repo you've got linked in the README(the version given by FFmpegLoader.FFmpegVersion is N-111626-g0ba719f726-20230726 so idk)

@Khhs167
Copy link
Author

Khhs167 commented Jul 26, 2023

I'd love to attach the video I've been using, but I am currently on limited and slow data.

@Khhs167
Copy link
Author

Khhs167 commented Jul 27, 2023

After further investigation, it seems like TryGetFrame(or possibly GetFrame) is the root of the problem.

When using TryGetNextFrame it seems like it suddenly works.

I'll do some more testing!

@Khhs167
Copy link
Author

Khhs167 commented Jul 27, 2023

Even more investigation later, and these kinds of errors seem to be more random that I thought.
All of a sudden TryGetNextFrame stopped working...

I wonder if it has something to do with threading?

The decoding thread shouldn't be ongoing though? Shouldn't that be invoked and then waited for?

@radek-k
Copy link
Owner

radek-k commented Jul 30, 2023

It might be a threading issue, but I'm not sure. Did you test other video files? What decoding thread do you mean? Is the Video.Step method called from another thread? FFMediaToolkit isn't thread-safe, so make sure that the TryGetFrame isn't called on different threads at the same time. You can try wrapping it with lock statement to ensure that.

@Khhs167
Copy link
Author

Khhs167 commented Jul 31, 2023

I am calling TryGetFrame from the same thread I do all FFmpeg stuff.
I managed to get ogv to work smoothly, mp4 and mov had their own issues(mp4 was "reiniting context", mov I don't remember, but it was 2.4 GB which I ain't dealin' with).

I didn't try other webm's but I tried re-encoding etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants