# Plugin + Third Party Lib = AccessViolation

**URL:** <https://forums.unrealengine.com/t/plugin-third-party-lib-accessviolation/321851>\
**Category:** Plugins\
**Tags:** third-party-librarie, access-violation, unreal-engine, Plugins, question\
**Created:** [June 15, 2015, 10:22am UTC](https://forums.unrealengine.com/t/plugin-third-party-lib-accessviolation/321851 "2015-06-15T10:22:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gormed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gormed](https://forums.unrealengine.com/u/gormed)\
**Post date:** [June 15, 2015, 10:22am UTC](https://forums.unrealengine.com/t/plugin-third-party-lib-accessviolation/321851/1 "2015-06-15T10:22:23Z")

</div>

Hi,

okay i have a UE 4.7 Plugin (not tested it for 4.8 yet) which uses the ffmpeg lib to record the current screen to HDD. I tried the UE4 binary and the source version with different self-build ffmpeg libs.

Some more details: Win 8.1, x64 Build for Windows, latest stable ffmpeg release (also tried some older versions)

The frames are meant to be captured by the plugin via ILiveStreamingService functionality:

```
void PushVideoFrame( const FColor* VideoFrameBuffer ) { ... }

```

But i tried some other different approaches too, e.g. capturing slate backbuffers manually:

```
uint8_t* FVideoExportStream::GrabFrame()
{
	FSlateRenderer* SlateRenderer = FSlateApplicationBase::Get().GetRenderer().Get();
	uint8_t* buffer = (uint8_t*)ReadbackBuffers[ReadbackBufferIndex];
	if (ReadbackBuffers[ReadbackBufferIndex] != nullptr)
	{
		SlateRenderer->UnmapVirtualScreenBuffer();
	}

	TArray<FString> UnusedKeypressBuffer;
	SlateRenderer->CopyWindowsToVirtualScreenBuffer(UnusedKeypressBuffer);
	SlateRenderer->MapVirtualScreenBuffer(&ReadbackBuffers[ReadbackBufferIndex]);

	// Ping pong between buffers
	ReadbackBufferIndex = (ReadbackBufferIndex + 1) % 2;
	return buffer;
}

```

There is an extra thread for encoding and recording (video and audio). The problem may lie on ffmpeg side, as far as i can say it. But maybe someone has done somthing compareable/related and can help. I have an access violation when i write the encoded frame to file:

```
// Write the compressed frame to the media file.
ret = av_interleaved_write_frame(oc, &pkt); // Here the access violation happens

```

Console log: **Unhandled exception at 0x000000006AE999FE (avformat-56.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000070**.

I have done something similar successfully with OpenCV (which cannot record audio, that is why i use ffmpeg), and had no problem writing to file. In fact, the file is created, but not filled with data; due to the access violation…

I hope that some UE engine or graphics dev can point me to the error or a potential solution. If you need some additional infos, just say it.

Thanks in advance,  
Hans
