Recherche avancée

Médias (91)

Autres articles (92)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (4684)

  • AWS Lambda in Node JS with FFMPEG Lambda Layer

    29 mars 2023, par mwcwge23

    I'm trying to make a Lambda that takes a video and puts a watermark image on it.
I'm using Lambda with NodeJS and FFMPEG Lambda Layer I took from here :
https://serverlessrepo.aws.amazon.com/applications/us-east-1/145266761615/ffmpeg-lambda-layer

    


    I got these two errors and I don't have a clue what do I did wrong :
errors

    


    Please help me :)

    


    (by the way, if you have an easier solution to put a watermark image on video that'll also be great)

    


    That's my code (trying to put a watermark image on a video file) :

    


    const express = require("express");
const childProcess = require("child_process");
const path = require("path");
const fs = require("fs");
const util = require("util");
const os = require("os");
const { fileURLToPath } = require("url");
const { v4: uuidv4 } = require("uuid");
const bodyParser = require("body-parser");
const awsServerlessExpressMiddleware = require("aws-serverless-express/middleware");
const AWS = require("aws-sdk");
const workdir = os.tmpdir();

const s3 = new AWS.S3();

// declare a new express app
const app = express();
app.use(bodyParser.json());
app.use(awsServerlessExpressMiddleware.eventContext());

// Enable CORS for all methods
app.use(function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "*");
  next();
});

const downloadFileFromS3 = function (bucket, fileKey, filePath) {
  "use strict";
  console.log("downloading", bucket, fileKey, filePath);
  return new Promise(function (resolve, reject) {
    const file = fs.createWriteStream(filePath),
      stream = s3
        .getObject({
          Bucket: bucket,
          Key: fileKey,
        })
        .createReadStream();
    stream.on("error", reject);
    file.on("error", reject);
    file.on("finish", function () {
      console.log("downloaded", bucket, fileKey);
      resolve(filePath);
    });
    stream.pipe(file);
  });
};

const uploadFileToS3 = function (bucket, fileKey, filePath, contentType) {
  "use strict";
  console.log("uploading", bucket, fileKey, filePath);
  return s3
    .upload({
      Bucket: bucket,
      Key: fileKey,
      Body: fs.createReadStream(filePath),
      ACL: "private",
      ContentType: contentType,
    })
    .promise();
};

const spawnPromise = function (command, argsarray, envOptions) {
  return new Promise((resolve, reject) => {
    console.log("executing", command, argsarray.join(" "));
    const childProc = childProcess.spawn(
        command,
        argsarray,
        envOptions || { env: process.env, cwd: process.cwd() }
      ),
      resultBuffers = [];
    childProc.stdout.on("data", (buffer) => {
      console.log(buffer.toString());
      resultBuffers.push(buffer);
    });
    childProc.stderr.on("data", (buffer) => console.error(buffer.toString()));
    childProc.on("exit", (code, signal) => {
      console.log(`${command} completed with ${code}:${signal}`);
      if (code || signal) {
        reject(`${command} failed with ${code || signal}`);
      } else {
        resolve(Buffer.concat(resultBuffers).toString().trim());
      }
    });
  });
};

app.post("/api/addWatermark", async (req, res) => {
  try {
    const bucketName = "bucketName ";
    const uniqeName = uuidv4() + Date.now();
    const outputPath = path.join(workdir, uniqeName + ".mp4");
    const key = "file_example_MP4_480_1_5MG.mp4";
    const localFilePath = path.join(workdir, key);
    const watermarkPngKey = "watermark.png";
    const watermarkLocalFilePath = path.join(workdir, watermarkPngKey);

    downloadFileFromS3(bucketName, key, localFilePath)
      .then(() => {
        downloadFileFromS3(bucketName, watermarkPngKey, watermarkLocalFilePath)
          .then(() => {
            fs.readFile(localFilePath, (err, data) => {
              if (!err && data) {
                console.log("successsss111");
              }
            });
            fs.readFile(watermarkLocalFilePath, (err, data) => {
              if (!err && data) {
                console.log("successsss222");
              }
            });

            fs.readFile(outputPath, (err, data) => {
              if (!err && data) {
                console.log("successsss3333");
              }
            });

            spawnPromise(
              "/opt/bin/ffmpeg",
              [
                "-i",
                localFilePath,
                "-i",
                watermarkLocalFilePath,
                "-filter_complex",
                `[1]format=rgba,colorchannelmixer=aa=0.5[logo];[0][logo]overlay=5:H-h-5:format=auto,format=yuv420p`,
                "-c:a",
                "copy",
                outputPath,
              ],
              { env: process.env, cwd: workdir }
            )
              .then(() => {
                uploadFileToS3(
                  bucketName,
                  uniqeName + ".mp4",
                  outputPath,
                  "mp4"
                );
              });
           });
      });
  } catch (err) {
    console.log({ err });
    res.json({ err });
  }
});

