View Full Version : Curious: why isn't AAC encoding using 100% cpu?
Redsandro
17th November 2009, 17:24
A simple question to which I cannot find the answer..
Why is audio encoding in for example NeroAacEnc.exe only using about 20-30% of my quad core? According to my cpu usage monitor it is using all cores somewhat.
In the same line of curiosity, x264 x86 uses ~60% and x264 x64 uses ~90%. What up with not using 100%? It's not like there's a bottleneck in HD reading. Especially when encoding audio.
DJ Bobo
17th November 2009, 18:44
20 to 30% sounds like 25% average, so I would say, this is because the nero encoder uses only one of the four cores (not multithreaded). What your CPU monitor shows is irrelevant.
Redsandro
17th November 2009, 18:47
That would be stupid of Nero. Do you know another aac encoder that can accept multi channel STDIN?
One that does use multiple cores?
-edit-
BTW, wrong forum, but x264 x86's 60%, it uses 2 cores? I though x264 was pretty optimised.
Inspector.Gadget
17th November 2009, 19:12
Use foobar2000 with Nero instead; it'll run as many files concurrently as you have cores.
Redsandro
17th November 2009, 19:37
Foobar is great, but I need something that takes STDIN for my encode script.
MatLz
17th November 2009, 19:53
Foobar has an avs script input plugin.
Inventive Software
17th November 2009, 23:53
In answer to the original question... because it doesn't need it? :confused:
Or are you really complaining that it's not fast enough? ¬_¬
Redsandro
17th November 2009, 23:58
Wrong answer. It doesn't need it when it has nothing to do.
Ofcourse it doesn't really take forever but yeah I'm complaining that I need to buy a computer 5 times as fast as I want the encoder to run. what's next, buying 5 gigs of memory for every 1 you need?
Inspector.Gadget
18th November 2009, 00:16
Why not just write a meta-script and call four of your existing scripts per instance?
Edit: I mean for four separate sources, of course; this won't help you when you only have, for instance, one clip's audio to transcode.
Redsandro
18th November 2009, 00:33
That is clever. But in this case I am indeed looking for a single clip's encode.
When I make the audio to a long video project, I like to transcode and mux my changes often for preview on tv. If it can take 2 minutes in stead of 8 that's ofcourse a welcome gain (to answer InventiveSoftware).
That's why I was looking into other encoders just now, but I don't really like faac and I haven't found other encoders with similar quality, STDIN support and ofcourse better usage of my processor.
thewebchat
18th November 2009, 01:08
Look, what's so hard about just running the damn thing 4 times? If you only have one file, you can just use Trim() or something to break it into 4 parts and then concatenate them later.
Redsandro
18th November 2009, 01:20
What's up with your tone? If participating in discussions like this is bad for your bloodpressure, I advise you to stay away.
In reply to the rest, I don't think you can bluntly split an encode in 4 pieces and seamlessly mux them without plops and gaps.
Second, vbscript does not have methods for launching multiple threads.
thewebchat
18th November 2009, 01:58
Sure you can. I've been doing this for ages. Since you have to decode to PCM before you encode, you automatically have sample-level accuracy. As long as you use unaligned splices, you are guaranteed to get every sample out that you put in. If you're really paranoid about it, you can use a framerate of 48000 fps and do aligned splices. Also, there is no threading involved, you only have to call neroAacEnc.exe 4 times (this is what foobar2000 does). Also, what's with your tone?
Redsandro
18th November 2009, 02:15
Okay, you probably know. I thought compressed audio was made out of chunks that aren't necessarily frame accurate. I thought that's why demuxing mpeg often leaves you with a delay. Really, that's what I thought. Can be wrong.
But assuming so, still, calling NeroAacEnc 4 times sounds like 4 threads to me, I wouldn't know how to arrange that from a script or commandline.
About my tone, since when is a question an answer?
thewebchat
18th November 2009, 02:59
Compressed audio is stored in chunks, but to encode it, you have to decompress those chunks anyway. That's why you can just cut and recombine your audio as you see fit. This is the same idea as compressed video. You can't cut a video at a B-frame directly, but when you encode it, you can just decode all the frames from the previous I-frame and start display at the frame you want. You could, for example, exec neroAacEnc and then put it in the background, then exec as many more as you need. This should be possible in VB, shouldn't it?
Redsandro
18th November 2009, 03:24
Interesting.
Yes you can exec separate programs in vbscript but there is no director function that keeps track of them or another easy way to know when they are done AFAIK.
How would you combine the 4, do you have a script or command line program for that? Or is it a foobar internal function?
thewebchat
18th November 2009, 03:29
Once you have four MP4s with each segment, you can just append them with whatever program you like. Perhaps mkvmerge would be easiest. foobar2000 doesn't break files up, it only encodes multiple files at once (and I think the task monitoring works by scanning the STDOUT output of neroAacEnc).
Redsandro
18th November 2009, 03:34
That easy? Who would have thought.
Unfortunately in this case, for monitoring stdout of 4 programs vbscript would require 4 parallel worker threads and it doesn't work that way. Vbscript's power is more like MSX-Basic than like Python.
thewebchat
18th November 2009, 03:53
Then, for a cruder approach, couldn't you monitor the process list and loop until the PIDs of the encoder tasks you started are no longer present? This is all assuming that VB doesn't pause while the tasks are executing, of course.
Redsandro
18th November 2009, 04:09
I could do that in python/linux, but I haven't got a clue on if that's even possible in vbscript and if it can list processes in Windows or even know the PIDs of the programs it exec'ed.
Thanks for your suggestions, but the amount of effort I would have to do to figure out how to do it without knowing it's even possible makes me want to find an encoder that doesn't require the user to do the workaround patchwork to support 'modern' (7 year old) hardware. My NeroAacEnc sais it's last updated in 2007. I guess you can't really complain if a commercial business releases a free tool.
thewebchat
18th November 2009, 04:17
Dunno, I find it hard to care when the "workaround" is so trivial. Besides, if they implemented threading, they would just be doing this internally, so I don't see what the big deal is.
More importantly, if you can't monitor the actual processes by PID, can't you just count the number of neroAacEncs running at script start, exec the ones you need, then exit your loop when the number of neroAacEncs falls below the number at the beginning? This might fail in interesting ways, but it should be easy even with VBnet. Or, maybe you can see if the MP4 outputs you write have active handles on them, and then terminate when they are no longer being written.
If you can't do any of those, then I guess your only option is to encode 4 movies at once. Or perhaps you could install Python for Windows.
Edit: It seems that you can't find the PID of the process you started, but you can find the process list like here (http://www.computerperformance.co.uk/vbscript/wmi_process.htm).
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.