Implementing "-async 1" in C Code to Fix Sound Sync

I built a segment that accepts video and h264 / AAC segments as input according to the HLS specification. The source code for it can be seen here: https://gist.github.com/cpnielsen/f36729c371aac0fe535d

It is implemented as a python extension, but the interesting parts are in the process_video() function. It uses the libav library (alternatively ffmpeg ) for heavy lifting.

It works 95% of the time, but we come across some videos where it creates segments with audio sync. If I used the command line tool, I could just add -async 1 to fix it, but how to implement the same functionality in my C code?

I found a code snippet in avconv_filter.c (for libav , not sure what the equivalent of ffmpeg ) where they trigger the filter, but without any documentation it’s hard to figure out how to do this outside the whole modular configuration.

I just need to:

  • Initiate the correct filter
  • Apply it to input (or output? Not sure)
  • Be aware of any errors when using the filter.

Any help is appreciated; code sample, filter description, etc.

+6
source share

Source: https://habr.com/ru/post/953633/


All Articles