Question: When I executed the following code:

```
AVFrame tmp = frames_video1[k]; //AVFrame frames_video1[]
AVFrame *avf1 = &tmp;
AVFrameSideData* avfsd1=NULL;
if(avf1->side_data != NULL)
    printf("avf1->side_data is not NULL!!...........\n");
avfsd1 = av_frame_get_side_data(avf1, AV_FRAME_DATA_MOTION_VECTORS);

```

I came across segmentation fault happened at av\_frame\_get\_side\_data(avf1, AV\_FRAME\_DATA\_MOTION\_VECTORS):

```
avf1->side_data is not NULL!!...........
Segmentation fault (core dumped) 

```

why?

Answer: 
here is the output of gdb:

```
(gdb) print avf1->side_data->type 
Cannot access memory at address 0x0

(gdb) print frames_video1[1]->side_data->type 
Cannot access memory at address 0x0

```

surprisingly, avf1 points to a corrupted frame whose `side_data->type` is null, which is abnormal. The cause of the issue resides somewhere else.
> 
> 
> ```
> AVFrame tmp = frames_video1[k]; //AVFrame frames_video1[]
> AVFrame *avf1 = &tmp;
> 
> ```
> 
> 

You can't do this. I don't know where you learned this, but this is not allowed and fundamentally cannot work. You don't know the size of AVFrame in the application (it is not part of FFmpeg's ABI), so you cannot place a copy on the stack. Instead, do this:

```
AVFrame *avf1 = frames_video1[k];

```

Do not ever copy an FFmpeg object on the stack, it will not work. This also means frames\_video1[] needs to be an array of `AVFrame *`, i.e. `AVFrame` pointers, not an array of `AVFrame`. If you don't understand why, read about pointers and memory in C and remember again that `AVFrame`'s size is not part of the FFmpeg ABI.

Now, let's debug your object. First, basics of C stack: how many frames are in `frames_video1[]`, and what is `k`? What is `frames_video1[k]->data[0]` or `frames_video[k]->linesize[0]`? Are they legal? Are you sure `frames_video1[k]` is a legal object? The fact that some copy of non-existing memory is non-`NULL` means nothing.

Secondly, if the object is legal, what is `AVFrame->nb_side_data`? You cannot access `AVFrame->side_data[]` beyond that index.

> 
> 
> ```
> (gdb) print avf1->side_data->type
> 
> ```
> 
> 

You can't do that either. `side_data[]` is an array of pointers, so instead do this:

```
(gdb) print avf1->side_data[0]->type

```

All that said, I again highly recommend you to read up on C pointers and memory allocation, I don't think you entirely understand it. FFmpeg is a very low-level C library and not understanding C will cause lots of grief.