[FFmpeg-trac] #9367(ffplay:new): H264 does NOT support slice multi threading mode

FFmpeg trac at avcodec.org
Sat Aug 7 10:29:55 EEST 2021


#9367: H264 does NOT support slice multi threading mode
-------------------------------------+-------------------------------------
             Reporter:               |                     Type:  defect
  Core_2_Extreme                     |
               Status:  new          |                 Priority:  important
            Component:  ffplay       |                  Version:
             Keywords:  h264 thread  |  unspecified
  slice                              |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 H264 (software decoding not hardware decoding) does NOT support slice
 multi threading mode.

 {{{
 ffplay -decoders(or ffmpeg -decoders)
 }}}
 will print
 (full log is attached as decoders.txt)
 {{{
 Decoders:
  V..... = Video
  A..... = Audio
  S..... = Subtitle
  .F.... = Frame-level multithreading
  ..S... = Slice-level multithreading
  ...X.. = Codec is experimental
  ....B. = Supports draw_horiz_band
  .....D = Supports direct rendering method 1

 [...a lot of other codecs...]
 VFS..D h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
 [...a lot of other codecs...]
 V....D mjpeg                MJPEG (Motion JPEG)
 V.S.BD mpeg2video           MPEG-2 video
 VF..BD mpeg4                MPEG-4 part 2
 [...a lot of other codecs...]
 }}}
 It means h264 supports both of frame and slice multi-threading mode,
 mjpeg does not support multi-threading decoding at all,
 mpeg2video suports only slice multi-threading,
 mpeg4 suports only frame multi-threading, right?
 Please tell me if my understanding is not correct.

 After I encoded h264, mjpeg, mpeg2video and mpeg4 video following command,
 h264
 {{{
 ffmpeg.exe -i BigBuckBunny.mp4 -vcodec libx264 -preset ultrafast -s
 3840x2160 -acodec copy 4k.mp4
 }}}
 mjpeg
 {{{
 ffmpeg.exe -i BigBuckBunny.mp4 -vcodec mjpeg -s 3840x2160 -acodec copy
 4k_mjpeg.mp4
 }}}
 mpeg2video
 {{{
 ffmpeg.exe -i BigBuckBunny.mp4 -vcodec mpeg2video -s 3840x2160 -acodec
 copy 4k_mpeg2.mp4
 }}}
 mpeg4
 {{{
 ffmpeg.exe -i BigBuckBunny.mp4 -vcodec mpeg4 -s 3840x2160 -acodec copy
 4k_mpeg4.mp4
 }}}

 I played them following command.
 h264
 {{{
 //according to ffmpeg's output, h264 should support both of multi-
 threading decoding.
 ffplay.exe -thread_type frame -vcodec h264 4k.mp4
 ffplay.exe -thread_type slice -vcodec h264 4k.mp4
 ffplay.exe -thread_type none -vcodec h264 4k.mp4
 }}}

 mjpeg
 {{{
 //according to ffmpeg's output, mjpeg does not support multi-threading
 decoding but just test it.
 ffplay.exe -thread_type frame -vcodec mjpeg 4k_mjpeg.mp4
 ffplay.exe -thread_type slice -vcodec mjpeg 4k_mjpeg.mp4
 ffplay.exe -thread_type none -vcodec mjpeg 4k_mjpeg.mp4
 }}}
 mpeg2video
 {{{
 //according to ffmpeg's output, mpeg2video does not support frame multi-
 threading decoding but just test it.
 ffplay.exe -thread_type frame -vcodec mpeg2video 4k_mpeg2.mp4
 ffplay.exe -thread_type slice -vcodec mpeg2video 4k_mpeg2.mp4
 ffplay.exe -thread_type none -vcodec mpeg2video 4k_mpeg2.mp4
 }}}
 mpeg4
 {{{
 //according to ffmpeg's output, mpeg4 does not support slice multi-
 threading decoding but just test it.
 ffplay.exe -thread_type frame -vcodec mpeg4 4k_mpeg4.mp4
 ffplay.exe -thread_type slice -vcodec mpeg4 4k_mpeg4.mp4
 ffplay.exe -thread_type none -vcodec mpeg4 4k_mpeg4.mp4
 }}}

 Result
 note : I have 4C/8T CPU.

 mjpeg decoder always uses only one thread because it does not support
 multi-threading.
 mjpeg with -thread_type frame
 https://i.gyazo.com/3193f3ad3208bb1c840d541a789696a3.png
 mjpeg with -thread_type slice
 https://i.gyazo.com/58177227392095063fb130b52bc9a96d.png
 mjpeg with -thread_type none
 https://i.gyazo.com/6d067b4974b295de063a38fea80a13f0.png

 mpeg2video decoder uses more than one thread if I use -thread_type slice
 because it support slice multi-threading decoding.
 mpeg2video with -thread_type frame
 https://i.gyazo.com/ab12dcfab660ff336273e8177a3f7a04.png
 mpeg2video with -thread_type slice
 https://i.gyazo.com/c68a6f15688097e57204fc920fba1710.png
 mpeg2video with -thread_type none
 https://i.gyazo.com/4e4843f5ab6c351738b45f71c33f3d91.png

 mpeg4 decoder uses more than one thread if I use -thread_type frame
 because it support frame multi-threading decoding.
 mpeg4 with -thread_type frame
 https://i.gyazo.com/00c6f179b49ff88186cb56670d2a4b00.png
 mpeg4 with -thread_type slice
 https://i.gyazo.com/7ae61e671115e23f91bd53048615186a.png
 mpeg4 with -thread_type none
 https://i.gyazo.com/3a38115df57a2d5ecb7ce75d583ca863.png

 h264 decoder only uses more than one thread if I use -thread_type frame
 It should use more than one thread if I use -thread_type slice because it
 supports slice multi-threading.
 h264 with -thread_type frame
 https://i.gyazo.com/aebfefc49965c5fa4ee6d80f29150432.png
 h264 with -thread_type slice
 https://i.gyazo.com/a413ab024286dc2a9abee0b16263afb9.png
 h264 with -thread_type none
 https://i.gyazo.com/e5b444afc72f2696ed9c60329825aaa6.png
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9367>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list