Recherche avancée

Médias (1)

Mot : - Tags -/bug

Autres articles (28)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • ANNEXE : Les extensions, plugins SPIP des canaux

    11 février 2010, par

    Un plugin est un ajout fonctionnel au noyau principal de SPIP. MediaSPIP consiste en un choix délibéré de plugins existant ou pas auparavant dans la communauté SPIP, qui ont pour certains nécessité soit leur création de A à Z, soit des ajouts de fonctionnalités.
    Les extensions que MediaSPIP nécessite pour fonctionner
    Depuis la version 2.1.0, SPIP permet d’ajouter des plugins dans le répertoire extensions/.
    Les "extensions" ne sont ni plus ni moins que des plugins dont la particularité est qu’ils se (...)

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

Sur d’autres sites (5642)

  • iOS FFmpeg : Requested output format 'flv' is not a suitable output format

    14 novembre 2013, par user2992563

    I just upgraded my iOS compiled FFmpeg library to 1.2.1 and now I'm getting the following error message :
    Requested output format 'flv' is not a suitable output format.

    I tried changing format to 'avi' and 'mov' aswell, but it seems that no matter the format_name I pass I get the same error message.

    This is how I set up the format_name :

    avformat_alloc_output_context2(&file, NULL, "flv", cname)

    And this is how I write the stream packets :

    // Appends a data packet to the rtmp stream
    -(bool) writePacket: (Demuxer *) source
    {
    int code = 0;

    AVCodecContext
    *videoCodec = [source videoCodec],
    *audioCodec = [source audioCodec];

    // Write headers
    if(useHeaders)
    {
       AVStream
       *video = av_new_stream(file, VIDEO_STREAM),
       *audio = av_new_stream(file, AUDIO_STREAM);

       if (!video || !audio)
           @throw [NSException exceptionWithName: @"StreamingError" reason: @"Could not allocate streams" userInfo: nil];

       // Clone input codecs and extra data
       memcpy(video->codec, videoCodec, sizeof(AVCodecContext));
       memcpy(audio->codec, audioCodec, sizeof(AVCodecContext));

       video->codec->extradata = av_malloc(video->codec->extradata_size);
       audio->codec->extradata = av_malloc(audio->codec->extradata_size);

       memcpy(video->codec->extradata, videoCodec->extradata, video->codec->extradata_size);
       memcpy(audio->codec->extradata, audioCodec->extradata, audio->codec->extradata_size);

       // Use FLV codec tags
       video->codec->codec_tag = FLV_TAG_TYPE_VIDEO;
       audio->codec->codec_tag = FLV_TAG_TYPE_AUDIO;
       video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
       video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
       audio->codec->sample_rate = INPUT_AUDIO_SAMPLING_RATE;

       // Update time base
       video->codec->time_base.num = 1;
       audio->codec->time_base.den = video->codec->time_base.den = FLV_TIMEBASE;

       // Signal bitwise stream copying
       //video->stream_copy = audio->stream_copy = 1;

       if((code = avformat_write_header(file, NULL)))
           @throw [NSException exceptionWithName: @"StreamingError" reason: @"Could not write stream headers" userInfo: nil];
       useHeaders = NO;
    }
    bool isVideo;
    AVPacket *packet = [source readPacket: &isVideo];

    if(!packet)
       return NO;

    if(isVideo)
    {
       packet->stream_index = VIDEO_STREAM;
       packet->dts = packet->pts = videoPosition;
       videoPosition += packet->duration = FLV_TIMEBASE * packet->duration * videoCodec->ticks_per_frame * videoCodec->time_base.num / videoCodec->time_base.den;
    }
    else
    {
       packet->stream_index = AUDIO_STREAM;
       packet->dts = packet->pts = audioPosition;
       audioPosition += packet->duration = FLV_TIMEBASE * packet->duration / INPUT_AUDIO_SAMPLING_RATE;
    }

    packet->pos = -1;
    packet->convergence_duration = AV_NOPTS_VALUE;

    // This sometimes fails without being a critical error, so no exception is raised
    if((code = av_interleaved_write_frame(file, packet)))
       NSLog(@"Streamer::Couldn't write frame");

    av_free_packet(packet);
    return YES;
    }

    In the code above I had to comment out this line as stream_copy has been removed from the newest version of FFmpeg :

    video->stream_copy = audio->stream_copy = 1;

    Any help would be greatly appreciated !

  • Mac Terminal (Bash) batch program to get multimedia file info using ffmpeg

    7 décembre 2013, par julesverne

    I have a Mac computer. Usually all my batch programming is done on my PC. So I tried to create what I assumed would be a simple equivalent using a Mac shell. Obviously as you all know that was foolish of me to think that. After 2 days of scowering the web I found the closest thing I could to what I was looking for. But no, this doesn't work either.

    All I'd like to do is throw a multimedia file onto the script, and have the terminal give me the ffmpeg info output. In my searching I did find this "$@" which as far as I can tell is the windows bat equivalent of %*. Meaning you can throw files on the script and the script refers to those files as variables which can be processed. So I believe what I want to do is possible.

    Again the code at the bottom is just to look through the current directory of all .mov files and run ffmpeg. It doesn't work. But.. if no one can help me figure out the actual thing I'd like to do then I'd settle with something like below that does actually work.

    #!/bin/bash
    FFMPEG=/Applications/ffmpeg
    FIND=/usr/bin/find
    FILES=$(${FIND} . -type f  -iname "*.mov")
    if [ "$FILES" == "" ]
    then
    echo "There are no *.mov file in $(pwd) directory"
    exit 1
    fi

    for f in *.mov
    do

    $FFMPEG -i "$f"

    done

    If someone can please help me figure this out I'd really appreciate it. Thank you in advance ! Jules

    I just found this solution from the "similar questions" sidebar, which is similar to the script above, so again, not completely what I wanted but.. didn't matter, didn't work for me. How to batch convert mp4 files to ogg with ffmpeg using a bash command or Ruby

  • FFmpeg Autogen and Unity C# to generate video from screenshots (FFmpeg.Autogen)

    1er juin 2022, par cameron gibbs

    I've taken the FFmpegHelper, VideoFrameConverter, H264VideoStreamEncoder classes straight from the FFmpeg.AutoGen.Example, rolled my own FFmpegBinariesHelper class and Size struct and mangled the EncodeImagesToH264 from Program.cs to look like the below code. I capture a bunch of frames into textures and feed them into Encoder.EncodeImagesToH264. It produces a file I'm calling outputFileName.h264 just fine, no errors. I've changed H264VideoStreamEncoder a little based on ffmpeg's own c++ examples because they had a few things it seemed the C# example was missing but that hasn't made any difference.

    


    The video is weird :

    


      

    1. it only plays in VLC, is there another AVPixelFormat I should be using for the destinationPixelFormat so that anything can play ?
    2. 


    3. VLC is unable to detect the video length or show current time
    4. 


    5. it plays back weird as if the first few seconds are all the same frame then starts playing what appears to be some of the frames I'd expect
    6. 


    


        public static class Encoder
    {
        public static unsafe void EncodeImagesToH264(Texture2D[] images, int fps, string outputFileName)
        {
            FFmpegBinariesHelper.RegisterFFmpegBinaries();

            var fistFrameImage = images[0];
            outputFileName = Path.ChangeExtension(outputFileName, ".h264");
            var sourceSize = new Size(fistFrameImage.width, fistFrameImage.height);
            var sourcePixelFormat = AVPixelFormat.AV_PIX_FMT_RGB24;
            var destinationSize = sourceSize;
            var destinationPixelFormat = AVPixelFormat.AV_PIX_FMT_YUV420P;

            try
            {
                using (var vfc = new VideoFrameConverter(
                    sourceSize,
                    sourcePixelFormat,
                    destinationSize,
                    destinationPixelFormat))
                {
                    using var fs = File.Open(outputFileName, FileMode.Create);
                    using var vse = new H264VideoStreamEncoder(fs, fps, destinationSize);
                    var frameNumber = 0;
                    foreach (var frameFile in images)
                    {
                        var bitmapData = GetBitmapData(frameFile);

                        //var pBitmapData = (byte*)NativeArrayUnsafeUtility
                        //    .GetUnsafeBufferPointerWithoutChecks(bitmapData);

                        fixed (byte* pBitmapData = bitmapData)
                        {
                            var data = new byte_ptrArray8 { [0] = pBitmapData };
                            var linesize = new int_array8 { [0] = bitmapData.Length / sourceSize.Height };
                            var frame = new AVFrame
                            {
                                data = data,
                                linesize = linesize,
                                height = sourceSize.Height
                            };

                            var convertedFrame = vfc.Convert(frame);
                            convertedFrame.pts = frameNumber;

                            vse.Encode(convertedFrame);

                            Debug.Log($"frame: {frameNumber}");
                            frameNumber++;
                        }
                    }
                    byte[] endcode = { 0, 0, 1, 0xb7 };
                    fs.Write(endcode, 0, endcode.Length);
                }
                Debug.Log(outputFileName);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }

        private static byte[] GetBitmapData(Texture2D frameBitmap)
        {
            return frameBitmap.GetRawTextureData();
        }
    }

    public sealed unsafe class H264VideoStreamEncoder : IDisposable
    {
        private readonly Size _frameSize;
        private readonly int _linesizeU;
        private readonly int _linesizeV;
        private readonly int _linesizeY;
        private readonly AVCodec* _pCodec;
        private readonly AVCodecContext* _pCodecContext;
        private readonly Stream _stream;
        private readonly int _uSize;
        private readonly int _ySize;

        public H264VideoStreamEncoder(Stream stream, int fps, Size frameSize)
        {
            _stream = stream;
            _frameSize = frameSize;

            var codecId = AVCodecID.AV_CODEC_ID_H264;
            _pCodec = ffmpeg.avcodec_find_encoder(codecId);
            if (_pCodec == null)
                throw new InvalidOperationException("Codec not found.");

            _pCodecContext = ffmpeg.avcodec_alloc_context3(_pCodec);
            _pCodecContext->bit_rate = 400000;
            _pCodecContext->width = frameSize.Width;
            _pCodecContext->height = frameSize.Height;
            _pCodecContext->time_base = new AVRational { num = 1, den = fps };
            _pCodecContext->gop_size = 10;
            _pCodecContext->max_b_frames = 1;
            _pCodecContext->pix_fmt = AVPixelFormat.AV_PIX_FMT_YUV420P;

            if (codecId == AVCodecID.AV_CODEC_ID_H264)
                ffmpeg.av_opt_set(_pCodecContext->priv_data, "preset", "veryslow", 0);

            ffmpeg.avcodec_open2(_pCodecContext, _pCodec, null).ThrowExceptionIfError();

            _linesizeY = frameSize.Width;
            _linesizeU = frameSize.Width / 2;
            _linesizeV = frameSize.Width / 2;

            _ySize = _linesizeY * frameSize.Height;
            _uSize = _linesizeU * frameSize.Height / 2;
        }

        public void Dispose()
        {
            ffmpeg.avcodec_close(_pCodecContext);
            ffmpeg.av_free(_pCodecContext);
        }

        public void Encode(AVFrame frame)
        {
            if (frame.format != (int)_pCodecContext->pix_fmt)
                throw new ArgumentException("Invalid pixel format.", nameof(frame));
            if (frame.width != _frameSize.Width)
                throw new ArgumentException("Invalid width.", nameof(frame));
            if (frame.height != _frameSize.Height)
                throw new ArgumentException("Invalid height.", nameof(frame));
            if (frame.linesize[0] < _linesizeY)
                throw new ArgumentException("Invalid Y linesize.", nameof(frame));
            if (frame.linesize[1] < _linesizeU)
                throw new ArgumentException("Invalid U linesize.", nameof(frame));
            if (frame.linesize[2] < _linesizeV)
                throw new ArgumentException("Invalid V linesize.", nameof(frame));
            if (frame.data[1] - frame.data[0] < _ySize)
                throw new ArgumentException("Invalid Y data size.", nameof(frame));
            if (frame.data[2] - frame.data[1] < _uSize)
                throw new ArgumentException("Invalid U data size.", nameof(frame));

            var pPacket = ffmpeg.av_packet_alloc();
            try
            {
                int error;
                do
                {
                    ffmpeg.avcodec_send_frame(_pCodecContext, &frame).ThrowExceptionIfError();
                    ffmpeg.av_packet_unref(pPacket);
                    error = ffmpeg.avcodec_receive_packet(_pCodecContext, pPacket);
                } while (error == ffmpeg.AVERROR(ffmpeg.EAGAIN));

                error.ThrowExceptionIfError();

                using var packetStream = new UnmanagedMemoryStream(pPacket->data, pPacket->size);
                packetStream.CopyTo(_stream);
            }
            finally
            {
                ffmpeg.av_packet_free(&pPacket);
            }
        }
    }