Recherche avancée

Médias (9)

Mot : - Tags -/soundtrack

Autres articles (112)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (16379)

  • How to live video stream using node API(Read file with chunk logic)

    28 septembre 2023, par Mukesh Singh Thakur

    I want to make a live video streaming API and send the video buffer chunk data to an HTML.
I am using rtsp URL.
The chunk logic does not work. The video only plays for 5 seconds then stops.

    


    index.js file

    


    const express = require('express');
const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');
const path = require('path');

const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.sendFile(__dirname + "/index.html");
});

const rtspUrl = 'rtsp://zephyr.rtsp.stream/movie?streamKey=64fd08123635440e7adc17ba31de2036';
const chunkDuration = 5; // Duration of each chunk in seconds


app.get('/video', (req, res) => {
  const outputDirectory = path.join(__dirname, 'chunks');
  if (!fs.existsSync(outputDirectory)) {
    fs.mkdirSync(outputDirectory);
  }

  const startTime = new Date().getTime();
  const outputFileName = `chunk_${startTime}.mp4`;
  const outputFilePath = path.join(outputDirectory, outputFileName);

  const command = ffmpeg(rtspUrl)
    .inputFormat('rtsp')
    // .inputOptions(['-rtsp_transport tcp'])
    .videoCodec('copy')
    .output(outputFilePath)
    .duration(chunkDuration)
    .on('start', () => {
      console.log(`start ${outputFileName}`);
    })
    .on('end', () => {
      console.log(`Chunk ${outputFileName} saved`);
      res.setHeader('Content-Type', 'video/mp4');
      res.sendFile(outputFilePath, (err) => {
        if (err) {
          console.error('Error sending file:', err);
        } else {
          fs.unlinkSync(outputFilePath); // Delete the chunk after it's sent
        }
      });
    })
    .on('error', (error) => {
      console.error('Error: ', error);
    });

  command.run();
});

