Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (44)

  • Modifier la date de publication

    21 juin 2013, par

    Comment changer la date de publication d’un média ?
    Il faut au préalable rajouter un champ "Date de publication" dans le masque de formulaire adéquat :
    Administrer > Configuration des masques de formulaires > Sélectionner "Un média"
    Dans la rubrique "Champs à ajouter, cocher "Date de publication "
    Cliquer en bas de la page sur Enregistrer

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
    sur le web 2.0 et dans les entreprises qui en vivent.
    Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
    Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
    le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
    Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

Sur d’autres sites (6694)

  • 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')


    


  • 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 auto rotate video when copying video stream without re-encoding

    25 février 2019, par Mahfujur Rahman

    I have been trying to convert an mp4 (portrait) file to mkv. As the mkv container support any video and audio stream, I am copying the audio and video stream to the output container. The command I’m using

    ffmpeg -y -i test.mp4 -vcodec copy -acodec copy test.mkv

    File info for test.mp4 is following

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: isommp42
       creation_time   : 2019-02-23T11:18:50.000000Z
       com.android.version: 8.0.0
     Duration: 00:00:25.86, start: 0.000000, bitrate: 12270 kb/s
       Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 12005 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
       Metadata:
         rotate          : 90
         creation_time   : 2019-02-23T11:18:50.000000Z
         handler_name    : VideoHandle
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
       Metadata:
         creation_time   : 2019-02-23T11:18:50.000000Z
         handler_name    : SoundHandle

    Now, the problem is that the output video I get from ffmpeg is a 90 degree counter clockwise rotated video. The reason I believe is the following info being removed from output file,

    Side data:
    displaymatrix: rotation of -90.00 degrees

    File info for rotated output file test.mkv

    Input #0, matroska,webm, from 'test.mkv':
     Metadata:
       MAJOR_BRAND     : mp42
       MINOR_VERSION   : 0
       COMPATIBLE_BRANDS: isommp42
       COM.ANDROID.VERSION: 8.0.0
       ENCODER         : Lavf58.12.100
     Duration: 00:00:25.87, start: 0.000000, bitrate: 12265 kb/s
       Stream #0:0(eng): Video: h264, yuv420p(tv, bt709, progressive), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 2k tbc (default)
       Metadata:
         ROTATE          : 90
         HANDLER_NAME    : VideoHandle
         DURATION        : 00:00:25.866000000
       Stream #0:1(eng): Audio: aac, 48000 Hz, stereo, fltp (default)
       Metadata:
         HANDLER_NAME    : SoundHandle
         DURATION        : 00:00:25.813000000

    But when I convert this rotated output test.mkv to mp4 again, I get the portrait file. The displaymatrix side data appears again in the file info.

    Converting the same mp4 file to m4v by copying the steam works fine.

    So, this whole thing is very much confusing to me.

    Now my question is, how can I convert the mp4 file to mkv without re-encoding and avoid getting rotated output ?

    In this post they solved it for c++. I am working on android and using ffmpeg android wrapper to use the ffmpeg library. Is there any ffmpeg flag to handle this situation ?