Recherche avancée

Médias (0)

Mot : - Tags -/objet éditorial

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (34)

  • 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 (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (5717)

  • How do I extract the first frame of a video stream as an image using avcpp ?

    19 mars 2023, par AurelaNYT

    I'm trying to extract the first frame of a video stream and save it as an image using the avcpp library (https://github.com/h4tr3d/avcpp). I have already written some code but I'm not sure how to extract the first frame from the stream and save it to a .JPG file. Can someone help me with this ?

    


    I have done the following for now and it works fine, however I am unable to understand how to go on with the conversion of the frame to an image :

    


    #include "iostream"
#include "avcpp/av.h"
#include "avcpp/codec.h"
#include "avcpp/frame.h"
#include "avcpp/packet.h"
#include "avcpp/codeccontext.h"
#include "avcpp/formatcontext.h"

class OpenVHCR {
public:

    static void getFirstFrame(const std::string& stream_uri, const bool debug_log) {
        av::init();
        av::Codec videoCodec;
        av::Stream videoStream;
        size_t videoStreamID = -1;
        std::error_code errorCode;
        av::FormatContext formatContext;
        av::VideoDecoderContext decoderContext;
        formatContext.openInput(stream_uri);
        if(formatContext.streamsCount() < 1){
            std::cerr << "[I/O] Failed to find a video steam in the URI provided." << std::endl;
        }else{
            if(debug_log){
                std::cout << "[I/O] Successfully found " <<  formatContext.streamsCount() << " streams in the URI provided." << std::endl;
            }
            formatContext.findStreamInfo(errorCode);
            if (errorCode) {
                std::cerr << "[AV] An unexpected error has occurred: " << errorCode.message() << std::endl;
                return;
            }
            for (size_t i = 0; i < formatContext.streamsCount(); ++i) {
                auto st = formatContext.stream(i);
                if (st.mediaType() == AVMEDIA_TYPE_VIDEO) {
                    videoStreamID = i;
                    videoStream = st;
                    break;
                }
            }
            if(!videoStream.isNull() && videoStream.isValid()){
                if(debug_log){
                    std::cout << "[I/O] Successfully opened a valid video stream." << std::endl;
                }
                decoderContext = av::VideoDecoderContext(videoStream);
                videoCodec = av::findDecodingCodec(decoderContext.raw()->codec_id);
                decoderContext.setCodec(videoCodec);
                decoderContext.setRefCountedFrames(true);
                decoderContext.open({{"threads", "1"}}, av::Codec(), errorCode);
                if(errorCode){
                    std::cout << "[AV] Failed to find a supported codec for the stream." << std::endl;
                    return;
                }else{
                    while (av::Packet streamPacket = formatContext.readPacket(errorCode)){
                        if(errorCode){
                            std::cout << "[AV] Failed to read  a packet from the stream." << std::endl;
                            return;
                        }else{
                            std::cout << "[AV] Successfully read a packet from the stream." << std::endl;
                            if(streamPacket.streamIndex() != videoStreamID){
                                continue;
                            }
                            //TODO: Find a way to get the first frame from the stream and save it as an image.
                            av::VideoFrame videoFrame = decoderContext.decode(streamPacket, errorCode);
                            std::cout << "[AV] Successfully received a frame from the video." << std::endl;
                            if (errorCode) {
                                std::cerr << "[AV] An unexpected error has occurred: " << errorCode.message() << std::endl;
                                return;
                            } else if (!videoFrame) {
                                std::cerr << "[AV] The received video frame seems to be empty." << std::endl;
                            }
                        }
                    }

                    formatContext.close();
                    decoderContext.close();
                }
            }else{
                std::cerr << "[I/O] Failed to find open a valid video stream." << std::endl;
            }
        }
    }
};



    


  • FFmpeg output video is not seekable. Output video is not playing instantly instead browser loads it completely then plays it

    19 février 2024, par Mohit56

    Hi I am using ffmpeg to transcode video. In my code I have used 'fluent-ffmpeg' npm package with nodeJs and 'aws-sdk' to save output video by writestream into s3 bucket.

    


    Problem
-> Video is getting transcoded and I am successfully able to save the video into s3 bucket but. As I paste the object_url of that video into browser and try to play, but that video is not playing instantly I have checked on 'developer console tool' browser is loading all the video once that is done then only it starts playing that is a problem.

    


    ->Let say if I have output video of size 10GB on that case browser will load all 10GB data then only it will start playing that video.

    


    ->If I am not using writestream approach and directly upload the video into local directory first then upload into s3 bucket, In this case if I play the video using object URL then that video plays instantly. In this case I don't have to wait for whole 10GB video to load then play it which is good.

    


    -> Can anybody help me to fix my writestream solution because I don't want to save the output video into my localdirectory. I want to writestream the output video directly into s3 bucket.

    


    Code Snippet

    


    const ffmpeg = require('fluent-ffmpeg');
const AWS = require('aws-sdk'); 
const stream = require("stream");

//set up your aws connection

const command = ffmpeg(inputVideoURL) 
.outputOptions(['-movflags', 'frag_keyframe']) 
.size('854x480') // set the desired resolution (480p) .outputFormat('mp4') 
.videoCodec('libx264') 
.audioCodec('aac') 
.on('progress',(p)=>{ console.log(p) }) 
.on('stderr',(err)=>console.log(err)) 
.on('start', commandLine => console.log('Spawned FFmpeg with command: ' + commandLine)) 
.on('end', () => console.log('Transcoding finished.')) 
.on('error', err => console.error('Error:', err))

//=>To save file into s3 using write steam. command.writeToStream(uploadFolderFileWriteStream('StreamCheck/output2.mp4'));

function uploadFolderFileWriteStream(fileName) { try { const pass = new stream.PassThrough();

const params = {
  Bucket: bucketName,
  Key: fileName,
  Body: pass,
  ACL: "public-read",
  ContentType:'video/mp4' ,
};

const upload = s3.upload(params);

upload.on('error', function(err) {
  console.log("Error uploading to S3:", err);
});

upload.send(function(err, data) {
  if(err) console.log(err);
  else console.log("Upload to S3 completed:", data);
});

return pass;

} catch (err) { console.log("[S3 createWriteStream]", err); } }


    


    I have tried below option as well be all of them not worked 
-> .addOption("-movflags frag_keyframe+empty_moov") 
-> .addOption('-movflags', 'frag_keyframe+empty_moov') 
-> .addOutputOption("-movflags +faststart")
-> .addOption('-movflags', 'faststart+frag_keyframe+empty_moov+default_base_moof')


    


  • Creating a continuous stream for RTMP in Node.js

    9 mars 2023, par hankthetank27

    I'm working on an app that downloads audio from youtube that will be streamed sequentially, similar to radio broadcast. I'm having trouble getting the individual tracks to stream continuously. My idea was to write the tracks sequentially into a readable stream that then is read by FFMPEG. Here is the code I'm having trouble with...

    


    import ytdl from "ytdl-core";&#xA;import ffmpeg from &#x27;fluent-ffmpeg&#x27;;&#xA;import { Readable } from "node:stream"&#xA;&#xA;export async function startAudioStream(): Promise<void>{&#xA;&#xA;  const mainStream = await createStreamedQueue()&#xA;&#xA;  ffmpeg(mainStream)&#xA;    .inputOptions([&#xA;      &#x27;-re&#x27;&#xA;    ])&#xA;    .outputOption([&#xA;      // &#x27;-c:v libx264&#x27;,&#xA;      // &#x27;-preset veryfast&#x27;,&#xA;      // &#x27;-tune zerolatency&#x27;,&#xA;      &#x27;-c:a aac&#x27;,&#xA;      &#x27;-ar 44100&#x27;,&#xA;    ])&#xA;    .save(&#x27;rtmp://localhost/live/main.flv&#x27;);&#xA;};&#xA;&#xA;async function createStreamedQueue(): Promise<readable>{&#xA;&#xA;  function createStream(): Readable{&#xA;    const stream = new Readable({&#xA;      read(){},&#xA;      highWaterMark: 1024 * 512,&#xA;    });&#xA;    stream._destroy = () => { stream.destroyed = true };&#xA;    return stream;&#xA;  }&#xA;&#xA;  const mainStream = createStream();&#xA;&#xA;  const ref1 = &#x27;https://youtu.be/lLCEUpIg8rE&#x27;&#xA;  const ref2 = &#x27;https://youtu.be/bRdyzdXJ0KA&#x27;;&#xA;&#xA;  function queueSong(src: string, stream: Readable): Promise<void>{&#xA;    return new Promise<void>((resolve, reject) => {&#xA;      ytdl(src, {&#xA;          filter: &#x27;audioonly&#x27;,&#xA;          quality: &#x27;highestaudio&#x27;&#xA;        })&#xA;        .on(&#x27;data&#x27;, (data) => {&#xA;          stream.push(data);&#xA;        })&#xA;        .on(&#x27;end&#x27;, () => {&#xA;          resolve();&#xA;        })&#xA;        .on(&#x27;error&#x27;, (err) => {&#xA;          console.error(&#x27;Error downloading file from YouTube.&#x27;, err);&#xA;          reject(err);&#xA;        })&#xA;    })&#xA;  }&#xA;  &#xA;  await queueSong(ref1, mainStream);&#xA;  // console.log(&#x27;after firsrt: &#x27;, mainStream)&#xA;  await queueSong(ref2, mainStream);&#xA;  // console.log(&#x27;after second: &#x27;, mainStream)&#xA;  return mainStream;&#xA;};&#xA;</void></void></readable></void>

    &#xA;

    To start, startAudioStream is called to initiate a readable stream of audio to an RTMP server via FFMPEG. That is working fine. The part I'm having trouble with is "queuing" the tracks into the stream that's being fed into FFMPEG. Right now, I have a "main" stream that each songs data is being pushed into, as you can see in queueSong. At the end of ytdl stream, the promise is resolved, allowing for the next song to be queued and its data to be pushed into mainStream. The issue that I'm experiencing is that the audio from ref1 is only every played.

    &#xA;

    I can see in the logs that mainStream does grow in length after each call to queueSong, but still will only stream the audio from the first track. My initial thought was that there is a terminating character at the of the last data chunk thats being written to the steam for each song ? But maybe im getting screwed up on how streams work...

    &#xA;