Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (63)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

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

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (7927)

  • Reason for write EPIPE error in my implementation ?

    25 mai 2019, par Chrisl446

    I currently have a small node.js express application for uploading images using sharp & thumbnails created from .mp4 videos using simple-thumbnail package/ffmpeg.

    The app works perfectly when uploading an image, the file is uploaded sharp processes it, then passes it along and it ends up in my amazon s3 bucket as expected. No errors what so ever.

    However, when I upload an mp4 video that I use to create and upload a thumbnail from by using simple-thumbnails genThumbnail() function, which uses ffmpeg child process, the thumbnail uploads successully to my s3 bucket, HOWEVER my app returns an EPIPE write error and NOT the url of the uploaded files url on S3.

    What is causing this and how can I fix it, considering it’s pretty much working aside from the EPIPE error that is being returned ? Thanks ahead !

    The packages of concern used are as follows :

    aws-sdk

    multer

    multer-s3 <- this one with the transform option, not the standard multer-s3 package

    simple-thumbnail

    const express = require('express');
    const app = express();

    const aws = require('aws-sdk');
    const multer = require('multer');
    const multerS3 = require('multer-s3'); //github:gmenih341/multer-s3 version of multer-s3 with transform option
    const sharp = require('sharp');
    const genThumbnail = require('simple-thumbnail');

    app.use((req, res, next) => {
       res.header('Access-Control-Allow-Origin', '*');
       res.header('Access-Control-Allow-Headers', 'Orgin, X-Requested-With, Content-Type, Accept, Authorization');
       if (req.method === 'OPTIONS') {
           res.header('Access-Control-Allow-Methods', 'POST');
           return res.status(200).json({});
       }
       next();
    });

    let uniqueFileName;
    let s3BucketName = 'bucketname';

    let s3 = new aws.S3({
       accessKeyId: ACCESS_KEY,
       secretAccessKey: SECRET_KEY,
       Bucket: s3BucketName
    });

    let upload = multer({
       storage: multerS3({
           s3: s3,
           bucket: s3BucketName,
           acl: 'public-read',
           cacheControl: 'max-age=31536000',
           contentType: multerS3.AUTO_CONTENT_TYPE,
           shouldTransform: true,
           transforms: [{
               id: 'thumbnail',
               key: function (req, file, cb) {
                   uniqueFileName = Date.now().toString();
                   cb(null, uniqueFileName + '.jpg')
               },
               transform: function (req, file, cb) {
                   if (file.mimetype == 'video/mp4') {
                       //When using simple-thumbnails' getThumbnail() on an mp4 video it uploads succesfully to S3 but node returns EPIPE write error
                       cb(null, genThumbnail(null, null, '250x?'))
                   } else {
                       //When using sharp to resize an image this works perfectly and retuns the JSON below with the files S3 URL
                       cb(null, sharp().jpeg())
                   }

               }
           }]
       })
    });

    app.post('/upload', upload.array('theFile'), (req, res) => {
       res.json({
           fileS3Url: 'https://s3.amazonaws.com/'+ s3BucketName +'/' + uniqueFileName
       });
    });

    app.use((req, res, next) => {
       const error = new Error('Not found');
       error.status = 404;
       next(error);
    });

    app.use((error, req, res, next) => {
       res.status(error.status || 500);
       res.json({
           error: {
               message: error.message
           }
       });
    });

    module.exports = app;
  • About the delay of Electron playing FFpmeg transcoded video

    26 juillet 2020, par Yohann

    In the Electron project, you need to try to play the video screen of the camera

    &#xA;

    The camera is Haikang’s webcam

    &#xA;

    Get real-time video stream through RTSP protocol

    &#xA;

    rtsp://admin:admin@192.168.0.253/main/Channels/

    &#xA;

    There will be a delay of about 3s when playing through the VLC player

    &#xA;

    Then when used in the project, create a websocket service in Electron through the main process, decode the rtsp video through fluent-ffmpeg, and convert it to flv stream and push it to the rendering process

    &#xA;

    import * as express from &#x27;express&#x27;&#xA;import * as expressWebSocket from &#x27;express-ws&#x27;&#xA;import ffmpeg from &#x27;fluent-ffmpeg&#x27;&#xA;import webSocketStream from &#x27;websocket-stream/stream&#x27;&#xA;const path = require(&#x27;path&#x27;)&#xA;&#xA;let ffmpegPath&#xA;if (process.env.NODE_ENV === &#x27;development&#x27;) {&#xA;  ffmpegPath = path.join(__static, &#x27;ffmpeg&#x27;, &#x27;bin&#x27;, &#x27;ffmpeg.exe&#x27;)&#xA;} else {&#xA;  ffmpegPath = path.join(process.cwd(), &#x27;ffmpeg&#x27;, &#x27;bin&#x27;, &#x27;ffmpeg.exe&#x27;)&#xA;}&#xA;ffmpeg.setFfmpegPath(ffmpegPath)&#xA;&#xA;// Start video transcoding service&#xA;function videoServer () {&#xA;  let app = express()&#xA;  app.use(express.static(__dirname))&#xA;  expressWebSocket(app, null, {&#xA;    perMessageDeflate: true&#xA;  })&#xA;  app.ws(&#x27;/rtsp/&#x27;, rtspRequestHandle)&#xA;  app.listen(8888)&#xA;  console.log(&#x27;Create a monitoring service&#x27;)&#xA;}&#xA;&#xA;//RTSP transcoding method&#xA;function rtspRequestHandle (ws, req) {&#xA;  console.log(&#x27;rtsp request handle&#x27;)&#xA;  const stream = webSocketStream(ws, {&#xA;    binary: true,&#xA;    browserBufferTimeout: 1000000&#xA;  },&#xA;  {&#xA;    browserBufferTimeout: 1000000&#xA;  })&#xA;  let url = req.query.url&#xA;  console.log(&#x27;rtsp url:&#x27;, url)&#xA;  try {&#xA;    ffmpeg(url)&#xA;      .addInputOption(&#x27;-rtsp_transport&#x27;, &#x27;tcp&#x27;, &#x27;-buffer_size&#x27;, &#x27;102400&#x27;) // Here you can add some RTSP optimized parameters&#xA;      .outputOptions([&#xA;        &#x27;-fflags&#x27;,&#xA;        &#x27;nobuffer&#x27;,&#xA;        &#x27;-tune&#x27;,&#xA;        &#x27;zerolatency&#x27;&#xA;      ])&#xA;      .on(&#x27;start&#x27;, function () {&#xA;        console.log(url, &#x27;Stream started.&#x27;)&#xA;      })&#xA;      .on(&#x27;codecData&#x27;, function () {&#xA;        console.log(url, &#x27;Stream codecData.&#x27;)&#xA;      })&#xA;      .on(&#x27;error&#x27;, function (err) {&#xA;        console.log(url, &#x27;An error occured: &#x27;, err.message)&#xA;      })&#xA;      .on(&#x27;end&#x27;, function () {&#xA;        console.log(url, &#x27;Stream end!&#x27;)&#xA;      })&#xA;      .outputFormat(&#x27;flv&#x27;).videoCodec(&#x27;copy&#x27;).noAudio().pipe(stream)&#xA;  } catch (error) {&#xA;    console.log(error)&#xA;  }&#xA;}&#xA;&#xA;export default videoServer&#xA;

    &#xA;

    The rendering process parses the video stream and plays the video through flv.js

    &#xA;

    <template>&#xA;  <div class="video">&#xA;    <video class="video-box" ref="player"></video>&#xA;  </div>&#xA;</template>&#xA;&#xA;<code class="echappe-js">&lt;script&gt;&amp;#xA;  import flvjs from &amp;#x27;flv.js&amp;#x27;&amp;#xA;  export default {&amp;#xA;    name: &amp;#x27;videopage&amp;#x27;,&amp;#xA;    props: {&amp;#xA;      rtsp: String&amp;#xA;    },&amp;#xA;    data () {&amp;#xA;      return {&amp;#xA;        player: null&amp;#xA;      }&amp;#xA;    },&amp;#xA;    mounted () {&amp;#xA;      console.log(flvjs.isSupported())&amp;#xA;      if (flvjs.isSupported()) {&amp;#xA;        let video = this.$refs.player&amp;#xA;        console.log(video)&amp;#xA;        if (video) {&amp;#xA;          this.player = flvjs.createPlayer({&amp;#xA;            type: &amp;#x27;flv&amp;#x27;,&amp;#xA;            isLive: true,&amp;#xA;            url: &amp;#x27;ws://localhost:8888/rtsp/?url=&amp;#x27; &amp;#x2B; this.rtsp&amp;#xA;          }, {&amp;#xA;            enableStashBuffer: true&amp;#xA;          })&amp;#xA;          console.log(this.player)&amp;#xA;          this.player.attachMediaElement(video)&amp;#xA;          try {&amp;#xA;            this.player.load()&amp;#xA;            this.player.play()&amp;#xA;          } catch (error) {&amp;#xA;            console.log(error)&amp;#xA;          }&amp;#xA;        }&amp;#xA;      }&amp;#xA;    },&amp;#xA;    methods: {&amp;#xA;      getCurrentFrame () {&amp;#xA;        let video = this.$refs.player&amp;#xA;        let scale = 1&amp;#xA;        let canvas = document.createElement(&amp;#x27;canvas&amp;#x27;)&amp;#xA;        canvas.width = video.videoWidth * scale&amp;#xA;        canvas.height = video.videoHeight * scale&amp;#xA;        canvas.getContext(&amp;#x27;2d&amp;#x27;).drawImage(video, 0, 0, canvas.width, canvas.height)&amp;#xA;        return canvas.toDataURL(&amp;#x27;image/png&amp;#x27;)&amp;#xA;      }&amp;#xA;    },&amp;#xA;    beforeDestroy () {&amp;#xA;      this.player &amp;amp;&amp;amp; this.player.destory &amp;amp;&amp;amp; this.player.destory()&amp;#xA;    }&amp;#xA;  }&amp;#xA;&lt;/script&gt;&#xA;&#xA;&#xA;

    &#xA;

    Then there will be a delay of about 3s when playing, and the delay will increase with the playing time

    &#xA;

    There will be a delay of 10 minutes in the later period

    &#xA;

    Is there any way to control this delay time

    &#xA;

    Or is there any other decoding scheme that can be used ?

    &#xA;

    Solutions that can support electron

    &#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;