Jump to content
  • Advertisement
Sign in to follow this  
Pruth

Unity Crash calling FFMPEG routines

This topic is 3545 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!