Minimize CPU use with QuickSync?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Minimize CPU use with QuickSync?

Jason Coleman
Hello,


I recently picked up a computer with a Kaby Lake processesor, and I'm trying to setup ffmpeg transcodes to minimize impact to the CPU and maximize use of QuickSync during transcodes. I am going by indirect indicators (CPU use and GPU use, as indicated in the Windows 10 task manager) + what ffmpeg output says. I thought I had the entire pipeline (decode/scale-resize/encode) being performed by Quicksync, but I'm still getting a lot of CPU use, call it 70-90%. Maybe my expectations are out of line and I need to adjust those? Am I missing anything that would cause operations to happen on the CPU instead? I'm currently using a zeranoe 64 bit build, on Win10 home, with the current Intel drivers. So this is an example encoding line, I don't have an output from ffmpeg in front of me, apologies, I can put one up later:


C:\ffmpeg\ffmpeg.exe -hwaccel qsv -init_hw_device qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv -i "testvid.mp4" -vf "format=nv12,hwupload=extra_hw_frames=100,scale_qsv=640:360" -b:v 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"


Thank you!

Jason


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Minimize CPU use with QuickSync?

Moritz Barsnick
Hi Jason,

On Thu, Jun 28, 2018 at 20:49:01 +0000, Jason Coleman wrote:
> but I'm still getting a lot of CPU use, call it 70-90%.
[...]
> C:\ffmpeg\ffmpeg.exe -hwaccel qsv -init_hw_device qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv -i "testvid.mp4" -vf "format=nv12,hwupload=extra_hw_frames=100,scale_qsv=640:360" -b:v 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"

I tried to reproduce this, with similar results regarding CPU. What I
noticed is that I get this message, but unfortunately only if I choose
a higher loglevel:

> [AVHWFramesContext @ 0000020ba2ce18c0] Error opening the internal VPP session.Surface upload/download will not be possible

I assume that this is the issue. I don't know what to do about it
though. Others should be able to pitch in.

Please check if you have the same issue (by adding "-loglevel verbose"
to your ffmpeg command line), and play around with that.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Minimize CPU use with QuickSync?

Li, Zhong
In reply to this post by Jason Coleman
> -----Original Message-----
> From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> Jason Coleman
> Sent: Friday, June 29, 2018 4:49 AM
> To: [hidden email]
> Subject: [FFmpeg-user] Minimize CPU use with QuickSync?
>
> Hello,
>
>
> I recently picked up a computer with a Kaby Lake processesor, and I'm trying
> to setup ffmpeg transcodes to minimize impact to the CPU and maximize use
> of QuickSync during transcodes. I am going by indirect indicators (CPU use
> and GPU use, as indicated in the Windows 10 task manager) + what ffmpeg
> output says. I thought I had the entire pipeline (decode/scale-resize/encode)
> being performed by Quicksync, but I'm still getting a lot of CPU use, call it
> 70-90%.

This is not an "entire" Quciksync pipeline as your command line below.
You are using a software decoder output to system memory, then upload as qsv surface and use qsv to do scaling and encoding.
So high CPU usage is normal IMHO.

Maybe my expectations are out of line and I need to adjust those?

> Am I missing anything that would cause operations to happen on the CPU
> instead? I'm currently using a zeranoe 64 bit build, on Win10 home, with the
> current Intel drivers. So this is an example encoding line, I don't have an
> output from ffmpeg in front of me, apologies, I can put one up later:
>
>
> C:\ffmpeg\ffmpeg.exe -hwaccel qsv -init_hw_device
> qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv -i "testvid.mp4" -vf
> "format=nv12,hwupload=extra_hw_frames=100,scale_qsv=640:360" -b:v
> 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"

Is there any reason to use software decoder? If no, you can try to add "-c:v h264_qsv" to specify qsv decoder (then "-init_hw_device qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv" is not necessary, and also remove "hwupload"):
C:\ffmpeg\ffmpeg.exe -hwaccel qsv -c:v h264_qsv -i "testvid.mp4" -vf
"scale_qsv=640:360" -b:v 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"

<I haven't set up QSV on windows yet. If this doesn't work, please let me know>

>
> Thank you!
>
> Jason

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Minimize CPU use with QuickSync?

