[Libav-user] any way to interrupt avcodec_decode_video2 ?

Don Moir donmoir at comcast.net
Tue Dec 31 13:24:57 CET 2013


----- Original Message ----- 
From: עופר בר 
To: This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter. 
Sent: Tuesday, December 31, 2013 6:32 AM
Subject: Re: [Libav-user] any way to interrupt avcodec_decode_video2 ?


>I think it's also possible to multi-thread decoding by changing some parameters codec context structure like thread_count and thread_type. 
>You do need a multi-threaded ffmpeg build for that I believe.
>Maybe in this way you can reduce the decoding time, assuming you have few cores.

Possibly ffmpeg multi-thread decoding would help some, but I am leary about that. More things to go wrong and more for me to figue out what went wrong :) Also I may have numerous threads open since there may be more than 10 av files open and playing at same time so try to be careful about being too thread heavy.

Conceptually it's a pretty easy thing to implement an interrupt callback for AVCodecContext. It may take awhile though for it to filter thru everywhere, hitting the problem areas first and ignored by others while waiting.

Mostly its not too bad but depends on machine and video of course. I don;t think most will have much interest but timeline apps and editing apps could benefit the most.

You also have to ask why an intense process like decoding is not interruptible.
  ----- Original Message ----- 
  From: עופר בר 
  To: This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter. 
  Sent: Tuesday, December 31, 2013 6:32 AM
  Subject: Re: [Libav-user] any way to interrupt avcodec_decode_video2 ?


  I think it's also possible to multi-thread decoding by changing some parameters codec context structure like thread_count and thread_type.
  You do need a multi-threaded ffmpeg build for that I believe.
  Maybe in this way you can reduce the decoding time, assuming you have few cores.





  On Mon, Dec 16, 2013 at 8:17 AM, Don Moir <donmoir at comcast.net> wrote:

    From: עופר בר 
    To: This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter. 
    Sent: Tuesday, December 31, 2013 5:24 AM
    Subject: Re: [Libav-user] any way to interrupt avcodec_decode_video2 ?


    >What do you mean by "waiting"? 
    >If you're calling this api on a different thread, why can't you terminate the thread?
    >If you're calling it from your main thread, there's nothing your app can do until the function returns, unless they implement some callbacks in the middle of the execution.


    >Best of luck!

    I allow for proper cleanup and no telling what state ffmpeg would be in if I just up and terminated the thread. It's in the mist of decoding and waiting for return allows me to free packet its decoding etc.

    Another thread waits on it normally waiting to seek or exit.

    Best thing would be interrupt callback.

    ---- Original Message ----- 
      From: עופר בר 
      To: This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter. 
      Sent: Tuesday, December 31, 2013 5:24 AM
      Subject: Re: [Libav-user] any way to interrupt avcodec_decode_video2 ?


      What do you mean by "waiting"? 
      If you're calling this api on a different thread, why can't you terminate the thread?
      If you're calling it from your main thread, there's nothing your app can do until the function returns, unless they implement some callbacks in the middle of the execution.


      Best of luck!



      On Mon, Dec 16, 2013 at 8:48 AM, Don Moir <donmoir at comcast.net> wrote:


        ----- Original Message ----- From: "Carl Eugen Hoyos" <cehoyos at ag.or.at>
        To: <libav-user at ffmpeg.org>
        Sent: Tuesday, December 31, 2013 4:08 AM 

        Subject: Re: [Libav-user]any way to interrupt avcodec_decode_video2 ?



          Don Moir <donmoir at ...> writes:


            Since app is timeline oriented, trying to keep seek time
            down to minimum and if avcodec_decode_video2 has been
            called, seems there is no way out until its finished
            and this decoding time can delay a new seek attempt.


          Are you looking for CODEC_FLAG2_SHOW_ALL?

          Carl Eugen



        No. I can easily check between calls to avcodec_decode_video2 but once its called you are stuck until it returns. Would be nice to be able to interrupt it for quicker seeking and to end 'the' video more quickly. Doesn't matter too much for a simple player app, but I have things on timelines and also video coming and going quicky. Things are time corrected to a timeline but the more I can reduce impact from things like this the better off we are.

        A simple seek to zero is quick, but if I have to wait on avcodec_decode_video2 to return, then its slower and can be quite slow. I don't mean finish as in the flag (gotframe) to avcodec_decode_video2, but just waiting on it to return period. 


        _______________________________________________
        Libav-user mailing list
        Libav-user at ffmpeg.org
        http://ffmpeg.org/mailman/listinfo/libav-user





--------------------------------------------------------------------------


      _______________________________________________
      Libav-user mailing list
      Libav-user at ffmpeg.org
      http://ffmpeg.org/mailman/listinfo/libav-user



    _______________________________________________
    Libav-user mailing list
    Libav-user at ffmpeg.org
    http://ffmpeg.org/mailman/listinfo/libav-user






------------------------------------------------------------------------------


  _______________________________________________
  Libav-user mailing list
  Libav-user at ffmpeg.org
  http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131231/8a8b7c3e/attachment.html>


More information about the Libav-user mailing list