app.listen(port, () => {
  console.log(`API server is running on port ${port}`);
});


    


    index.html

    


    &#xA;&#xA;&#xA;&#xA;  &#xA;  &#xA;  &#xA;  &#xA;&#xA;&#xA;&#xA;  <video width="50%" controls="controls" autoplay="autoplay">&#xA;    <source src="/video" type="video/mp4"></source>&#xA;    Your browser does not support the video tag.&#xA;  </video>&#xA;&#xA;&#xA;&#xA;

    &#xA;

    package.json

    &#xA;

    {&#xA;.....&#xA;  "scripts": {&#xA;    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1",&#xA;    "start": "nodemon index.js"&#xA;  },&#xA;.....&#xA;}&#xA;

    &#xA;

  • How to live video stream using node API (Read file with chunk logic)

    28 septembre 2023, par Mukesh Singh Thakur

    I want to make a live video streaming API and send the video buffer chunk data to an HTML.&#xA;I am using rtsp URL.&#xA;The chunk logic does not work. The video only plays for 5 seconds then stops.

    &#xA;

    index.js file

    &#xA;

    const express = require(&#x27;express&#x27;);&#xA;const ffmpeg = require(&#x27;fluent-ffmpeg&#x27;);&#xA;const fs = require(&#x27;fs&#x27;);&#xA;const path = require(&#x27;path&#x27;);&#xA;&#xA;const app = express();&#xA;const port = 3000;&#xA;&#xA;app.get(&#x27;/&#x27;, (req, res) => {&#xA;  res.sendFile(__dirname &#x2B; "/index.html");&#xA;});&#xA;&#xA;const rtspUrl = &#x27;rtsp://zephyr.rtsp.stream/movie?streamKey=64fd08123635440e7adc17ba31de2036&#x27;;&#xA;const chunkDuration = 5; // Duration of each chunk in seconds&#xA;&#xA;&#xA;app.get(&#x27;/video&#x27;, (req, res) => {&#xA;  const outputDirectory = path.join(__dirname, &#x27;chunks&#x27;);&#xA;  if (!fs.existsSync(outputDirectory)) {&#xA;    fs.mkdirSync(outputDirectory);&#xA;  }&#xA;&#xA;  const startTime = new Date().getTime();&#xA;  const outputFileName = `chunk_${startTime}.mp4`;&#xA;  const outputFilePath = path.join(outputDirectory, outputFileName);&#xA;&#xA;  const command = ffmpeg(rtspUrl)&#xA;    .inputFormat(&#x27;rtsp&#x27;)&#xA;    // .inputOptions([&#x27;-rtsp_transport tcp&#x27;])&#xA;    .videoCodec(&#x27;copy&#x27;)&#xA;    .output(outputFilePath)&#xA;    .duration(chunkDuration)&#xA;    .on(&#x27;start&#x27;, () => {&#xA;      console.log(`start ${outputFileName}`);&#xA;    })&#xA;    .on(&#x27;end&#x27;, () => {&#xA;      console.log(`Chunk ${outputFileName} saved`);&#xA;      res.setHeader(&#x27;Content-Type&#x27;, &#x27;video/mp4&#x27;);&#xA;      res.sendFile(outputFilePath, (err) => {&#xA;        if (err) {&#xA;          console.error(&#x27;Error sending file:&#x27;, err);&#xA;        } else {&#xA;          fs.unlinkSync(outputFilePath); // Delete the chunk after it&#x27;s sent&#xA;        }&#xA;      });&#xA;    })&#xA;    .on(&#x27;error&#x27;, (error) => {&#xA;      console.error(&#x27;Error: &#x27;, error);&#xA;    });&#xA;&#xA;  command.run();&#xA;});&#xA;&#xA;app.listen(port, () => {&#xA;  console.log(`API server is running on port ${port}`);&#xA;});&#xA;

    &#xA;

    index.html

    &#xA;

    &#xA;&#xA;&#xA;&#xA;  &#xA;  &#xA;  &#xA;  &#xA;&#xA;&#xA;&#xA;  <video width="50%" controls="controls" autoplay="autoplay">&#xA;    <source src="/video" type="video/mp4"></source>&#xA;    Your browser does not support the video tag.&#xA;  </video>&#xA;&#xA;&#xA;&#xA;

    &#xA;

    package.json

    &#xA;

    {&#xA;.....&#xA;  "scripts": {&#xA;    "test": "echo \"Error: no test specified\" &amp;&amp; exit 1",&#xA;    "start": "nodemon index.js"&#xA;  },&#xA;.....&#xA;}&#xA;

    &#xA;

  • ffmpeg - stretched pixel issue

    5 juin 2023, par Adunato

    Context

    &#xA;

    I'm converting a PNG sequence into a video using FFMPEG. The images are semi-transparent portraits where the background has been removed digitally.

    &#xA;

    Issue

    &#xA;

    The edge pixels of the subject are stretched all the way to the frame border, creating a fully opaque video.

    &#xA;

    Cause Analysis

    &#xA;

    The process worked fine in the previous workflow using rembg from command line however, since I started using rembg via python script using alpha_matting to obtain higher quality results, the resulting video has these issues.

    &#xA;

    The issue is present in both webm format (target) and mp4 (used for testing).

    &#xA;

    Command Used

    &#xA;

    Command used for webm is :

    &#xA;

    ffmpeg -thread_queue_size 64 -framerate 30 -i <png sequence="sequence" location="location"> -c:v libvpx -b:v 0 -crf 18 -pix_fmt yuva420p -auto-alt-ref 0 -c:a libvorbis <png output="output">&#xA;</png></png>

    &#xA;

    Throubleshooting Steps Taken

    &#xA;

      &#xA;
    1. PNG Visual inspection The PNG images have a fully transparent background as desired.
    2. &#xA;

    3. PNG Alpha Measurement I have created a couple of python scripts to look at alpha level in pixels and confirmed that there is no subtle alpha level in the background pixels
    4. &#xA;

    5. Exported MP4 with AE Using the native AE renderer the resulting MP4/H.265 has a black background, so not showing the stretched pixel issue
    6. &#xA;

    &#xA;

    Image of the Issue

    &#xA;

    Text

    &#xA;

    Sample PNG Image from sequence&#xA;Text

    &#xA;

    Code Context

    &#xA;

    rembg call via API using alpha_matting seems to generate a premultiplied alpha which uses non black pixels for 0 alpha pixels.

    &#xA;

    remove(input_data, alpha_matting=True, alpha_matting_foreground_threshold=250,&#xA;                    alpha_matting_background_threshold=250, alpha_matting_erode_size=12)&#xA;

    &#xA;

    A test using a rough RGB reset of 0-alpha pixels confirms that the images are being played with their RGB value ignoring Alpha.

    &#xA;

    def reset_alpha_pixels(img):&#xA;    # Open the image file&#xA;    # Process each pixel&#xA;    data = list(img.getdata())&#xA;    new_data = []&#xA;    for item in data:&#xA;        if item[3] == 0:&#xA;            new_data.append((0, 0, 0, 0))&#xA;        else:&#xA;            new_data.append((item[0], item[1], item[2], item[3]))&#xA;        # Replace the alpha value but keep the RGB&#xA;        &#xA;&#xA;    # Update the image data&#xA;    img.putdata(new_data)&#xA;&#xA;    return img&#xA;

    &#xA;

    Updates

    &#xA;

      &#xA;
    • Added python context to make the question more relevant within SO scope.
    • &#xA;

    &#xA;