Giter Site home page Giter Site logo

YUV to RGB Pixel Format about beamcoder HOT 1 OPEN

streampunk avatar streampunk commented on June 29, 2024
YUV to RGB Pixel Format

from beamcoder.

Comments (1)

scriptorian avatar scriptorian commented on June 29, 2024

Hi,
Thanks for your interest in beamcoder.

My understanding is that vp8 is exclusively an 8-bit 4:2:0 format and it is likely that the FFmpeg vp8 decoder will deliver data as 3 separate buffers for Y, U and V with the U & V buffers each being 1/4 the size of the Y buffer. For the conversion you could look in the Streampunk/nodencl project where you will find a colourMaths.js file in the scratch folder with a function that you could use to generate a set of matrix coefficients and a matrixMultiply function that would do the right thing on YUV source data if you are not too worried about the knotty details of white points and gamma functions.

However I think an easier way to progress this could be to use a bit more of beamcoder to do the conversion for you. Using the streaming helpers that would be something like the below, with scale, spec, colorspace etc values set as you require:

async function run() {
  const urls = [ 'file:/Users/ianrothmann/Downloads/RT76057bde97adbd0537bcdb89037c9034.mkv' ];
  const spec = { start: 0, end: 10 };

  const params = {
    video: [
      {
        sources: [
          { url: urls[0], ms: spec, streamIndex: 0 }
        ],
        filterSpec: '[in0:v] scale=1280:720, colorspace=all=bt709 [out0:v]',
        streams: [
          { name: 'rawvideo', time_base: [1, 90000],
            codecpar: {
              width: 1280, height: 720, format: 'rgb24', color_space: 'bt709',
              sample_aspect_ratio: [1, 1]
            }
          }
        ]
      }
    ],
    out: {
      formatName: 'rawvideo',
      url: 'file:temp.raw'
    }
  };

  await beamcoder.makeSources(params);
  const beamStreams = await beamcoder.makeStreams(params);

  await beamStreams.run();
}

console.log('Running');
let start = Date.now();
run()
  .then(() => console.log(`Finished ${Date.now() - start}ms`))
  .catch(console.error);

I hope this helps!

from beamcoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.