Jump to content
  • Advertisement
Sign in to follow this  

Unity Crash calling FFMPEG routines

This topic is 3638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just wanted to post a workaround (hack is more appropriate) that works for me to solve the crasher that can happen when calling a FFMPEG routine that expects the stack pointer to be 16 byte aligned at the time of call!. This code snippet works on my VS .Net C++ app. I got the inspiration from the original thread posted by "kek_miyu" http://www.gamedev.net/community/forums/topic.asp?topic_id=482230. So I thought I should return the favor by posting my solution and hope it works for someone else. // Adjust the stack pointer address by pushing dummy data until // it is 16 byte aligned. unsigned int stackAddress; unsigned int numDummyVariablesPushed = 0; while (true) { __asm { mov stackAddress, esp } if (stackAddress&15) { numDummyVariablesPushed ++; __asm { push eax } } else { break; } } // Call to FFMPEG routine that is being a naughty boy :) int encodedSize = avcodec_encode_video(tempStream->codec, bit_buffer, bit_buffer_size, encodedFrame); // Restore the stack pointer value back to original while (numDummyVariablesPushed --) { __asm { pop eax } }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!