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 (47)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Qu’est ce qu’un éditorial

    21 juin 2013, par

    Ecrivez votre de point de vue dans un article. Celui-ci sera rangé dans une rubrique prévue à cet effet.
    Un éditorial est un article de type texte uniquement. Il a pour objectif de ranger les points de vue dans une rubrique dédiée. Un seul éditorial est placé à la une en page d’accueil. Pour consulter les précédents, consultez la rubrique dédiée.
    Vous pouvez personnaliser le formulaire de création d’un éditorial.
    Formulaire de création d’un éditorial Dans le cas d’un document de type éditorial, les (...)

Sur d’autres sites (8780)

  • Precise method of segmenting & transcoding video+audio (via ffmpeg), into an on-demand HLS stream ?

    17 novembre 2019, par Felix

    recently I’ve been messing around with FFMPEG and streams through Nodejs. My ultimate goal is to serve a transcoded video stream - from any input filetype - via HTTP, generated in real-time as it’s needed in segments.

    I’m currently attempting to handle this using HLS. I pre-generate a dummy m3u8 manifest using the known duration of the input video. It contains a bunch of URLs that point to individual constant-duration segments. Then, once the client player starts requesting the individual URLs, I use the requested path to determine which time range of video the client needs. Then I transcode the video and stream that segment back to them.

    Now for the problem : This approach mostly works, but has a small audio bug. Currently, with most test input files, my code produces a video that - while playable - seems to have a very small (< .25 second) audio skip at the start of each segment.

    I think this may be an issue with splitting using time in ffmpeg, where possibly the audio stream cannot be accurately sliced at the exact frame the video is. So far, I’ve been unable to figure out a solution to this problem.

    If anybody has any direction they can steer me - or even a prexisting library/server that solves this use-case - I appreciate the guidance. My knowledge of video encoding is fairly limited.

    I’ll include an example of my relevant current code below, so others can see where I’m stuck. You should be able to run this as a Nodejs Express server, then point any HLS player at localhost:8080/master to load the manifest and begin playback. See the transcode.get('/segment/:seg.ts' line at the end, for the relevant transcoding bit.

    'use strict';
    const express = require('express');
    const ffmpeg = require('fluent-ffmpeg');
    let PORT = 8080;
    let HOST = 'localhost';
    const transcode = express();


    /*
    * This file demonstrates an Express-based server, which transcodes &amp; streams a video file.
    * All transcoding is handled in memory, in chunks, as needed by the player.
    *
    * It works by generating a fake manifest file for an HLS stream, at the endpoint "/m3u8".
    * This manifest contains links to each "segment" video clip, which browser-side HLS players will load as-needed.
    *
    * The "/segment/:seg.ts" endpoint is the request destination for each clip,
    * and uses FFMpeg to generate each segment on-the-fly, based off which segment is requested.
    */


    const pathToMovie = 'C:\\input-file.mp4';  // The input file to stream as HLS.
    const segmentDur = 5; //  Controls the duration (in seconds) that the file will be chopped into.


    const getMetadata = async(file) => {
       return new Promise( resolve => {
           ffmpeg.ffprobe(file, function(err, metadata) {
               console.log(metadata);
               resolve(metadata);
           });
       });
    };



    // Generate a "master" m3u8 file, which the player should point to:
    transcode.get('/master', async(req, res) => {
       res.set({"Content-Disposition":"attachment; filename=\"m3u8.m3u8\""});
       res.send(`#EXTM3U
    #EXT-X-STREAM-INF:BANDWIDTH=150000
    /m3u8?num=1
    #EXT-X-STREAM-INF:BANDWIDTH=240000
    /m3u8?num=2`)
    });

    // Generate an m3u8 file to emulate a premade video manifest. Guesses segments based off duration.
    transcode.get('/m3u8', async(req, res) => {
       let met = await getMetadata(pathToMovie);
       let duration = met.format.duration;

       let out = '#EXTM3U\n' +
           '#EXT-X-VERSION:3\n' +
           `#EXT-X-TARGETDURATION:${segmentDur}\n` +
           '#EXT-X-MEDIA-SEQUENCE:0\n' +
           '#EXT-X-PLAYLIST-TYPE:VOD\n';

       let splits = Math.max(duration / segmentDur);
       for(let i=0; i&lt; splits; i++){
           out += `#EXTINF:${segmentDur},\n/segment/${i}.ts\n`;
       }
       out+='#EXT-X-ENDLIST\n';

       res.set({"Content-Disposition":"attachment; filename=\"m3u8.m3u8\""});
       res.send(out);
    });

    // Transcode the input video file into segments, using the given segment number as time offset:
    transcode.get('/segment/:seg.ts', async(req, res) => {
       const segment = req.params.seg;
       const time = segment * segmentDur;

       let proc = new ffmpeg({source: pathToMovie})
           .seekInput(time)
           .duration(segmentDur)
           .outputOptions('-preset faster')
           .outputOptions('-g 50')
           .outputOptions('-profile:v main')
           .withAudioCodec('aac')
           .outputOptions('-ar 48000')
           .withAudioBitrate('155k')
           .withVideoBitrate('1000k')
           .outputOptions('-c:v h264')
           .outputOptions(`-output_ts_offset ${time}`)
           .format('mpegts')
           .on('error', function(err, st, ste) {
               console.log('an error happened:', err, st, ste);
           }).on('progress', function(progress) {
               console.log(progress);
           })
           .pipe(res, {end: true});
    });

    transcode.listen(PORT, HOST);
    console.log(`Running on http://${HOST}:${PORT}`);
  • libav : Store h264 frames in mp4 container

    25 janvier 2024, par ImJustACowLol

    I'm making a C++ application that retrieves frames from a camera and then encodes each frame with a H264 encoder (not using libav). This encoded H264 frame is then kept in memory as a void *mem as I need to do several things with the encoded frame.

    &#xA;

    One of the things I need to do, is store the frames (so the void *mem pointers) in a .mp4 container using libavcodec/libavformat. I do NOT want to transcode each frame, I just want to store them directly into the mp4 container.

    &#xA;

    Preferably for each individual frame that I push through, I get the resulting data as a return type from the function (not sure if this is possible ?). If this is not possible, then writing to a file directly is OK as well.

    &#xA;

    How does one go about doing this with libav ?

    &#xA;

    The only part I have got so far, and where I'm getting stuck, is this :

    &#xA;

    /*&#xA;some private fields accessible in MP4Muxer:&#xA;int frameWidth_, frameHeight_, frameRate_, srcBitRate_;&#xA;*/&#xA;&#xA;&#xA;void MP4Muxer::muxFrame(void *mem, size_t len, int64_t timestamp, bool keyFrame) {&#xA;    const AVOutputFormat* outputFormat = av_guess_format("mp4", NULL, NULL);&#xA;    AVFormatContext* outputFormatContext = avformat_alloc_context();&#xA;    outputFormatContext->oformat = outputFormat;&#xA;    AVStream* videoStream = avformat_new_stream(outputFormatContext, NULL);&#xA;&#xA;    videoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    videoStream->codecpar->codec_id = AV_CODEC_ID_H264;&#xA;    videoStream->codecpar->width = frameWidth_;&#xA;    videoStream->codecpar->height = frameHeight_;&#xA;    videoStream->avg_frame_rate = (AVRational) {frameRate_, 1};&#xA;    videoStream->time_base = (AVRational) {1, 90000};&#xA;&#xA;}&#xA;

    &#xA;

    How do I continue from here ? Are there any good resources I can follow ? There are some resources I found online, but all of them either write the output directly to a file, read input directly from streams/files etc. so I have a hard time translating them to my needs.

    &#xA;

  • movenc : Add a flag for indicating a discontinuous fragment

    20 novembre 2014, par Martin Storsjö
    movenc : Add a flag for indicating a discontinuous fragment
    

    This allows creating a later mp4 fragment without sequentially
    writing the earlier ones before (when called from a segmenter).

    Normally when writing a fragmented mp4 file sequentially, the
    first timestamps of a fragment are adjusted to match the
    end of the previous fragment, to make sure the timestamp is the
    same, even if it is calculated as the sum of previous fragment
    durations. (And for the first packet in a file, the offset of
    the first packet is written using an edit list.)

    When writing an individual mp4 fragment discontinuously like this
    (with potentially writing the earlier fragments separately later),
    there’s a risk of getting a gap in the timeline if the duration
    field of the last packet in the previous fragment doesn’t match up
    with the start time of the next fragment.

    Using this requires setting -avoid_negative_ts make_non_negative
    (or -avoid_negative_ts 0).

    Signed-off-by : Martin Storsjö <martin@martin.st>

    • [DBH] libavformat/movenc.c
    • [DBH] libavformat/movenc.h