Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#9367 closed defect (invalid)

H264 does NOT support slice multi threading mode

Reported by: Core_2_Extreme Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Core_2_Extreme)

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 supports only slice multi-threading,
mpeg4 supports 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 supports 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 supports 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

Attachments (1)

decoders.txt (29.3 KB ) - added by Core_2_Extreme 3 years ago.
Output for ffplay -decoders

Download all attachments as: .zip

Change History (8)

by Core_2_Extreme, 3 years ago

Attachment: decoders.txt added

Output for ffplay -decoders

comment:1 by Core_2_Extreme, 3 years ago

Description: modified (diff)

comment:2 by Core_2_Extreme, 3 years ago

Description: modified (diff)

comment:3 by Elon Musk, 3 years ago

Resolution: invalid
Status: newclosed

Sorry, but this is not page to ask support questions. This page is only for reporting bugs or requesting new features.

in reply to:  3 comment:4 by Core_2_Extreme, 3 years ago

Replying to richardpl:

Sorry, but this is not page to ask support questions. This page is only for reporting bugs or requesting new features.

ffmpeg says h264 supports multi-threading decoding, but it is not working, is it not bug?

comment:5 by mkver, 3 years ago

Priority: importantnormal

Slice multithreading depends upon the input being composed of multiple slices. For it to work you have to encode your file with multiple slices (use -slices).

in reply to:  5 comment:6 by Core_2_Extreme, 3 years ago

Replying to mkver:

Slice multithreading depends upon the input being composed of multiple slices. For it to work you have to encode your file with multiple slices (use -slices).

I encoded following command

ffmpeg.exe -i BigBuckBunny.mp4 -vcodec libx264 -preset ultrafast -s 3840x2160 -slices 8 -acodec copy 4k_slices.mp4

and played it following command then it worked.

ffplay.exe -thread_type slice -vcodec h264 4k_slices.mp4

https://i.gyazo.com/f11e7397f15921a8c7023308d9f1a707.png
Thank you so much.

comment:7 by Carl Eugen Hoyos, 3 years ago

Component: ffplayundetermined
Keywords: h264 thread slice removed
Note: See TracTickets for help on using tickets.