[FFmpeg-trac] #6529(avformat:new): interrupt_callback not working

FFmpeg trac at avcodec.org
Sun Jul 16 07:41:58 EEST 2017

#6529: interrupt_callback not working
             Reporter:  sergman      |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  avformat     |                  Version:
             Keywords:  interrupt    |  unspecified
  callback                           |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
 The issue is related to the old problem described here:

 I installed the latest version and the callback is not called if I pass
 non-existing/broken link to avio_open2 or avformat_open_input

 Even av_dict_set(&options, "timeout", "5", 0); does not have any effect.
 The call just hangs.

 Note that if the link exists the callback is working fine.

 Here is the small code (actually copied from the mentioned ticked above).
 Compiled in Visual Studio 2015. Includes/libraries/DLLs are all up to date
 from https://ffmpeg.zeranoe.com/builds/


 #include <Windows.h>

 #include <libavcodec\avcodec.h>
 #include <libavformat\avformat.h>
 #include <stdio.h>

 static int interrupt_cb(void *ctx)
         printf("Interrupt callback called\n");

         return 0;

 int main(int argc, char *argv[]) {
         AVFormatContext *pFormatCtx;

         if (argc < 2) {
                 printf("Please provide a movie file\n");
                 return -1;
         // Register all formats and codecs

         // Open video file
         pFormatCtx = avformat_alloc_context();
         pFormatCtx->interrupt_callback.callback = interrupt_cb;
         pFormatCtx->interrupt_callback.opaque = pFormatCtx;

         AVDictionary* options = NULL;
         AVIOContext* av = NULL;
         AVIOInterruptCB cb = {
                 .callback = interrupt_cb,
                 .opaque = NULL,

         //av_dict_set(&options, "timeout", "5", 0);
         // hangs
         int ret = avio_open2(&av, argv[1], AVIO_FLAG_READ, &cb, &options);

         // hangs
         if (avformat_open_input(&pFormatCtx, argv[1], NULL, &options) !=
                 return -1; // Couldn't open file

         return 0;


Ticket URL: <https://trac.ffmpeg.org/ticket/6529>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list