leandromoreira / ffmpeg-libav-tutorial

FFmpeg libav tutorial - learn how media works from basic to transmuxing, transcoding and more. Translations: πŸ‡ΊπŸ‡Έ πŸ‡¨πŸ‡³ πŸ‡°πŸ‡· πŸ‡ͺπŸ‡Έ πŸ‡»πŸ‡³ πŸ‡§πŸ‡·
https://github.com/leandromoreira/ffmpeg-libav-tutorial
BSD 3-Clause "New" or "Revised" License
9.78k stars 937 forks source link

[Question] About libavformat avio, How to use custom asynchronous IO. #92

Closed ChinaChenMingQuan closed 3 years ago

ChinaChenMingQuan commented 3 years ago

Note: It is asynchronous IO, not synchronous IO.

leandromoreira commented 3 years ago

hi there @ChinaChenMingQuan this might not be related directly with ffmpeg/libav, but by using avio + c async io, isnt?

But if that's not the case, I found this seek async piece of code, it might help you.

ChinaChenMingQuan commented 3 years ago

@leandromoreira, I need asynchronous IO like the C# language.

Example:

  1. Pseudocode: await fread_async(buffer, 1, count, handle_stream); await av_read_frame_async(pFormatContext, pPacket);

  2. C Code: fread_async(buffer, 1, count, handle_stream, callback_on_completion); av_read_frame_async(pFormatContext, pPacket, callback_on_completion);

  3. C++ Code: co_await fread_async(buffer, 1, count, handle_stream); co_await av_read_frame_async(pFormatContext, pPacket);

ChinaChenMingQuan commented 3 years ago

I want to call the FFmpeg API, Don't want to change the FFmpeg code. I don't like the GPL.

ChinaChenMingQuan commented 3 years ago

But FFmpeg API avio_alloc_context does not support asynchronous IO. It's so hard to find a modern codec library.

ChinaChenMingQuan commented 3 years ago

@leandromoreira, FFmpeg has no asynchronous IO. Server needs asynchronous IO to wait for client code. Cannot host a client in one thread.

ChinaChenMingQuan commented 3 years ago

@leandromoreira, Only multiple processes can be selected to solve. If you have a method, I hope you can give an example.