[Libav-user] Speeding up codec detection of raw bitstream
wiebe at halfgaar.net
Sun Feb 11 20:09:19 EET 2018
----- Original Message -----
> From: "Wiebe Cazemier" <wiebe at halfgaar.net>
> To: libav-user at ffmpeg.org
> Sent: Sunday, 11 February, 2018 12:51:01
> Subject: [Libav-user] Speeding up codec detection of raw bitstream
> I'm working on an application for a hardware device I built. In essence, I
> obtain raw data from an optical receiver, which can be AC3, DTS, etc, and use
> ffmpeg to decode this into multi-channel analog output. It all works, but I was
> wondering what I can do to speed up the detection of the codec, especially if
> header packets are missed (because it captures mid-stream).
> To give ffmpeg IO, I make my own AVIOContext  with a callback function that
> reads from a semaphore controlled buffer. I assign that to avFormatContext->pb
> . Then I open the stream with:
> avformat_open_input(&avFormatContext, NULL, NULL, NULL) 
> This function blocks until a good codec is detected (or gives up?). Especially
> for DTS, this can take a very long time, especially when it missed headers.
> Is there a way to speed this up? Would it help for instance to not use
> av_register_all() and avcodec_register_all()? If so, how and what do I register
> what I need (documentation is unclear to me; it doesn't give examples).
> If there is any information in the original s/pdif bitstream, that is lost. The
> DIR9001 chip only outputs the contents.
>  http://ffmpeg.org/doxygen/trunk/structAVIOContext.html
>  http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html
Correction, it's the following line that takes a while:
In the docs I find this note with that function: "TODO: Let the user decide somehow what information is needed so that we do not waste time getting stuff the user does not need.
Still any options available to speed this up?
More information about the Libav-user