app.listen(8136, function () {
  console.log("App started");
});

module.exports = app;



    


  • Encoding audio_common messages to OPUS

    14 juin 2023, par djangbahevans

    


    I am trying to stream microphone and camera data to Amazon KVS WebRTC. I'm able to make video work using this package (adapted for noetic) however I am struggling to make audio work. I'm using the audio_capture package to get mp3 frames. I'm trying to convert this to OPUS frames before streaming to KVS, but I'm unsure how to do this. I wrote this bit of code based on the small resources I can find on using ffmpeg, but it's not working. avcodec_fill_audio_frame is returning -22.

    


    #include "opus_encoder.h"

OPUSEncoder::OPUSEncoder() {
  av_register_all();
  codecContext == nullptr;
}

OPUSEncoder::~OPUSEncoder() {
  if (codecContext != nullptr) {
    avcodec_free_context(&codecContext);
  }
}

int OPUSEncoder::Initialize(int Fs, int channels) {
  AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_OPUS);
  if (!codec) {
    printf("Codec not found\n");
    return -1;
  }

  codecContext = avcodec_alloc_context3(codec);
  if (!codecContext) {
    printf("Could not allocate audio codec context\n");
    return -1;
  }

  codecContext->sample_fmt = AV_SAMPLE_FMT_S16;
  codecContext->bit_rate = 128000;
  codecContext->sample_rate = Fs;
  codecContext->channel_layout = av_get_default_channel_layout(channels);
  codecContext->channels = channels;

  if (avcodec_open2(codecContext, codec, nullptr) < 0) {
    printf("Could not open codec\n");
    return -1;
  }

  return 0;
}

int OPUSEncoder::Encode(const uint8_t *audio_data, int frameSize,
                        uint8_t *out) {
  AVPacket pkt;
  av_init_packet(&pkt);
  pkt.data = nullptr;
  pkt.size = 0;

  AVFrame *frame = av_frame_alloc();
  frame->nb_samples = frameSize;
  frame->format = codecContext->sample_fmt;
  frame->channel_layout = codecContext->channel_layout;

  int ret = avcodec_fill_audio_frame(frame, codecContext->channels,
                                     codecContext->sample_fmt, audio_data,
                                     frameSize * 2, 0);
  if (ret < 0) {
    printf("Error filling audio frame: %d\n", ret);
    return -1;
  }

  ret = avcodec_send_frame(codecContext, frame);
  if (ret < 0) {
    printf("Error sending the frame to the encoder\n");
    return -1;
  }

  while (ret >= 0) {
    ret = avcodec_receive_packet(codecContext, &pkt);
    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
      return 0;
    } else if (ret < 0) {
      printf("Error encoding audio frame\n");
      return -1;
    }

    memcpy(out, pkt.data, pkt.size);
    out += pkt.size;
    av_packet_unref(&pkt);
  }

  av_frame_free(&frame);

  return 0;
}


    


  • FFmpeg recorded video is dark with Xvfb and chrome headless on Centos 7

    15 juin 2023, par narsy4

    I am trying to do a video recording of headless chrome session on Centos 7 (Amazon EC2 instance) using ffmpeg. I have installed ffmpeg, Xvfb and google chrome on the machine. I started Xvfb on :99, verified the display using xdpyinfo and started chrome. However when I run the ffmpeg cmd to capture the video (no errors in ffmpeg debug logs), the output is dark with a X sign in the centre of video screen. What am I doing wrong here ? Any help is appreciated.

    


    **Xvfb and chrome commands**
Xvfb :99 -screen 0 1920x1080x24 &
export DISPLAY=:99
google-chrome --headless --disable-gpu --no-sandbox --start-maximized --window-size=1920x1080 https://www.google.com



    


    **FFmpeg command**
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :99 -loglevel debug -pix_fmt yuv420p /tmp/video.mp4



    


    dark video

    


    Searched for and read a few threads on this, but couldn't get it to work.