How to use the beamcoder.decoder function in beamcoder

To help you get started, we’ve selected a few beamcoder examples, based on popular ways it is used in public projects.

github Streampunk / casparcl / scratch / ebu_oss_clunker.js View on Github external
await v210Dst.hostAccess('readonly')
		// console.log(process.hrtime(lstamp))
		return res;
	}

	async function waitForIt (t) {
		return new Promise((resolve, reject) => {
			setTimeout(resolve, t > 0 ? t : 0)
		})
	}

	let start = process.hrtime();

	let dm1 = await beamy.demuxer('file:../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf')
	await dm1.seek({ time: 240.0 })
	let dec1 = await beamy.decoder({ demuxer: dm1, stream_index: 0 })
	console.log(dec1)
	let dm2 = await beamy.demuxer('file:../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf')
	await dm2.seek({ time: 340.0 })
	let dec2 = await beamy.decoder({ demuxer: dm1, stream_index: 0 })

	let rate1 = 1.0
	let rate2 = 1.0
	let nextRate1 = 1.0
	let nextRate2 = 1.0
	let fraction1 = 0.5
	let fraction2 = 0.5
	let previous1, previous2

	async function read1 (rootCall = true) {
		if (rootCall === true) {
			fraction1 = fraction1 + rate1
github Streampunk / casparcl / scratch / promise_clunker.js View on Github external
const testImageProgram = await context.createProgram(testImage, {
		globalWorkItems: Uint32Array.from([ width, height ])
	});

	const numBytesV210 = v210_io.getPitchBytes(width) * height;
	const v210Src = await context.createBuffer(numBytesV210, 'readonly', 'coarse');

	const numBytesRGBA = width * height * 4 * 4;
	const rgbaDst = await context.createBuffer(numBytesRGBA, 'readwrite', 'coarse');
	const imageDst = await context.createBuffer(numBytesRGBA, 'readwrite', 'coarse');

	const v210Dst = await context.createBuffer(numBytesV210, 'writeonly', 'coarse');

	let dm = await beamy.demuxer('file:../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf')
	console.log(dm)
	let dec = await beamy.decoder({ demuxer: dm, stream_index: 0 })
	let enc = beamy.encoder({ name: 'v210', codec_id: 127, width: 1920, height: 1080, pix_fmt: 'yuv422p10le', bits_per_raw_sample: 20, time_base: [ 1, 25 ] })
	console.log(enc)

	let playback = await macadam.playback({
  	deviceIndex: 0, // Index relative to the 'macadam.getDeviceInfo()' array
  	displayMode: macadam.bmdModeHD1080i50,
  	pixelFormat: macadam.bmdFormat10BitYUV
	})

	let result = []
	let counter = 0

	async function read() {
		let p = await dm.read()
		if (p.stream_index === 0) return p
		return read()
github Streampunk / casparcl / scratch / high_beam_cl.js View on Github external
res[0] = await v210Reader.fromV210(v210Src, rgbaDst)
		//await rgbaDst.hostAccess('readonly')
		// dumpFloatBuf(rgbaDst, 1920, 2, 4);
		res[1] = await testImageProgram.run({input: rgbaDst, output: imageDst})
		//await imageDst.hostAccess('readonly')
		// dumpFloatBuf(imageDst, 1920, 2, 4);
		res[2] = await v210Writer.toV210(imageDst, v210Dst)
		await v210Dst.hostAccess('readonly')
		// v210_io.dumpBuf(v210Dst, 1920, 4);
		// console.log(process.hrtime(lstamp))
		return res;
	}

	let dm = await beamy.demuxer('file:../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf')
	console.log(dm)
	let dec = await beamy.decoder({ demuxer: dm, stream_index: 0 })
	let enc = beamy.encoder({ name: 'v210', codec_id: 127, width: 1920, height: 1080, pix_fmt: 'yuv422p10le', bits_per_raw_sample: 20, time_base: [ 1, 25 ] })
	console.log(enc)

	let playback = await macadam.playback({
  	deviceIndex: 0, // Index relative to the 'macadam.getDeviceInfo()' array
  	displayMode: macadam.bmdModeHD1080i50,
  	pixelFormat: macadam.bmdFormat10BitYUV
	})

	let counter = 0

	const gen = (push, next) => {
		dm.read().then(p => {
			if (p.stream_index === 0) {
				push(null, p)
				next()
github Streampunk / casparcl / scratch / elecular_clunker.js View on Github external
async function init () {
  const platformIndex = 1;
  const deviceIndex = 0;
  const context = new addon.clContext({
    platformIndex: platformIndex,
    deviceIndex: deviceIndex
  });
  const platformInfo = await context.getPlatformInfo();
  console.log(platformInfo.vendor, platformInfo.devices[deviceIndex].type);

  let demuxer = await beamcoder.demuxer('../../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf');
  await demuxer.seek({ time: 40 });
  let decoder = beamcoder.decoder({ name: 'h264' });
  let encParams = {
    name: 'v210',
    width: width,
    height: height,
    time_base: [1, 25],
    framerate: [25, 1],
    pix_fmt: 'yuv422p10le',
  };
  let encoder = beamcoder.encoder(encParams);

  const bgColSpecRead = '709';
  const ovColSpecRead = 'sRGB';
  const colSpecWrite = '709';

  v210Loader = new rgbyuv.yuvLoader(context, bgColSpecRead, colSpecWrite, new v210_io.reader(width, height));
  await v210Loader.init();
github Streampunk / casparcl / scratch / elecular_process.js View on Github external
async function init () {
  const platformIndex = 1;
  const deviceIndex = 0;
  const context = new addon.clContext({
    platformIndex: platformIndex,
    deviceIndex: deviceIndex
  });
  const platformInfo = await context.getPlatformInfo();
  console.log(platformInfo.vendor, platformInfo.devices[deviceIndex].type);

  let demuxer = await beamcoder.demuxer('../../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf');
  await demuxer.seek({ time: 40 });
  let decoder = beamcoder.decoder({ name: 'h264' });
  let encParams = {
    name: 'v210',
    width: width,
    height: height,
    time_base: [1, 25],
    framerate: [25, 1],
    pix_fmt: 'yuv422p10le',
  };
  let encoder = beamcoder.encoder(encParams);

  const bgColSpecRead = '709';
  const ovColSpecRead = 'sRGB';
  const colSpecWrite = '709';

  v210Loader = new rgbyuv.yuvLoader(context, bgColSpecRead, colSpecWrite, new v210_io.reader(width, height));
  await v210Loader.init();
github Streampunk / casparcl / scratch / elecular_clunker2.js View on Github external
async function init () {
  const enableDeinterlace = true;
  const platformIndex = 1;
  const deviceIndex = 0;
  const context = new addon.clContext({
    platformIndex: platformIndex,
    deviceIndex: deviceIndex,
    overlapping: true
  });
  const platformInfo = await context.getPlatformInfo();
  console.log(platformInfo.vendor, platformInfo.devices[deviceIndex].type);

  let demuxer = await beamcoder.demuxer('../../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf');
  await demuxer.seek({ time: 40 });
  const stream = demuxer.streams[0];
  let decoder = beamcoder.decoder({ name: stream.codecpar.name });
  let filterer = await beamcoder.filterer({
    filterType: 'video',
    inputParams: [{
      width: stream.codecpar.width,
      height: stream.codecpar.height,
      pixelFormat: stream.codecpar.format,
      timeBase: stream.time_base,
      pixelAspect: stream.codecpar.sample_aspect_ratio
    }],
    outputParams: [{
      pixelFormat: stream.codecpar.format
    }],
    filterSpec: 'yadif=mode=1:parity=-1:deint=0'
  })

	const bgColSpecRead = '709';