Jason Coleman
I didn't have a specific reason to utilize the software decoder. I didn't realize I still was. In retrospect, it makes sense that I would have to specify the decoder as well, I'd chalk it up to lack of familiarity with how ffmpeg works. I made the changes you suggested, which really makes for a much simpler looking command, so that's nice. I had built my command based on information I scraped together doing a lot of reading of out-dated posts and a lot of searching online.


In any event, I'm still seeing around 20% CPU usage, but I'm not sure from where, but I'm really pleased with the change because on the GPU end, I'm seeing around 75% utilization now, and in particular where my transcode was running around 4x before, it's running around 16x now, so that's fantastic. I'm not 100% sure that the CPU usage isn't just from more network overhead from everything running so much faster.


I've also run into the occasional file that fails to transcode because it looks like something in the stream is breaking the QS decoder, actually. Some entries on the ffmpeg bug list suggest it's a problem in how QuickSync is handling some frame types? Anyway, different problem, but I'm keeping my original line around as well, so that for the files I have problems with, I can switch back to the software decoder.


Thank you, that was very helpful!




________________________________
From: ffmpeg-user <[hidden email]> on behalf of Li, Zhong <[hidden email]>
Sent: Thursday, July 5, 2018 10:16 AM
To: FFmpeg user questions
Subject: Re: [FFmpeg-user] Minimize CPU use with QuickSync?

> -----Original Message-----
> From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> Jason Coleman
> Sent: Friday, June 29, 2018 4:49 AM
> To: [hidden email]
> Subject: [FFmpeg-user] Minimize CPU use with QuickSync?
>
> Hello,
>
>
> I recently picked up a computer with a Kaby Lake processesor, and I'm trying
> to setup ffmpeg transcodes to minimize impact to the CPU and maximize use
> of QuickSync during transcodes. I am going by indirect indicators (CPU use
> and GPU use, as indicated in the Windows 10 task manager) + what ffmpeg
> output says. I thought I had the entire pipeline (decode/scale-resize/encode)
> being performed by Quicksync, but I'm still getting a lot of CPU use, call it
> 70-90%.

This is not an "entire" Quciksync pipeline as your command line below.
You are using a software decoder output to system memory, then upload as qsv surface and use qsv to do scaling and encoding.
So high CPU usage is normal IMHO.

Maybe my expectations are out of line and I need to adjust those?

> Am I missing anything that would cause operations to happen on the CPU
> instead? I'm currently using a zeranoe 64 bit build, on Win10 home, with the
> current Intel drivers. So this is an example encoding line, I don't have an
> output from ffmpeg in front of me, apologies, I can put one up later:
>
>
> C:\ffmpeg\ffmpeg.exe -hwaccel qsv -init_hw_device
> qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv -i "testvid.mp4" -vf
> "format=nv12,hwupload=extra_hw_frames=100,scale_qsv=640:360" -b:v
> 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"

Is there any reason to use software decoder? If no, you can try to add "-c:v h264_qsv" to specify qsv decoder (then "-init_hw_device qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv" is not necessary, and also remove "hwupload"):
C:\ffmpeg\ffmpeg.exe -hwaccel qsv -c:v h264_qsv -i "testvid.mp4" -vf
"scale_qsv=640:360" -b:v 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"

<I haven't set up QSV on windows yet. If this doesn't work, please let me know>

>
> Thank you!
>
> Jason

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-user&data=02%7C01%7C%7Cb58e54fea58f40ec236d08d5e281e5b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636663969882315767&sdata=vRxhXHOVaXgENTrMgvm80cBn9teXXtBwbHoSHM7HjLs%3D&reserved=0

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Minimize CPU use with QuickSync?

Li, Zhong
> -----Original Message-----
> From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> Jason Coleman
> Sent: Friday, July 6, 2018 11:33 PM
> To: FFmpeg user questions <[hidden email]>
> Subject: Re: [FFmpeg-user] Minimize CPU use with QuickSync?
>
> I didn't have a specific reason to utilize the software decoder. I didn't realize
> I still was. In retrospect, it makes sense that I would have to specify the
> decoder as well, I'd chalk it up to lack of familiarity with how ffmpeg works. I
> made the changes you suggested, which really makes for a much simpler
> looking command, so that's nice. I had built my command based on
> information I scraped together doing a lot of reading of out-dated posts and
> a lot of searching online.
>
>
> In any event, I'm still seeing around 20% CPU usage, but I'm not sure from
> where, but I'm really pleased with the change because on the GPU end, I'm
> seeing around 75% utilization now, and in particular where my transcode was
> running around 4x before, it's running around 16x now, so that's fantastic.
> I'm not 100% sure that the CPU usage isn't just from more network overhead
> from everything running so much faster.

