View Full Version : How to use ffmpeg-mt in MPC?
Chengbin
20th September 2009, 01:56
Under output, I use Haali Renderer. Under internal filter, and H.264, it says I'm using ffmpeg-mt, with 4 threads.
ffdshow is set up correctly.
I have to force ffdshow video decoder under external filters to get it to work. I don't want to do that because I can't load an external subtitle under this mode.
I'm using the Crowdrun footage to do some test on my Q6600.
With single core (I don't know which decoder, probably libavcodec), I can get around 3fps. With ffmpeg-mt, I'm getting 100% CPU usage, but I'm only getting 1.5fps??? In ffdshow, under decoder options, I unchecked drop frame and skip H264 deblocking cause I thought that might drop fps. But nothing changed. Even with them unchecked, it still drop frames, unlike with the single core decoder.
Anybody have a clue?
shiloto
20th September 2009, 13:26
whats your windows?
What kind of files are you playing
Try using other renderer
LoRd_MuldeR
20th September 2009, 13:33
If MPC's "internal" H.264 decoder was compiled with libavcodec taken from "normal" FFmpeg repository instead of the "FFmpeg-MT" repository, then there is no way ;)
Of course you could always compile MPC yourself from the sources and make sure that the "FFmpeg-MT" libraries are used...
Chengbin
20th September 2009, 14:04
I use Windows Vista.
@LoRd_MuldeR
What MPC HC should I get? The latest MPC HC?
LoRd_MuldeR
20th September 2009, 14:09
What MPC HC should I get? The latest MPC HC?
I don't know if there are any pre-compiled MPC-HC builds publicly available that use multi-threaded libavcodec (FFmpeg-MT) for the "internal" decoders :confused:
Keep in mind that MPC-HC also has a DXVA decoder. So AFAIK if your GPU does support it, MPC-HC won't use the software decoder (libavcodec) for decoding H.264 at all.
At least not by default. You can disable the internal DXVA decoder of course and make it fall back to software decoding...
Chengbin
20th September 2009, 15:16
How do I get it to use ffmpeg-mt AND be able to load external subtitles?
Do you know why the MT decoder is 2x slower than the ST decoder?
LoRd_MuldeR
20th September 2009, 15:52
Again: Unless MPC-HC was compiled with multi-threaded libavcodec/ffmpeg (aka "FFmpeg-MT"), then there is no way to make it use FFmpeg-MT!
At least not for the built-in "internal" decoders. You can still use ffdshow with FFmpeg-MT as an "external" filter, of course...
clsid
20th September 2009, 16:20
The video decoder and the loading of subtitles are two unrelated things.
As LM has already said, disable the internal decoder and use ffdshow. Then you can use ffmpeg-mt instead of libavcodec.
LoRd_MuldeR
20th September 2009, 16:27
Then you can use ffmpeg-mt instead of libavcodec.
I think this statement can be confusing ;)
Just to make it clear: We don't use ffmpeg-mt instead of libavcodec. We always use the decoders provided by the "libavcodec" library, which is one part of the FFmpeg project.
However there now is the multi-threaded FFmpeg repository (aka "FFmpeg-MT") in addition to the normal/stable FFmpeg repository. They'll (hopefully) be merge at some point in the future.
Currently you must decided which flavor of the "libavcodec" library you link against your application, at compile-time. Well, ffdshow contains both of them, but most apps don't...
roozhou
20th September 2009, 19:43
Currently you must decided which flavor of the "libavcodec" library you link against your application, at compile-time. Well, ffdshow contains both of them, but most apps don't...
The only reason to use ffmpeg-mt is frame-level h264 decoding. You will have to replace a few files in libavcodec to make a ffmpeg-mt build.
clsid
20th September 2009, 19:44
The library names used in ffdshow are "libavcodec" and "ffmpeg-mt". I tried not to confuse him with details.
Chengbin
21st September 2009, 01:24
The video decoder and the loading of subtitles are two unrelated things.
As LM has already said, disable the internal decoder and use ffdshow. Then you can use ffmpeg-mt instead of libavcodec.
I can't load subtitles because I'm using a different renderer when I force ffdshow video decoder in external filters.
LoRd_MuldeR
21st September 2009, 01:31
Why is that? MPC-HC should always use the renderer you have selected under "Output" options, no matter what decoders (or more precisely: "transform" filters) are used.
So what renderer did you select? And which one is used instead if you force ffdshow?
Chengbin
21st September 2009, 02:36
Never mind, I take that back.
I don't know why I can't load subtitle before. It popped up a message to change renderer when I try to load an external subtitle.
The whole point of this thread was trying to play the Crowdrun footage on my PC. Apparently ffmpeg-mt is just really slow at decoding this particular video. I'm getting 0.3fps with ffmpeg-mt with 1 thread, but 3.5fps with libavcodec. Maybe it is not optimized for 50fps + UHD? With 1080p video the CPU usage is around the same.
Astrophizz
21st September 2009, 05:33
Why would ffmpeg-mt be any better than libavcodec with just one thread? Don't know why it's worse but the benefit of multithreading only comes when you allow it to use more than one thread, on multiple cores.
Chengbin
21st September 2009, 12:02
Why would ffmpeg-mt be any better than libavcodec with just one thread? Don't know why it's worse but the benefit of multithreading only comes when you allow it to use more than one thread, on multiple cores.
As I said before, ffmpeg-mt with 4 threads is less than half the speed of libavcodec with a single core :confused:
LoRd_MuldeR
21st September 2009, 12:06
How did you measure this? Please use TimeCodec (http://haali.cs.msu.ru/mkv/timeCodec.exe) to compare decoder performance!
The last time I did a comprision, the result was like this:
E:\HD\freedom EP1 sample.mkv, 1920x1080, High@L4.1
[ffdshow, rev2509, 4 threads]
User: 3s, kernel: 0s, total: 4s, real: 22s, fps: 142.8, dfps: 27.2
User: 3s, kernel: 0s, total: 4s, real: 22s, fps: 142.8, dfps: 27.2 <-- 100%
User: 3s, kernel: 0s, total: 4s, real: 25s, fps: 140.8, dfps: 24.2
[ffdshow, rev2527, Pre-Beta 6, 4 threads]
User: 3s, kernel: 0s, total: 4s, real: 22s, fps: 149.3, dfps: 27.5
User: 3s, kernel: 0s, total: 3s, real: 22s, fps: 155.2, dfps: 27.4 <-- 101%
User: 3s, kernel: 0s, total: 4s, real: 24s, fps: 147.1, dfps: 24.9
[ffdshow-MT, rev2515, 4 threads]
User: 2s, kernel: 0s, total: 2s, real: 8s, fps: 219.0, dfps: 68.7
User: 2s, kernel: 0s, total: 2s, real: 8s, fps: 252.7, dfps: 68.7 <-- 254%
User: 2s, kernel: 0s, total: 2s, real: 9s, fps: 220.2, dfps: 67.2
[CoreAVC, Version 1.8.5]
User: 0s, kernel: 0s, total: 0s, real: 7s, fps: 679.7, dfps: 82.3
User: 0s, kernel: 0s, total: 1s, real: 7s, fps: 616.0, dfps: 82.1 <-- 304%
User: 0s, kernel: 0s, total: 0s, real: 7s, fps: 691.6, dfps: 82.0
[DivX H.264 Decoder, Beta-3]
User: 1s, kernel: 0s, total: 1s, real: 6s, fps: 458.4, dfps: 88.4
User: 1s, kernel: 0s, total: 1s, real: 6s, fps: 512.0, dfps: 88.4 <-- 327%
User: 1s, kernel: 0s, total: 1s, real: 7s, fps: 499.0, dfps: 87.6
That means FFmpeg-MT actually is ~2.5x faster than the "normal" FFmpeg branch on my Quadcore machine ;)
(Note that "ffdshow-MT" was tested with FFmpeg-MT decoders, the "normal" ffdshow builds were using the Non-multithreded FFmpeg decoders)
Chengbin
21st September 2009, 21:06
ffmpeg-mt is roughly 4 times faster under threads 4 compared to thread 1.
My hypothesis was, maybe ffmpeg-mt was not optimized for UHD + 50fps video. ffmpeg-mt @ 4 threads = less than half of libavcodec.
1080p video and under, ffmpeg-mt @ 1 thread = libavcodec.
LoRd_MuldeR
22nd September 2009, 12:40
My hypothesis was, maybe ffmpeg-mt was not optimized for UHD + 50fps video. ffmpeg-mt @ 4 threads = less than half of libavcodec.
Again: How did you measure this? Did you use TimeCodec.exe and did you set the renderer to Null? If not, please re-do the test!
I just did a quick test with the "Crowdrun" video (3840x2160 @ 50fps) and ffdshow r3078:
[ffdshow, using "normal" libavcodec]
User: 5s, kernel: 3s, total: 8s, real: 74s, fps: 55.6, dfps: 6.7 <-- 100%
[ffdshow, using "FFmpeg-MT" libavcodec, 4 threads]
User: 5s, kernel: 0s, total: 5s, real: 34s, fps: 86.6, dfps: 14.5 <-- 216%
[DivX H.264 decoder]
User: 3s, kernel: 0s, total: 4s, real: 28s, fps: 124.2, dfps: 17.7 <-- 264%
;)
Chengbin
22nd September 2009, 21:19
Where can I get TimeCodec.exe?
rack04
22nd September 2009, 21:25
Where can I get TimeCodec.exe?
http://forum.doom9.org/showthread.php?p=1327503#post1327503
LoRd_MuldeR
22nd September 2009, 21:25
Where can I get TimeCodec.exe?
Find the hyperlink in this (http://forum.doom9.org/showpost.php?p=1327503&postcount=17) post ;)
Arrrrg, rack04 was faster :D
Chengbin
22nd September 2009, 23:45
User: 3s, kernel: 0s, total: 3s, real: 35s, fps: 126.7, dfps: 14.3
I am definitely not getting 14.3fps on MPC-HC with ffmpeg-mt. I'm getting like 1 fps to my eyes.
LoRd_MuldeR
22nd September 2009, 23:53
I am definitely not getting 14.3fps on MPC-HC with ffmpeg-mt. I'm getting like 1 fps to my eyes.
If you are talking about MPC-HC's internal decoders, they probably use the "normal" libavcodec, not FFmpeg-MT.
Use ffdshow (by disabling the "internal" decoder) and make sure it is configured to use the "FFmpeg-MT" decoders for H.264 video.
If you still get low fps then, the bottleneck is elsewhere! Maybe the renderer, maybe postproc filters enabled in ffdshow...
her34
23rd September 2009, 00:11
How did you measure this? Please use TimeCodec (http://haali.cs.msu.ru/mkv/timeCodec.exe) to compare decoder performance!
The last time I did a comprision, the result was like this:
E:\HD\freedom EP1 sample.mkv, 1920x1080, High@L4.1
[ffdshow, rev2509, 4 threads]
User: 3s, kernel: 0s, total: 4s, real: 22s, fps: 142.8, dfps: 27.2
User: 3s, kernel: 0s, total: 4s, real: 22s, fps: 142.8, dfps: 27.2 <-- 100%
User: 3s, kernel: 0s, total: 4s, real: 25s, fps: 140.8, dfps: 24.2
[ffdshow, rev2527, Pre-Beta 6, 4 threads]
User: 3s, kernel: 0s, total: 4s, real: 22s, fps: 149.3, dfps: 27.5
User: 3s, kernel: 0s, total: 3s, real: 22s, fps: 155.2, dfps: 27.4 <-- 101%
User: 3s, kernel: 0s, total: 4s, real: 24s, fps: 147.1, dfps: 24.9
[ffdshow-MT, rev2515, 4 threads]
User: 2s, kernel: 0s, total: 2s, real: 8s, fps: 219.0, dfps: 68.7
User: 2s, kernel: 0s, total: 2s, real: 8s, fps: 252.7, dfps: 68.7 <-- 254%
User: 2s, kernel: 0s, total: 2s, real: 9s, fps: 220.2, dfps: 67.2
[CoreAVC, Version 1.8.5]
User: 0s, kernel: 0s, total: 0s, real: 7s, fps: 679.7, dfps: 82.3
User: 0s, kernel: 0s, total: 1s, real: 7s, fps: 616.0, dfps: 82.1 <-- 304%
User: 0s, kernel: 0s, total: 0s, real: 7s, fps: 691.6, dfps: 82.0
[DivX H.264 Decoder, Beta-3]
User: 1s, kernel: 0s, total: 1s, real: 6s, fps: 458.4, dfps: 88.4
User: 1s, kernel: 0s, total: 1s, real: 6s, fps: 512.0, dfps: 88.4 <-- 327%
User: 1s, kernel: 0s, total: 1s, real: 7s, fps: 499.0, dfps: 87.6
That means FFmpeg-MT actually is ~2.5x faster than the "normal" FFmpeg branch on my Quadcore machine ;)
(Note that "ffdshow-MT" was tested with FFmpeg-MT decoders, the "normal" ffdshow builds were using the Non-multithreded FFmpeg decoders)
Do you have an atom cpu you can test your video on?
Of course it'll be much slower, but I'm curious exactly how it would compare
LoRd_MuldeR
23rd September 2009, 00:15
Do you have an atom cpu you can test your video on?
Nope. Just my Core2 Quad Q6600. But on an Atom machine you probably will be better off with a decoder that lets the GPU do the work :p
Chengbin
23rd September 2009, 03:09
If you are talking about MPC-HC's internal decoders, they probably use the "normal" libavcodec, not FFmpeg-MT.
Use ffdshow (by disabling the "internal" decoder) and make sure it is configured to use the "FFmpeg-MT" decoders for H.264 video.
If you still get low fps then, the bottleneck is elsewhere! Maybe the renderer, maybe postproc filters enabled in ffdshow...
CPU usage was 100% with ffmpeg-mt as the decoder.
I have no preprocessing on.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.