[FFmpeg-devel] [PATCH] avformat/utils: add helper functions to retrieve index entries from an AVStream
James Almer
jamrial at gmail.com
Tue Mar 23 21:22:57 EET 2021
On 3/23/2021 4:11 PM, Nicolas George wrote:
> Nicolas George (12021-03-23):
>> And it is exactly what we are doing when we let users access fields
>> directly.
>
> I mean:
>
> AVStream **streams = ctx->streams;
> av_read_frame(ctx, &packet);
> AVStream *stream = streams[packet.stream_index];
>
> That should work, right?
No, avformat_new_stream() will reallocate that array, so if
av_read_frame() can allocate new streams (I think AVFMT_NOHEADER formats
do that) then that may just crash.
You should always use ctx->streams directly.
>
> Regards,
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list