[FFmpeg-trac] #4901(undetermined:reopened): mjpeg codec ignores -threads 1

FFmpeg trac at avcodec.org
Fri Oct 2 16:28:39 CEST 2015


#4901: mjpeg codec ignores -threads 1
-------------------------------------+-------------------------------------
             Reporter:  jvd66        |                    Owner:
                 Type:  defect       |                   Status:  reopened
             Priority:  normal       |                Component:
              Version:  unspecified  |  undetermined
             Keywords:               |               Resolution:
             Blocking:               |               Blocked By:
Analyzed by developer:  0            |  Reproduced by developer:  0
-------------------------------------+-------------------------------------

Comment (by jvd66):

 We cannot use current git head because we have a large body of scripts
 that use the ffmpeg 2.2.x command line arguments format , and the git head
 is too unstable for our use.

 Inspecting the code with GDB shows that with the above -threads* options,
 which represent all
 the possibly relevant combinations I could think of:
     -threads 1 -threads:1 1 -threads:0 1 -threads:v 1 -threads:1 1
 -threads:d 1 -threads:a 1
     -threads:v 1 -threads:s 1 -threads:t 1 -threads:#0 1
 only the OUTPUT codec 'thread_count' is getting set to 1 :
     @ffmpeg.c , line 2337:
                 codec  = ost->st->codec;
     (gdb) p ost->st->codec->thread_count
     $51 = 1
 but the INPUT codec still has a thread_count of 0, meaning that a number
 of threads equal to
 the number of CPU cores found will be used :
     (gdb) p ist->st->codec->thread_count
     $52 = 0

 This seems nonsensical ; why would one use 8 threads to extract one frame
 from the input stream
 for capture to a JPEG file ( the purpose of the transcode ) ?

 There appears to be no way to set the number of threads used for the input
 codec with
 command line arguments.

 A quick fix I'm going to adopt until you FFMPEG developers release a
 better fix is:
     if(  ocodec->thread_count // is non-zero
       && (ocodec->codec_id == AV_CODEC_ID_MJPEG)
       )  icodec->thread_count = ocodec->thread_count ;

 I'll test with this patch and post the results back here shortly.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/4901#comment:3>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list