working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,066 snippets matching: hardware

    public by p.kontalis  3263  1  5  0

    Retrieve System Characteristics

    Windows System Information Function
    Public Function RetrievePCInfo() As DataTable
        Dim DT As New DataTable
        DT.Columns.Add("Class")
        DT.Columns.Add("Name")
        DT.Columns.Add("Value")
        Dim search3 As New ManagementObjectSearcher("SELECT * FROM meta_class")
        Dim info3 As New ManagementObject
        For Each info3 In search3.Get
            Dim search4 As New ManagementObjectSearcher("SELECT * FROM " & info3("__CLASS").ToString)
            Dim Squerysearch4 As String = search4.Query.QueryString.ToString
            Dim info4 As New ManagementObject
            For Each info4 In search4.Get
                For Each Prop As PropertyData In info4.Properties
                    DT.Rows.Add(info3("__CLASS").ToString, Prop.Name, Prop.Value)
                Next
            Next
        Next
        Return DT
    End Function
    
    ' Beware this of code requires a large amount of RAM.
    ' Recommended to Extract all classes first and then for each class retieve the values.
    ' info class from motherboard is Win32_Bios
    ' info class from CPU is Win32_Prosessor

    public by lbottaro  2656  8  6  2

    How to detect your computer's RAM configuration via cmd prompt

    Using this simple WMI (Windows Management Instrumentation) command you can see how your RAM is configured on your pc. The output shows how many banks are used and their capacity. Output: Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\wmic MEMORYCHIP get banklabel, devicelocator, caption, capaci
    C:\>wmic MEMORYCHIP get banklabel, devicelocator, caption, capacity

    public by Hardware  1315  0  3  0

    Prewikka init.d script

    Prewikka init.d script: prewikka.sh
    #!/bin/bash
    
    # Variables couleurs
    CSI="\033["
    CEND="${CSI}0m"
    CGREEN="${CSI}1;32m"
    
    # PID du processus
    PID=$(netstat -tlnp | awk '/:8000 */ {split($NF,a,"/"); print a[1]}')
    
    # PYTHONPATH
    export PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/bin/prewikka-httpd
    
    start() {
    
      echo -n "Starting Prewikka..."
      /usr/bin/prewikka-httpd &
      echo -e " ${CGREEN}[OK]${CEND}"
    
    }
    
    stop() {
    
      echo -n "Stopping Prewikka..."
      kill -9 $PID
      echo -e " ${CGREEN}[OK]${CEND}"
    
    }
    
    status() {
    
      if [[ $PID -gt 0 ]]; then
        echo -e "Prewikka is running ${CGREEN}[OK]${CEND}"
      else
        echo "Prewikka is not running..."
      fi
    
    }
    
    case "$1" in
    start)
      start
      ;;
    stop)
      stop
      ;;
    restart)
      stop
      start
      ;;
    status)
      status
      ;;
    *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
      ;;
    esac
    
    exit 0
    
    

    public by msdn  1175  0  6  0

    ConvertHwIdToDevDic: Convert serialized hardwareId to well formed HardwareId structures so that it can be easily consumed.

    Convert serialized hardwareId to well formed HardwareId structures so that it can be easily consumed.
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Security.Cryptography;
    using System.Security.Cryptography.Pkcs;
    using System.Security.Cryptography.X509Certificates;
    using System.Text;
    using System.Web.Http;
    using CSWindowsStoreAppDeviceService.Properties;
    using CSWindowsStoreAppDeviceService.Models;
    using Security.Cryptography;
    
    /// <summary>
    /// Convert serialized hardwareId to well formed HardwareId structures so that 
    /// it can be easily consumed. 
    /// </summary>
    /// <param name="hardwareId"></param>
    /// <returns></returns>
    private static IDictionary<int, List<string>> ConvertHwIdToDevDic(Byte[] hardwareId)
    {
        var hardwareIdString = BitConverter.ToString(hardwareId).Replace("-", "");
        // make the empty Device Dictionary data structure
        var deviceDic = new Dictionary<int, List<string>>
            {
                {0, new List<string>()}, // Invalid
                {1, new List<string>()}, // Processor
                {2, new List<string>()}, // Memory
                {3, new List<string>()}, // Disk Device
                {4, new List<string>()}, // Network Adapter
                {5, new List<string>()}, // Audio Adapter
                {6, new List<string>()}, // Docking Station
                {7, new List<string>()}, // Mobile Broadband
                {8, new List<string>()}, // Bluetooth
                {9, new List<string>()}, // System BIOS
            };
    
        for (var i = 0; i < hardwareIdString.Length / 8; i++)
        {
            switch (hardwareIdString.Substring(i * 8, 4))
            {
                case "0100": // Processor
                    deviceDic[1].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0200": // Memory
                    deviceDic[2].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0300": // Disk Device
                    deviceDic[3].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0400": // Network Adapter
                    deviceDic[4].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0500": // Audio Adapter
                    deviceDic[5].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0600": // Docking Station
                    deviceDic[6].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0700": // Mobile Broadband
                    deviceDic[7].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0800": // Bluetooth
                    deviceDic[8].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
                case "0900": // System BIOS
                    deviceDic[9].Add(hardwareIdString.Substring(i * 8 + 4, 4));
                    break;
            }
        }
    
        return deviceDic;
    }

    external by SLOLNE  137  0  2  0

    a simple processing particle sketch to accompany our hardware. Its not in conversation with the hardware, but ideally would be so that when the person walks by the sensor they make a physical and digital painting simultaneously.

    a simple processing particle sketch to accompany our hardware. Its not in conversation with the hardware, but ideally would be so that when the person walks by the sensor they make a physical and digital painting simultaneously. : Silver Spray Paint on Canvas
    This code is from the example section on Prosessing.org
    It is authored by: Daniel Shiffman
    I just changed the background colour from balck to white and made the window a little larger. 
    
    ArrayList<ParticleSystem> systems;
    
    void setup() {
      size(900, 660);
      systems = new ArrayList<ParticleSystem>();
    }
    
    void draw() {
      background(255);//made this white to better fit our concept
      for (ParticleSystem ps: systems) {
        ps.run();
        ps.addParticle();
      }
      if (systems.isEmpty()) {
        fill(305);//made this silver
        textAlign(CENTER);
        text("click mouse to add particle systems", width/2, height/2);
      }
    }
    
    void mousePressed() {
      systems.add(new ParticleSystem(1, new PVector(mouseX, mouseY)));
    }
    
    
    
    // An ArrayList is used to manage the list of Particles
    
    class ParticleSystem {
    
      ArrayList<Particle> particles;    // An arraylist for all the particles
      PVector origin;                   // An origin point for where particles are birthed
    
      ParticleSystem(int num, PVector v) {
        particles = new ArrayList<Particle>();   // Initialize the arraylist
        origin = v.get();                        // Store the origin point
        for (int i = 0; i < num; i++) {
          particles.add(new Particle(origin));    // Add "num" amount of particles to the arraylist
        }
      }
    
    
      void run() {
        // Cycle through the ArrayList backwards, because we are deleting while iterating
        for (int i = particles.size()-1; i >= 0; i--) {
          Particle p = particles.get(i);
          p.run();
          if (p.isDead()) {
            particles.remove(i);
          }
        }
      }
    
      void addParticle() {
        Particle p;
        // Add either a Particle or CrazyParticle to the system
        if (int(random(0, 2)) == 0) {
          p = new Particle(origin);
        } 
        else {
          p = new CrazyParticle(origin);
        }
        particles.add(p);
      }
    
      void addParticle(Particle p) {
        particles.add(p);
      }
    
      // A method to test if the particle system still has particles
      boolean dead() {
        return particles.isEmpty();
      }
    }
    
    
    
    // A subclass of Particle
    
    class CrazyParticle extends Particle {
    
      // Just adding one new variable to a CrazyParticle
      // It inherits all other fields from "Particle", and we don't have to retype them!
      float theta;
    
      // The CrazyParticle constructor can call the parent class (super class) constructor
      CrazyParticle(PVector l) {
        // "super" means do everything from the constructor in Particle
        super(l);
        // One more line of code to deal with the new variable, theta
        theta = 0.0;
      }
    
      // Notice we don't have the method run() here; it is inherited from Particle
    
      // This update() method overrides the parent class update() method
      void update() {
        super.update();
        // Increment rotation based on horizontal velocity
        float theta_vel = (velocity.x * velocity.mag()) / 10.0f;
        theta += theta_vel;
      }
    
      // This display() method overrides the parent class display() method
      void display() {
        // Render the ellipse just like in a regular particle
        super.display();
        // Then add a rotating line
        pushMatrix();
        translate(location.x,location.y);
        rotate(theta);
        stroke(105,lifespan);//changed
        line(0,0,25,0);
        popMatrix();
      }
    
    }
    
    
    
    // A simple Particle class
    
    class Particle {
      PVector location;
      PVector velocity;
      PVector acceleration;
      float lifespan;
    
      Particle(PVector l) {
        acceleration = new PVector(0,0.05);
        velocity = new PVector(random(-1,1),random(-2,0));
        location = l.get();
        lifespan = 255.0;
      }
    
      void run() {
        update();
        display();
      }
    
      // Method to update location
      void update() {
        velocity.add(acceleration);
        location.add(velocity);
        lifespan -= 2.0;
      }
    
      // Method to display
      void display() {
        stroke(255,lifespan);
        fill(255,lifespan);
        ellipse(location.x,location.y,8,8);
      }
    
      // Is the particle still useful?
      boolean isDead() {
        return (lifespan < 0.0);
      }
    
    }
    
    
    

    external by cmbiwer  251  0  3  0

    Quick follow up of hardware injections SNR time series.

    Quick follow up of hardware injections SNR time series.: run_hwinj_snr_timeseries_followup.sh
    #!/bin/bash
    
    # quick follow up of hardware injections SNR time series
    # pycbc v1.3.4 and lalsuite v6.36
    
    set -e
    
    # injection options
    INJECTION_TIME=1134345930.46611
    INJECTION_PREFIX=coherentbbh10_1128678894
    
    # make output dir
    HTML_DIR=/home/cbiwer/public_html/hwinj_single_tmplt/${INJECTION_TIME}_${INJECTION_PREFIX}
    mkdir -p ${HTML_DIR}
    
    # get SVN with waveform information
    svn co https://daqsvn.ligo-la.caltech.edu/svn/injection/hwinj/Details/Inspiral/
    
    # get parameters from XML file
    INJECTION_FILE=Inspiral/${INJECTION_PREFIX}.xml
    MASS1=`lwtprint -t sim_inspiral -c mass1 ${INJECTION_FILE}`
    MASS2=`lwtprint -t sim_inspiral -c mass2 ${INJECTION_FILE}`
    SPIN1Z=`lwtprint -t sim_inspiral -c spin1z ${INJECTION_FILE}`
    SPIN2Z=`lwtprint -t sim_inspiral -c spin2z ${INJECTION_FILE}`
    
    # get start and end time for matched filtering executable
    INJECTION_TIME_INT=${INJECTION_TIME%.*}
    GPS_START_TIME=$((${INJECTION_TIME_INT} - 1024))
    GPS_END_TIME=$((${INJECTION_TIME_INT} + 1024))
    
    # match filter
    CHANNEL_NAME=L1:GDS-CALIB_STRAIN
    FRAME_TYPE=L1_HOFT_C00
    OUTPUT_FILE=L1-SINGLE_TEMPLATE.hdf
    pycbc_single_template --segment-end-pad   16   --segment-length   256 \
    --low-frequency-cutoff   30   --pad-data   8   --sample-rate   4096 \
    --segment-start-pad   112   --psd-segment-stride   8   --psd-inverse-length 16 \
    --psd-segment-length   16   --processing-scheme   mkl   --approximant SEOBNRv2_ROM_DoubleSpin \
    --psd-estimation   median   --strain-high-pass   20 \
    --order   -1   --chisq-bins  16    --channel-name ${CHANNEL_NAME} \
    --output-file   ${OUTPUT_FILE} \
    --mass1 ${MASS1} --mass2 ${MASS2} --spin1z ${SPIN1Z} --spin2z ${SPIN2Z} \
    --gps-start-time   ${GPS_START_TIME} --gps-end-time   ${GPS_END_TIME} --verbose \
    --frame-type ${FRAME_TYPE}
    
    # plot SNR time seires
    IMG_FILE=${HTML_DIR}/L1-SINGLE_TEMPLATE-100MS.png
    pycbc_single_template_plot --window 0.10 \
    --single-template-file ${OUTPUT_FILE} \
    --output-file ${IMG_FILE} \
    --event-time ${INJECTION_TIME}
    
    # plot SNR time series
    IMG_FILE=${HTML_DIR}/L1-SINGLE_TEMPLATE-10S.png
    pycbc_single_template_plot --window 10 \
    --single-template-file ${OUTPUT_FILE} \
    --output-file ${IMG_FILE} \
    --event-time ${INJECTION_TIME}
    
    # match filter
    CHANNEL_NAME=H1:GDS-CALIB_STRAIN
    FRAME_TYPE=H1_HOFT_C00
    OUTPUT_FILE=H1-SINGLE_TEMPLATE.hdf
    pycbc_single_template --segment-end-pad   16   --segment-length   256 \
    --low-frequency-cutoff   30   --pad-data   8   --sample-rate   4096 \
    --segment-start-pad   112   --psd-segment-stride   8   --psd-inverse-length 16 \
    --psd-segment-length   16   --processing-scheme   mkl   --approximant SEOBNRv2_ROM_DoubleSpin \
    --psd-estimation   median   --strain-high-pass   20 \
    --order   -1   --chisq-bins  16    --channel-name ${CHANNEL_NAME} \
    --output-file   ${OUTPUT_FILE} \
    --mass1 ${MASS1} --mass2 ${MASS2} --spin1z ${SPIN1Z} --spin2z ${SPIN2Z} \
    --gps-start-time   ${GPS_START_TIME} --gps-end-time   ${GPS_END_TIME} --verbose \
    --frame-type ${FRAME_TYPE}
    
    # plot SNR time series
    IMG_FILE=${HTML_DIR}/H1-SINGLE_TEMPLATE-100MS.png
    pycbc_single_template_plot --window 0.10 \
    --single-template-file ${OUTPUT_FILE} \
    --output-file ${IMG_FILE} \
    --event-time ${INJECTION_TIME}
    
    # plot SNR time series
    IMG_FILE=${HTML_DIR}/H1-SINGLE_TEMPLATE-10S.png
    pycbc_single_template_plot --window 10 \
    --single-template-file ${OUTPUT_FILE} \
    --output-file ${IMG_FILE} \
    --event-time ${INJECTION_TIME}
    
    

    external by Mirco Babini  991  9  3  0

    HardwareBackButtonManager Service for Ionic (Angular.js) provides an interface to easily enable or disable the hardware back button on Android

    HardwareBackButtonManager Service for Ionic (Angular.js) provides an interface to easily enable or disable the hardware back button on Android: Angular.Ionic.HardwareBackButtonManager.js
    .service( 'HardwareBackButtonManager', function($ionicPlatform){
      this.deregister = undefined;
    
      this.disable = function(){
        this.deregister = $ionicPlatform.registerBackButtonAction(function(e){
            if( true ){
                e.preventDefault();
                return false;
            }
        }, 101);
      }
    
      this.enable = function(){
        if( this.deregister !== undefined ){
          this.deregister();
          this.deregister = undefined;
        }
      }
      return this;
    })
    
    // usage
    .controller( 'YourController', function( 'HardwareBackButtonManager' ){
    	HardwareBackButtonManager.disable();
    	
    	// re-enable it when you want,
    	HardwareBackButtonManager.enable();
    })
    
    

    external by Brainiarc7  632  5  3  0

    FFMpeg's playbook: Advanced encoding options with hardware-accelerated acceleration for both NVIDIA NVENC's and Intel's VAAPI-based hardware encoders in both ffmpeg and libav.

    FFMpeg's playbook: Advanced encoding options with hardware-accelerated acceleration for both NVIDIA NVENC's and Intel's VAAPI-based hardware encoders in both ffmpeg and libav.: ffmppeg-advanced-playbook-nvenc-and-libav-and-vaapi.md
    FFmpeg and libav's playbook: Advanced encoding options with hardware-based acceleration, NVIDIA's NVENC and Intel's VAAPI-based encoder.
    ------------------------------------------------------------------------
    
    Hello guys,
    
    Continuing from [this guide to building ffmpeg and libav with NVENC and VAAPI enabled](https://gist.github.com/Brainiarc7/95c9338a737aa36d9bb2931bed379219), this snippet will cover advanced options that you can use with ffmpeg and libav on both NVENC and VAAPI hardware-based encoders.
    
    
    **For ffmpeg:**
    
    As usual, we supply the usual arguments when we want to encode with *VAAPi*-based encoders:
    
        ffmpeg -loglevel debug -vaapi_device /dev/dri/renderD128 -i input_file -vf 'format=nv12,hwupload' -threads 8 -aspect 16:9 -y -f matroska -acodec copy -vcodec h264_vaapi -qp 19 -bf 2 "output_file"
    
    **For libav:**
    
    Libav takes its' arguments in a slightly different way. For both ffmpeg and libav, refer to [this](https://gist.github.com/Brainiarc7/95c9338a737aa36d9bb2931bed379219) on what these arguments do. If you're already familiar with both pipelines, carry on.
    
        avconv -v 55 -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i "input_file" -c:a copy -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi -bf 2 -b 12500k "output_file"
    
    **Trying *two-pass* with the *h264_vaapi* encoder:**
    
        ffmpeg -loglevel debug -vaapi_device /dev/dri/renderD128 -i "input_file" -vf 'format=nv12,hwupload' -pass 1 -map 0:0 -map 0:1 -threads 8 -aspect 16:9 -y -f matroska -an -c:v h264_vaapi -b 7.5M "/dev/null"
        
        ffmpeg -loglevel debug -vaapi_device /dev/dri/renderD128 -i "input_file" -vf 'format=nv12,hwupload' -pass 2 -map 0:0 -map 0:1 -threads 8 -aspect 16:9 -y -f matroska -acodec copy -c:v h264_vaapi -b 7.5M "output_file"
    
    **And with *NVENC*:**
    
    NVENC's *h264* and *h265_nvenc* based encoders natively support two-pass encoding, and this should be pretty straight-forward:
    
        ffmpeg -loglevel debug  -i "input_file" -c:v h264_nvenc -preset llhq -profile:v high -rc ll_2pass_quality -an -b:v 2.4M -pass 1 -2pass -1 "output_file"
        
        ffmpeg -loglevel debug  -i "input_file" -c:v h264_nvenc -preset llhq -profile:v high -rc ll_2pass_quality -acodec copy -b:v 2.4M -pass 2 -2pass -1 -y "output_file"
    
    Note the syntax order:
    
    (a). The first will always be **ffmpeg** (the binary name in the system path or absolute path to ffmpeg depending on your deployment). 
    
    (b). The second should be an *option passed directly to ffmpeg*, such as a debug value (if needed).  
    
    (c). **-i**: Here is your input file's absolute path. If you are already in the path relative to the file's position, then use that relative path. The same applies to the output video too. 
    
    (d). **-c:v** : Use this to select the encoder. In the example above, we have selected h264_nvenc. 
    
    (e). **-preset**: Some video and audio encoders will support the preset argument. In the case where both the video and the audio codec support the same argument, such as this, then wrap this argument with a declaration, as shown: -preset:v would apply for the video encoder whereas -preset:a would apply for the audio encoder. 
    
    (f). Here, *pass absolute options to the video encoder.* In the example above, we are passing -rc (the rate control factor) recognized by the *h264_nvenc* encoder, and selecting the
    *low-latency, 2-pass quality rate control factor* as we are doing a *two-pass high quality* encode. You will also notice that we have passed the *-profile:v* option to the video encoder (h264_nvenc) to select the *high quality preset*. 
    
    (g). ***-acodec*:** Use this to select the audio encoder to use. In our case, we are copying the audio as is and we don't re-encode. 
    
    (h). ***-b:v***: This selects a video bitrate. In our example, we have selected a 2.4 MB/s variable bitrate by default, as the nvenc_h264 encoder uses variable rate encoding unless its' explicitly disabled (via the *-cbr* option that enforces *constant-rate encoding*).
    
    **Optional arguments:**
    
    (a)**.-c:a** copy copies the audio stream
    
    (b)**.-f**: Selects the container format to use. This can be MP4, Matroska, etc. Select whatever suits you, and take note of container restrictions.
    
    
    **Formats (muxers and demuxers):**
    
    List all supported formats in your ffmpeg build:
    
        ffmpeg -formats
    
    Display options specific to, and information about, a particular *muxer*:
    
        ffmpeg -h muxer=matroska
    
    Display options specific to, and information about, a particular *demuxer*:
    
        ffmpeg -h demuxer=matroska
    
    **Codecs (encoders and decoders):**
    
    List all supported codecs in your ffmpeg build:
    
        ffmpeg -codecs
    
    List all supported encoders in your ffmpeg build:
    
        ffmpeg -encoders
    
    List all available decoders in your ffmpeg build:
    
        ffmpeg -decoders
    
    Display options specific to, and information about, a particular *encoder*:
    
        ffmpeg -h encoder=mpeg4
    
    Display options specific to, and information about, a particular *decoder:*
    
        ffmpeg -h decoder=aac
    
    **Reading the results**
    
    There is a key near the top of the output that describes each letter that precedes the name of the format, encoder, decoder, or codec:
    
        $ ffmpeg -encoders
        […]
        Encoders:
         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
         ------
        […]
         V.S... mpeg4                MPEG-4 part 2
    
    In this example V.S... indicates that the encoder mpeg4 is a Video encoder and supports *Slice-level multithreading.*
    
    
    **Miscellaneous:**
    
    See advanced nvenc encoder options in ffmpeg:
    
        ffmpeg -h encoder=nvenc_h264
    
        Encoder nvenc_h264 [NVIDIA NVENC H.264 encoder]:
            General capabilities: delay 
            Threading capabilities: none
            Supported pixel formats: yuv420p nv12 yuv444p
        nvenc_h264 AVOptions:
          -preset            <int>        E..V.... Set the encoding preset (from 0 to 11) (default medium)
             default                      E..V.... 
             slow                         E..V.... hq 2 passes
             medium                       E..V.... hq 1 pass
             fast                         E..V.... hp 1 pass
             hp                           E..V.... 
             hq                           E..V.... 
             bd                           E..V.... 
             ll                           E..V.... low latency
             llhq                         E..V.... low latency hq
             llhp                         E..V.... low latency hp
             lossless                     E..V....
             losslesshp                   E..V....
          -profile           <int>        E..V.... Set the encoding profile (from 0 to 3) (default main)
             baseline                     E..V.... 
             main                         E..V.... 
             high                         E..V.... 
             high444p                     E..V.... 
          -level             <int>        E..V.... Set the encoding level restriction (from 0 to 51) (default auto)
             auto                         E..V.... 
             1                            E..V.... 
             1.0                          E..V.... 
             1b                           E..V.... 
             1.0b                         E..V.... 
             1.1                          E..V.... 
             1.2                          E..V.... 
             1.3                          E..V.... 
             2                            E..V.... 
             2.0                          E..V.... 
             2.1                          E..V.... 
             2.2                          E..V.... 
             3                            E..V.... 
             3.0                          E..V.... 
             3.1                          E..V.... 
             3.2                          E..V.... 
             4                            E..V.... 
             4.0                          E..V.... 
             4.1                          E..V.... 
             4.2                          E..V.... 
             5                            E..V.... 
             5.0                          E..V.... 
             5.1                          E..V.... 
          -rc                <int>        E..V.... Override the preset rate-control (from -1 to INT_MAX) (default -1)
             constqp                      E..V.... Constant QP mode
             vbr                          E..V.... Variable bitrate mode
             cbr                          E..V.... Constant bitrate mode
             vbr_minqp                    E..V.... Variable bitrate mode with MinQP
             ll_2pass_quality              E..V.... Multi-pass optimized for image quality (only for low-latency presets)
             ll_2pass_size                E..V.... Multi-pass optimized for constant frame size (only for low-latency presets)
             vbr_2pass                    E..V.... Multi-pass variable bitrate mode
          -surfaces          <int>        E..V.... Number of concurrent surfaces (from 0 to INT_MAX) (default 32)
          -cbr               <boolean>    E..V.... Use cbr encoding mode (default false)
          -2pass             <boolean>    E..V.... Use 2pass encoding mode (default auto)
          -gpu               <int>        E..V.... Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on. (from -2 to INT_MAX) (default any)
             any                          E..V.... Pick the first device available
             list                         E..V.... List the available devices
          -delay             <int>        E..V.... Delay frame output by the given amount of frames (from 0 to INT_MAX) (default INT_MAX)
    
    
    See advanced h264_vaapi options:
    
        ffmpeg -h encoder=h264_vaapi
    
        Encoder h264_vaapi [H.264/AVC (VAAPI)]:
            General capabilities: delay 
            Threading capabilities: none
            Supported pixel formats: vaapi_vld
        h264_vaapi AVOptions:
          -qp                <int>        E..V.... Constant QP (for P-frames; scaled by qfactor/qoffset for I/B) (from 0 to 52) (default 20)
          -quality           <int>        E..V.... Set encode quality (trades off against speed, higher is faster) (from 0 to 8) (default 0)
          -low_power         <int>        E..V.... Use low-power encoding mode (experimental: only supported on some platforms, does not support all features) (from 0 to 1) (default 0)
    
    
    
    
    
    
    
    
    

    external by JJ  477  1  3  0

    A simple Arduino driver for the NEC (Japanese) Infrared IR protocol. Drive an IR LED direct with your own code. This is a direct pin bit-bang approach, so beware about interrupts and timing difference between hardware. Feel free to use hardware PWM to...

    A simple Arduino driver for the NEC (Japanese) Infrared IR protocol. Drive an IR LED direct with your own code. This is a direct pin bit-bang approach, so beware about interrupts and timing difference between hardware. Feel free to use hardware PWM to generate the carrier frequency if you want better accuracy.: Arduino-IR-TX-NEC
    //*****************************************
    // NEC (Japanese) Infrared code sending library for the Arduino
    // Send a standard NEC 4 byte protocol direct to an IR LED on the define pin
    // Assumes an IR LED connected on I/O pin to ground, or equivalent driver.
    // Tested on a Freetronics Eleven Uno compatible
    // Written by David L. Jones www.eevblog.com
    // Youtube video explaining this code: http://www.youtube.com/watch?v=BUvFGTxZBG8
    // License: Creative Commons CC BY
    //*****************************************
    
    #define IRLEDpin  2              //the arduino pin connected to IR LED to ground. HIGH=LED ON
    #define BITtime   562            //length of the carrier bit in microseconds
    //put your own code here - 4 bytes (ADDR1 | ADDR2 | COMMAND1 | COMMAND2)
    unsigned long IRcode=0b11000001110001111100000000111111;  
    
    // SOME CODES:
    // Canon WL-D89 video remote START/STOP button = 0b11000001110001111100000000111111
    
    void setup()
    {
    }
    
    void IRsetup(void)
    {
      pinMode(IRLEDpin, OUTPUT);
      digitalWrite(IRLEDpin, LOW);    //turn off IR LED to start
    }
    
    // Ouput the 38KHz carrier frequency for the required time in microseconds
    // This is timing critial and just do-able on an Arduino using the standard I/O functions.
    // If you are using interrupts, ensure they disabled for the duration.
    void IRcarrier(unsigned int IRtimemicroseconds)
    {
      for(int i=0; i < (IRtimemicroseconds / 26); i++)
        {
        digitalWrite(IRLEDpin, HIGH);   //turn on the IR LED
        //NOTE: digitalWrite takes about 3.5us to execute, so we need to factor that into the timing.
        delayMicroseconds(9);          //delay for 13us (9us + digitalWrite), half the carrier frequnecy
        digitalWrite(IRLEDpin, LOW);    //turn off the IR LED
        delayMicroseconds(9);          //delay for 13us (9us + digitalWrite), half the carrier frequnecy
        }
    }
    
    //Sends the IR code in 4 byte NEC format
    void IRsendCode(unsigned long code)
    {
      //send the leading pulse
      IRcarrier(9000);            //9ms of carrier
      delayMicroseconds(4500);    //4.5ms of silence
      
      //send the user defined 4 byte/32bit code
      for (int i=0; i<32; i++)            //send all 4 bytes or 32 bits
        {
        IRcarrier(BITtime);               //turn on the carrier for one bit time
        if (code & 0x80000000)            //get the current bit by masking all but the MSB
          delayMicroseconds(3 * BITtime); //a HIGH is 3 bit time periods
        else
          delayMicroseconds(BITtime);     //a LOW is only 1 bit time period
         code<<=1;                        //shift to the next bit for this byte
        }
      IRcarrier(BITtime);                 //send a single STOP bit.
    }
    
    void loop()                           //some demo main code
    {
      IRsetup();                          //Only need to call this once to setup
      IRsendCode(IRcode);                 
      delay(5000);
      IRsendCode(IRcode);
      while(1);
    }
    
    

    external by syfTec  38  2  1  0

    This gist shows you how to encode specifically to HEVC with ffmpeg's NVENC on supported hardware, with a two-pass profile and optional CUVID-based hardware-accelerated decoding.

    This gist shows you how to encode specifically to HEVC with ffmpeg's NVENC on supported hardware, with a two-pass profile and optional CUVID-based hardware-accelerated decoding. : ffmpeg-hevc-encode-nvenc.md
    Encoding high-quality HEVC content  with FFmpeg - based NVENC encoder on supported hardware:
    --------------------------------------------------
    
    If you've built ffmpeg as [instructed here on Linux](https://gist.github.com/Brainiarc7/988473b79fd5c8f0db54b92ebb47387a) and the ffmpeg binary is in your path, you can do fast HEVC encodes as shown below, using [NVIDIA's NPP's libraries](https://developer.nvidia.com/npp) to vastly speed up the process.
    
    Now, to do a simple NVENC encode in 1080p, (that will even work for Maxwell Gen 2 (GM200x) series), start with:
    
        ffmpeg  -i <inputfile>  \
        -filter:v hwupload_cuda,scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos,hwdownload \
        -c:v hevc_nvenc -profile main -preset slow -rc vbr_hq \ 
         -c:a copy <outputfile>
    
    Note that this encode method lacks 10-bit support and is in the 4:2:0 color space.
    
    **Extra notes:** For full hardware-accelerated transcodes, you may also want to use one of the many Nvidia CUVID-based accelerated decoders available in your FFmpeg build. See the list available on your system as shown [here](https://gist.github.com/Brainiarc7/c6164520f082c27ae7bbea9556d4a3ba).
    
    Add the appropriate CUVID decoder to the command line based on the source media file:
    
    1. For transcoding 8-bit H.264/AVC content to the same or to *8-bit* HEVC content as the final result, append `-hwaccel cuvid -c:v h264_cuvid` to the ffmpeg arguments before the `-i` option.
    
    2.  For transcoding 8-bit HEVC content to the same or to 8-bit H.264 content as the final result, append `-hwaccel cuvid -c:v hevc_nvenc` to the ffmpeg arguments before the `-i`  option.
    
    3. Follow the same guide in transcoding 8-bit content supported by CUVID's decoder as shown above, linked to the [previous gist](https://gist.github.com/Brainiarc7/c6164520f082c27ae7bbea9556d4a3ba), as per the input format.
    
    4. Now, for *10-bit* encodes, you can now use the `-hwaccel cuvid` option (as the latest NVENC SDK enables FFmpeg to do full HDR transcoding), combined with `-c:v {hwaccel_type}` , which can be any of the following entries based on the source content codec: 
    
    (a).`h263_cuvid`: Nvidia CUVID H263 decoder (codec h263)
    (b).`h264_cuvid`: Nvidia CUVID H264 decoder (codec h264)
    (c).`hevc_cuvid`: Nvidia CUVID HEVC decoder (codec hevc)
    (d).`mjpeg_cuvid`: Nvidia CUVID MJPEG decoder (codec mjpeg)
    (e).`mpeg1_cuvid`: Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
    (f).`mpeg2_cuvid`: Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
    (g).`mpeg4_cuvid`: Nvidia CUVID MPEG4 decoder (codec mpeg4)
    (h).`vc1_cuvid`:  Nvidia CUVID VC1 decoder (codec vc1)
    (i).`vp8_cuvid`:  Nvidia CUVID VP8 decoder (codec vp8)
    (j).`vp9_cuvid`:  Nvidia CUVID VP9 decoder (codec vp9)
    
    Note that decode support will vary on the platform you're on, and as such:
    
    1.  Maxwell Generation 1 SKUs ([GM107](http://www.anandtech.com/show/7764/the-nvidia-geforce-gtx-750-ti-and-gtx-750-review-maxwell/4)) is limited to H.264, MJPEG, and MPEG (1 through 4) decode support only.
    2.  Second Generation Maxwell ([GM204](http://www.anandtech.com/show/8526/nvidia-geforce-gtx-980-review/3)) is the same as Maxwell's first generation in terms of decode capability.
    3.  Newer Maxwell GPUs ([GM206](http://www.anandtech.com/show/8923/nvidia-launches-geforce-gtx-960) and the [GM200](http://www.anandtech.com/show/9059/the-nvidia-geforce-gtx-titan-x-review/2)) offer additional support for fixed function hardware accelerated HEVC decoding.
    4. All pascal GPUs ([GP104](http://www.anandtech.com/show/10325/the-nvidia-geforce-gtx-1080-and-1070-founders-edition-review/4), [GP100](https://www.extremetech.com/extreme/226032-nvidias-pascal-gp100-gpu-massive-bandwidth-enormous-double-precision-performance), etc) offer support for all the above CUVID-based decoders. 
    
    An attempt to use a CUVID-based decoder that is not supported by your hardware will result in a CUDA-related error like this:
    
        [vp9_cuvid @ 0x30bf700] ctx->cvdl->cuvidCreateDecoder(&cudec, &cuinfo) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
        Stream mapping:
          Stream #0:0 -> #0:0 (vp9 (vp9_cuvid) -> h264 (h264_nvenc))
        Error while opening decoder for input stream #0:0 : Generic error in an external library
        [AVIOContext @ 0x30c14a0] Statistics: 0 seeks, 0 writeouts
        [AVIOContext @ 0x30c16e0] Statistics: 882605 bytes read, 0 seeks
    
    Here, I tried using the vp9_cuvid decoder on an unsupported platform (to be specific, a First generation Maxwell card) and it failed spectacularly.
    
    Everything after this point will require a Pascal based card (10xx).
    
    **Adding 10bit:**
    
        ffmpeg  -i <inputfile>  \ 
        -filter:v hwupload_cuda,scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos,hwdownload \
        -c:v hevc_nvenc -profile:v main10 -preset slow \
        -rc vbr_hq -c:a:0 copy <outputfile>
    
    **Adding 10bit with 4:4:4 conversion:**
    
        ffmpeg  -i <inputfile> \ 
        -filter:v hwupload_cuda,scale_npp=w=1920:h=1080:format=yuv444p16:interp_algo=lanczos,hwdownload \ 
        -c:v hevc_nvenc -profile:v main10 -preset slow -rc vbr_hq -c:a:0 copy <outputfile>
    
    And finally, 10bit, 4:4:4 with the maximum look-ahead value Pascal supports, which helps with motion heavy scenes:
    
        ffmpeg -i <inputfile> \
        -filter:v hwupload_cuda,scale_npp=w=1920:h=1080:format=yuv444p16:interp_algo=lanczos,hwdownload,format=nv12 \
        -c:v hevc_nvenc  -profile:v main10 -preset slow -rc vbr_hq -rc-lookahead 32 -c:a:0 copy <outputfile>
    
    Note: Using NVIDIA's NPP to speed up the encode and decode process as illustrated above has been documented extensively, refer to  [this](https://gist.github.com/Brainiarc7/2afac8aea75f4e01d7670bc2ff1afad1) gist for more information.
    
    **Hint:** If you want to do the encodes without having to specify the target encodes resolution (skipping the nvidia-provided scaler), you may repeat the snippets above by removing the `-filter:v` argument in full.
    
    
    This gist will be updated as the NVENC SDK adds more HEVC encode features. Refer to [this](https://gist.github.com/Brainiarc7/24c966c8a001061ee86cc4bc05826bf4) portion on speeding up ffmpeg with GNU parallel on a multi-node cluster and [this](https://gist.github.com/Brainiarc7/2afac8aea75f4e01d7670bc2ff1afad1) portion on using xargs to spawn multiple ffmpeg sessions for NVENC as needed.
    
    
    
    
    
    
    
    
    
    • Public Snippets
    • Channels Snippets