Recherche avancée

Médias (1)

Mot : - Tags -/net art

Autres articles (68)

  • 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

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (11091)

  • 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;

  • 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;

  • Live streaming through video tag

    1er février 2018, par ElmiS

    I am currently trying to make a video streaming service without using plugins.

    My server is using ffmpeg to transmux a rtsp stream to a fragmented mp4 so that the HTML 5 video tag can play it.

    The ffmpeg command is

    > ffmpeg -rtsp_transport tcp -i rtsp_address -movflags frag_keyframe+empty_moov -c:v copy -f mp4 -

    (My rtsp stream has no audio)

    Then I feed it to the client page though websocket which then will use Media Source Extensions API to give data to the video tag.

    This all works on firefox but does not work for chrome or edge/i.e and I have searched all over but could not find an answer as to why it won’t play.

    The initial data such as the width and the height of the video seems to go through as the size of the video frame changes. However the video won’t start and when I use video.play() so that it would autoplay the video once loaded, I get an error saying

    Uncaught (in promise) DOMException : The play() request was interrupted by a call to pause().

    It seems like the video automatically pauses itself since I did not use pause() anywhere in my code.

    My client side code is

     var webSocket;
     var video = document.getElementById("rtspPlayer");
     var mediaSource;
     var sourceArray;
     var strCodec = 'video/mp4; codecs="avc1.420029"';
     var buffer = [];

     window.onload = function(){
       var selector = document.getElementById("select");
       var url = selector.options[selector.selectedIndex].value;

       setUpWebSocket(url);
       setUpMediaSource();
     }

     function setUpWebSocket(url){
       webSocket = new WebSocket(url);
       webSocket.onopen = onWebSocketOpen;
       webSocket.onmessage = onWebSocketData;
     }

     function setUpMediaSource(){
       mediaSource = new window.MediaSource();
       var uri = window.URL.createObjectURL(mediaSource);
       video.setAttribute('src', uri);
       video.setAttribute('type', 'video/mp4');

       mediaSource.onsourceopen = function(){
         mediaSource.duration = Infinity;
         sourceBuffer = mediaSource.addSourceBuffer(strCodec);
         sourceBuffer.onupdateend = readFromBuffer();
       }
     }

     function onWebSocketOpen(){
       video.play();
     }

     function onWebSocketData(data){
       var blob = data.data;
       var fileReader = new FileReader();
       fileReader.onload = function() {
         buffer.push(this.result);
         readFromBuffer();
       };
       fileReader.readAsArrayBuffer(blob);
     }

     function readFromBuffer(){
       if(buffer.length === 0){
         //console.log("Buffer length 0");
         return;
       }
       else if(!sourceBuffer){
         //console.log("No Source Buffer");
         return;
       }
       else if(sourceBuffer.updating){
         //console.log("SourceBuffer Updating");
         return;
       }

       try{
         var data = buffer.shift();
         sourceBuffer.appendBuffer(data);
       }
       catch(e){
         return;
       }
     }

    I’m certain that this is the right Codec for the video I want to play as I have saved 30 second of the video using ffmpeg and used Bento4’s mp4info to check the codec. Also the 30 second video clip played well though the media source. However playing live seems impossible for me to solve.

    Help me please ! I’ve been trying to solve this problem for days.