[FFmpeg-trac] #9326(avformat:new): avformat_find_stream_info sometimes gets stuck

FFmpeg trac at avcodec.org
Sat Jul 10 12:09:45 EEST 2021

#9326: avformat_find_stream_info sometimes gets stuck
             Reporter:  Jean-        |                     Type:  defect
  Michaël Celerier                   |
               Status:  new          |                 Priority:  normal
            Component:  avformat     |                  Version:
                                     |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |

 Under Linux, with a V4L2 device, avformat_find_stream_info gets stuck
 (tried on ffplay).

 Minimal code that fails for me (can be reproduced in ffplay):

     auto formatContext = avformat_alloc_context();

     avformat_open_input(&formatContext, "/dev/video0", nullptr, nullptr);
     avformat_find_stream_info(formatContext, nullptr);  // < stuck here

 (error code checking omitted for clarity).

 My video device is a virtual V4L2 device (Droidcam which allows to get a
 camera feed from an Android tablet or phone to the desktop over the

 The issue can be tested with the droidcam ArchLinux AUR package. What
 seems to happen is just that there is no data flowing out of /dev/video0
 at all and I guess avformat_find_stream_info is trying to probe some bytes
 of the stream without a timeout ?

 What kind of checks could I add in my client app to make sure that things
 aren't going to get stuck, sort of running a probe in a separate process
 and adding a watchdog ?

 For instance, guvcview is able to perform operations on the stream without
 getting stuck, even if there is no input, so likely there *is* a way.
Ticket URL: <https://trac.ffmpeg.org/ticket/9326>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list