Glad to see it works. There are still some tasks are done by CPU
(e.g, video muxer, demuxer, audio copy, video frame header parser for qsv decoder, video frame header generated in qsv encoder and so on).

>
> I've also run into the occasional file that fails to transcode because it looks
> like something in the stream is breaking the QS decoder, actually. Some
> entries on the ffmpeg bug list suggest it's a problem in how QuickSync is
> handling some frame types? Anyway, different problem, but I'm keeping my
> original line around as well, so that for the files I have problems with, I can
> switch back to the software decoder.

If you find any clips can't be decoded by QSV decoder, please file a bug on https://trac.ffmpeg.org/ 

>
> Thank you, that was very helpful!
>
>
>
>
> ________________________________
> From: ffmpeg-user <[hidden email]> on behalf of Li,
> Zhong <[hidden email]>
> Sent: Thursday, July 5, 2018 10:16 AM
> To: FFmpeg user questions
> Subject: Re: [FFmpeg-user] Minimize CPU use with QuickSync?
>
> > -----Original Message-----
> > From: ffmpeg-user [mailto:[hidden email]] On Behalf
> Of
> > Jason Coleman
> > Sent: Friday, June 29, 2018 4:49 AM
> > To: [hidden email]
> > Subject: [FFmpeg-user] Minimize CPU use with QuickSync?
> >
> > Hello,
> >
> >
> > I recently picked up a computer with a Kaby Lake processesor, and I'm
> > trying to setup ffmpeg transcodes to minimize impact to the CPU and
> > maximize use of QuickSync during transcodes. I am going by indirect
> > indicators (CPU use and GPU use, as indicated in the Windows 10 task
> > manager) + what ffmpeg output says. I thought I had the entire
> > pipeline (decode/scale-resize/encode) being performed by Quicksync,
> > but I'm still getting a lot of CPU use, call it 70-90%.
>
> This is not an "entire" Quciksync pipeline as your command line below.
> You are using a software decoder output to system memory, then upload as
> qsv surface and use qsv to do scaling and encoding.
> So high CPU usage is normal IMHO.
>
> Maybe my expectations are out of line and I need to adjust those?
> > Am I missing anything that would cause operations to happen on the CPU
> > instead? I'm currently using a zeranoe 64 bit build, on Win10 home,
> > with the current Intel drivers. So this is an example encoding line, I
> > don't have an output from ffmpeg in front of me, apologies, I can put one
> up later:
> >
> >
> > C:\ffmpeg\ffmpeg.exe -hwaccel qsv -init_hw_device
> > qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv -i "testvid.mp4" -vf
> > "format=nv12,hwupload=extra_hw_frames=100,scale_qsv=640:360" -b:v
> 800k
> > -c:v h264_qsv -c:a copy -y "testoutput.mp4"
>
> Is there any reason to use software decoder? If no, you can try to add "-c:v
> h264_qsv" to specify qsv decoder (then "-init_hw_device
> qsv=qsv:MFX_IMPL_hw_any -filter_hw_device qsv" is not necessary, and
> also remove "hwupload"):
> C:\ffmpeg\ffmpeg.exe -hwaccel qsv -c:v h264_qsv -i "testvid.mp4" -vf
> "scale_qsv=640:360" -b:v 800k -c:v h264_qsv -c:a copy -y "testoutput.mp4"
>
> <I haven't set up QSV on windows yet. If this doesn't work, please let me
> know>
>
> >
> > Thank you!
> >
> > Jason
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fffmpe
> g.org%2Fmailman%2Flistinfo%2Fffmpeg-user&data=02%7C01%7C%7Cb58e
> 54fea58f40ec236d08d5e281e5b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa
> %7C1%7C0%7C636663969882315767&sdata=vRxhXHOVaXgENTrMgvm80cB
> n9teXXtBwbHoSHM7HjLs%3D&reserved=0
>
> To unsubscribe, visit link above, or email [hidden email]
> with subject "unsubscribe".
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email [hidden email]
> with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".