Slashdot Mirror


Which Open Source Video Apps Use SMP Effectively?

ydrol writes "After building my new Core 2 Quad Q6600 PC, I was ready to unleash video conversion activity the likes of which I had not seen before. However, I was disappointed to discover that a lot of the conversion tools either don't use SMP at all, or don't balance the workload evenly across processors, or require ugly hacks to use SMP (e.g. invoking distributed encoding options). I get the impression that open source projects are a bit slow on the uptake here? Which open source video conversion apps take full native advantage of SMP? (And before you ask, no, I don't want to pick up the code and add SMP support myself, thanks.)"

44 of 262 comments (clear)

  1. ffmpeg by bconway · · Score: 5, Informative

    Use the -threads switch.

    --
    Interested in open source engine management for your Subaru?
    1. Re:ffmpeg by morgan_greywolf · · Score: 5, Informative

      Similarly, mencoder supports threads=# where # is something between 1 and 8.

    2. Re:ffmpeg by sp332 · · Score: 3, Informative

      And it may or may not be useful to actually rune more than one thread per kernel. It depends on the encoder and application how many threads you shall run, so the best is to test with 1, 2 and 4 threads per kernel.

      Isn't that per-core, not per-kernel?

    3. Re:ffmpeg by mweather · · Score: 5, Informative

      Apple computers ARE PCs. They coined the damn term.

    4. Re:ffmpeg by m0rph3us0 · · Score: 4, Informative

      No it doesn't the only time you want to use multi-threading in a single CPU environment is because asynchronous methods for IO are unavailable or the code would be too difficult to re-architect to use asynchronous IO. If the application is seriously IO bound threads can even make the situation worse by causing random IO patterns.

      Ideally, the number of threads a program uses should be no more than the number of processors available. Otherwise, you are wasting time context switching instead of processing.

    5. Re:ffmpeg by i.r.id10t · · Score: 2, Informative

      Yup, with separate disks to work on to remove (mostly) the disk i/o contention, just let each process run happily away.

      --
      Don't blame me, I voted for Kodos
    6. Re:ffmpeg by ydrol · · Score: 4, Informative
      Darn, I forgot a minor detail in my question. I was really asking about the various front-end apps (dvd::rip, k9copy, acidrip etc), I got the impression that none seem to notice they are running on an SMP platform and pass the necessary switches by default to the backend.

      Some may argue this is a good thing, but for the time being SMP is the way forward for faster processing as MHz has maxed out, in consumer PCS. So when they start buying octo-core CPUs they dont expect it to run at 1/8th speed by default.

      I was also being a bit lazy. I could have checked up on each app in turn, but I asked /. instead.

    7. Re:ffmpeg by Anonymous Coward · · Score: 3, Informative

      If thread 1 is doing work while thread 2 is blocked (io, semaphores, etc), then multithreading will be faster.

    8. Re:ffmpeg by sexconker · · Score: 2, Informative

      If you're making another copy of it to play on another device (format shifting or whatever bullshit term they used), yeah, you can probably get sued for it if some asshat wants to target you.

      Illegal? No.
      Wrong? Hell no.

      My point is that encoding apps often exist separately from editing apps (such as FCP). This is due in large part to piracy, especially when talking about free/open encoders and sites like doom9.
      Pirates are not concerned with editing/creating, they're concerned with copying and converting/compressing. Likewise, the writers of such tools/interfaces are concerned with pleasing a certain crowd of people...

      I was calling FCP trash in terms of a converter/encoder. It's much more geared toward editing. Thus, I think the ACs mention of FCP in this conext is not very pertinent.

    9. Re:ffmpeg by VGPowerlord · · Score: 4, Informative

      True, but in most contexts, "PC" is the shortened form of IBM-compatible PC (which is really outdated), and is usually just stands for Windows these days.

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    10. Re:ffmpeg by elgaard · · Score: 2, Informative

      I have not tried it. But e.g. k9copy uses mencoder.
      So if you just put something like "x264ops=threads=auto" in you mencoder.conf file it might work also from k9copy.
      k9copy also have a settings menu where you can tune options to mencoder for various codecs.

    11. Re:ffmpeg by SimonTheSoundMan · · Score: 2, Informative

      Yeah, Compressor is pretty damn good. It doesn't just use all your cores, but it can also distribute the workload to other machines on a network. Whole render farms.

      Logic Node is somewhat better, however it only does audio, we have two eight core Mac pro's and three Xserv machines in our studio. The Xserve machines will be binned when the new version of Logic Pro supporting GPU processing the audio is out.

    12. Re:ffmpeg by networkBoy · · Score: 3, Informative

      I hit I/O throttling when I do the following:
      * rip 2 dvds (two DVDR Drives)
      * transcoding previous DVD rips to XVID
      * Moving completed rips to server over 1 Gbps Ethernet link.

      At this point I can see CPU load start to drop as PCI bus I/O saturates.

      At no point do I hit disk I/O or memory limits.
      Disks are non-RAID non-striped, but rips are to separate disks (thus DVDA rips to HDA DVDB to HDB) and server upload pulls from whatever disk is not currently transcoding (transcode file on HDA, when done start transcode on HDB and move file from HDA).
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    13. Re:ffmpeg by MadnessASAP · · Score: 4, Informative

      If I may offer a suggestion, I'm not too sure on what your setup is but on mine I have 2 DVD drives each on separate IDE buses and 2 SATA drives (also on separate buses) rip from the DVD to drive 1 and encode from drive 1 to 2. OF course it all depends on a variety of factors but using that certainly helped that.

      --
      I may agree with what you say, but I will defend to the death your right to face the consequences of saying it.
    14. Re:ffmpeg by Nikker · · Score: 4, Informative

      Running multiple cores with an ide interface is going to kill you regardless because you are only encoding in memory not really storing much there. Basically you have a cap of about 40MB/s for anything larger than about 40MB.

      --
      A loop, by its nature, continues. If that didn't make sense, start reading this sentence again.
    15. Re:ffmpeg by ksheff · · Score: 5, Informative

      That's the point. If the xvid encoder is single threaded, then to keep all the cores busy, one must run multiple instances of ffmpeg with each one encoding a different file. For the given Makefile, that is what make will do when the -j switch is used.

      --
      the good ground has been paved over by suicidal maniacs
    16. Re:ffmpeg by QuoteMstr · · Score: 3, Informative

      You're still missing the OP's point. Let me spell it out for you:

      Say you have four videos to encode, and four cores.

      1) You can either use one core at a time and encode one video at a time. Let's say that takes time T.
      2) You can encode one video at a time, but use all four cores while doing it. Your total time is T/4.
      3) You can encode four videos at a time, one on each core. Your total time is T/4.

      The OP was advocating strategy #3. It's a fine approach.

  2. transcode, of course! by morgan_greywolf · · Score: 5, Informative

    transocde uses separate processes for everything.

  3. VisualHub... by e4g4 · · Score: 3, Informative

    ...makes excellent use of multiple cores. It is however Mac-only. Interestingly, what it does is split a file into chunks and spawns multiple ffmpeg processes to do the conversion. Which is to say, perhaps you can do some (relatively simple) scripting with ffmpeg that will do the job.

    --
    The secret to creativity is knowing how to hide your sources. - Albert Einstein
  4. x264 and avisynth by PhrostyMcByte · · Score: 2, Informative

    x264 and avisynth can make pretty decent use of threads. check out meGUI.

  5. Beat me to it! by BLKMGK · · Score: 4, Informative

    x264 via meGUI from Doom9 is what I use to compress HD-DVD and BD movies - also on a quad core. I have some tutorials posted out and about on how I'm doing it. Near as I can tell you cannot dupe the process on Linux due to the crypto - Slysoft's AnyDVD-HD is needed.

    Playback - I use XBMC for Linux. It is also SMP enabled using the ffmpeg cabac patch. the developers of this project have been VERY aggressive at taking cutting edge improvements to the likes of ffmpeg and incorporating them into the code. Since Linux has no video acceleration of H.264 SMP really helps on high bitrate video!

    --
    Build it, Drive it, Improve it! Hybridz.org
  6. Re:Which part of Open Source didn't you get? by phuul · · Score: 2, Informative
    So is ffmpeg not open source? It uses the LGPL license and from their license FAQ:

    "FFmpeg is licensed under the GNU Lesser General Public License (LGPL). However, FFmpeg incorporates several optional modules that are covered by the GNU General Public License (GPL), notably libpostproc and libswscale. If those parts get used the GPL applies to all of FFmpeg. Read the license texts to learn how this affects programs built on top of FFmpeg or reusing FFmpeg. You may also wish to have a look at the GPL FAQ. "

    Since his suggestion was to do some scripting that does essentially what VisualHub does using ffmpeg I'm not sure I see how he missed the Open Source requirement.

  7. Handbrake by vfs · · Score: 5, Informative

    Handbrake has always used both of the cores on my system for transcoding.

    1. Re:Handbrake by Anonymous Coward · · Score: 1, Informative

      Handbrake has always used both of the cores on my system for transcoding.

      ... and is only good for transcoding DVDs. Sure it's nice and simple for that one thing, but I assume the submitter wants more than that.

    2. Re:Handbrake by catmistake · · Score: 4, Informative

      that's because Handbrake uses ffmpeg

    3. Re:Handbrake by crmarvin42 · · Score: 2, Informative

      It's good for Video_TS folders in general. In fact, a handful of DVD's can't be ripped directly from the disk using handbrake and need to be copied to HD via something like MacTheRipper before being transcoded by Handbrake. I don't know what format the guy is trying to transcode from, but most people only need to transcode DVD's.

      --
      Bureaucracy expands to meet the needs of the expanding bureaucracy.-Oscar Wilde
    4. Re:Handbrake by Anonymous Coward · · Score: 1, Informative

      Handbrake uses x264, though you can use ffmpeg if you want. And Handbrake can take as many cores as you want to throw at it...

  8. Re:Which part of Open Source didn't you get? by pushing-robot · · Score: 4, Informative

    OP is asking for open source tools. You cited a commercial one that doesn't provide source.

    VisualHub (the front-end app) may be closed, but ffmpeg is LGPL.

    And the GP was suggesting using ffmpeg, not VisualHub.

    --
    How can I believe you when you tell me what I don't want to hear?
  9. Re:Simple... by j00r0m4nc3r · · Score: 5, Informative

    Running multiple instances of the same code concurrently in multiple threads is simple. Even running mutually exclusive parts of the same code concurrently in separate threads is easy. Converting complex serial algorithms to effectively utilize multiple cores is generally not simple. And writing code that can scale and balance across n number of cores/threads is extremely hard. There are all sorts of synchronization issues to deal with, scheduling issues, data transport issues, etc.. and it becomes increasingly hard to debug code the more cores/threads you throw in. I think the stigma is justified.

  10. Re:F(next) = F(current) + Delta(F(current:next)) by Lumenary7204 · · Score: 2, Informative

    Note that the above example is about the video component only of a single MPEG audio/video stream.

    There is no reason that an encoder/decoder can't process audio in one thread and video in another, thereby using more than one core (which has already been discussed in other posts relating to this article).

  11. keyframes by Anonymous Coward · · Score: 5, Informative

    Actually, the MPEG stream resets itself every n frames or so (n is often a number like 8, but can vary depending on the video content). These are called keyframes (K) and the delta frames (called P and I frames) are generated against them. Because of this, it is really easy to apply parallel processing to video encoding.

    1. Re:keyframes by DigitAl56K · · Score: 4, Informative

      Actually, the MPEG stream resets itself every n frames or so (n is often a number like 8, but can vary depending on the video content).

      That is not true for MPEG-4 unless you have specifically constrained the I/IDR interval to an extremely short interval, and doing so severely impacts the efficiency of the encoder because I-frames are extremely expensive compared to other types.

      Keyframes are usually inserted when temporal prediction fails for some percentage of blocks, or using some RD evaluation based on the cost of encoding the frame. Therefore unless the encoder has reached the maximum key interval the I frame position requires that motion estimation is performed, and thus you can't know in advance where to start a new GOP.

      In H.264 due to multiple references you would certainly have issues to contend with since long references might cross I-frame boundaries, which is why there is the distinction of "IDR" frames, and this would certainly not be possible threading at keyframe level.

      Granted, for MPEG1&2 encoders threading at keyframes is a possibility, although still not one I'd personally favor.

    2. Re:keyframes by TwinkieStix · · Score: 3, Informative

      This may be true for sending entire frames to threads, but in mpeg4, frames are broken up into chunks. Motion vectors are created that allow these chunks to move about the image from frame to frame. Other filters are used to remove blockiness, compress the image, do motion detection and macroblock detection, and do various other tasks. MPEG4, especially H.264, can be easily multi-threaded: http://ietisy.oxfordjournals.org/cgi/content/abstract/E88-D/7/1623 http://adsabs.harvard.edu/abs/2004SPIE.5308..384L http://www.electronicsweekly.com/Articles/2007/05/02/41296/aspex-targets-parallel-processor-at-blu-ray-dvd.htm When doing a two-pass encode, this is even easier because the keyframes are discovered on the first (faster) pass, so (if encoding already couldn't be threaded) it could by taking advantage of the known keyframe markers in at least the second pass. But, that's not necessary. I use handbrake to create H.264 videos under Linux all the time on my dual core machine, and both processors stay between 80%-90% utilization from start to finish regardless of the number of passes.

    3. Re:keyframes by srw · · Score: 2, Informative

      Slight correction: in MPEG, the keyframes are called I-Frames. The delta frames are B and P frames. Most MPEG2 encoders that I have used default to a 15 frame GOP.

    4. Re:keyframes by Anonymous Coward · · Score: 1, Informative

      These are called keyframes (K) and the delta frames (called P and I frames) are generated against them.

      This is essentially correct, but a little bit off in the terminology. The keyframes are called Intra-coded (I) frames. The delta frames are called Predictive-coded (P) or Bidirectionally-predictive-coded (B) frames depending on whether or not they depend on frames from the future.

  12. Re:F(next) = F(current) + Delta(F(current:next)) by Zygfryd · · Score: 2, Informative

    http://en.wikipedia.org/wiki/Group_of_pictures

    You can encode GOPs independently. I think the only dependency between GOP encoding processes is bit allocation, which probably works well enough if you simply assign each process an equal share of the total bit budget.

  13. Windows? VirtualDub 1.8.x + ffdshow-tryouts by tdelaney · · Score: 3, Informative

    You don't say if you're running on Windows or Linux or something else. If you are running on Windows, the latest versions of VirtualDub have made big improvements to SMT/SMP encoding.

    VirtualDub home
    VirtualDub 1.8.1 announcement
    VirtualDub downloads

    Make sure you grab 1.8.3 - 1.8.1 was pretty good, but had a few teething problems. 1.8.2 has a major regression which is fixed in 1.8.3. The comments in the 1.8.1 announcement contain a few important tips for using the new features (some of which I posted BTW).

    The two major new features that would be of interest to you are:

    1. You can run all VirtualDub processing in one thread, and the codec in another. This works very well in conjunction with a multi-threaded codec - this one change improved my CPU utilitisation from approx 75% to 95% on my dual-core machines - with an equivalent increase in encoding performance.

    2. VD now has simple support for distributed encoding. You can use a shared queue across either multiple instances of VD on a single machine, or across multiple machines (must use UNC paths for multiple machines). Each instance of VD will pick the next job in the queue when it finishes its current job. Instances can be started in slave mode (in which case they will automatically start processing the queue).

    I use 3 machines for encoding (all dual-core). With VD 1.8.x I start VD on two of the machines in slave mode, and one in master mode. I add jobs to the queue on the master instance, and the other two instances immediately pick up the new jobs and start encoding. When I've added all the jobs, I then start the master instance working on the job queue.

    To achieve a similar effect on your quad-code, start two instances of VD on the same machine - one slave, the other master.

    It's not perfect (if you've only got one job, you won't use your maximum capacity) but it has greatly simplified my transcoding tasks, and reduced the time to transcode large numbers of files.

  14. avidemux by Unit3 · · Score: 5, Informative

    I've noticed a lot of talk about commandline options, but not the nice guis that use them. Avidemux is open source, cross-platform, gives you a decent interface, and uses multithreaded libraries like ffmpeg and x264 on the backend to do the encoding, so it generally makes optimal use of your multicore system.

    --
    -- sudo.ca
  15. Do more jobs rather than one job more quickly by myz24 · · Score: 1, Informative

    As posted elsewhere, it is difficult to divide a project up that is really pretty linear. Instead, you should try to do more jobs at once. Encode four videos at once.

  16. Re:Simple... by sexconker · · Score: 2, Informative

    How the hell is this modded interesting (as opposed to informative)?

    Do people really not know this stuff (thus making it interesting to them)?

    For the gp and the others who still don't get it.

    Multi-threaded programming (getting your shit to run in separate threads) is easy, now.
    Multi-threaded / distributed algorithms (getting your shit to do some coherent, useful shit while scaling well) are not easy at all.

  17. heroinewarrior.com by heroine · · Score: 2, Informative

    The version of Cinelerra from heroinewarrior.com uses SMP. It's highly dependant on the supporting libraries & who implemented the feature. In the worst case, use renderfarm mode & nodes for each processor. Sometimes the libraries work in SMP mode & sometimes they don't. Sometimes the feature was intended for everyone to use on any number of processors & sometimes it was written for 1 person's cheap single processor.

  18. Re:F(next) = F(current) + Delta(F(current:next)) by foxyshadis · · Score: 2, Informative

    Several implementations of this exist: For x264, there's x264farm (which includes network encoding as well).

  19. AcidRip patches by ydrol · · Score: 2, Informative

    Cheers. I also found these Acidrip patches. PS In case anyone missed it, I really meant to ask about the front end GUI/script tools rather than the engines. PPS I'm actually using Mandriva.

  20. Re:Use Mac OS X... by Anonymous Coward · · Score: 3, Informative

    But Mac users have been living with SMP since 2001

    Just for reference:

    UNIX System V R4-MP 1993
    Windows NT 1993
    OS/2 2.11 1993
    Linux 2.0 1996