Recherche avancée

Médias (91)

Autres articles (102)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • L’agrémenter visuellement

    10 avril 2011

    MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
    Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (8056)

  • Test if YouTube stream key is still active

    17 avril 2022, par codingmaster398

    I'm making a service to stream to YouTube, simply put.

    


    If the live stream ends or the stream key is no longer being used, we need to know. So far, it plays a short 3 second clip every once in a while, and if FFMpeg stops before it streams, we assume that the stream key is invalid. However, once we start a stream with the correct stream key, then end it and reset the stream key in another stream, the stream key still is being picked up as active.

    


    Is there any API to see if the stream key is still being used ?

    


  • Is there any way to publish a video stream on an existing RTSP server without FFMPEG

    19 mai 2022, par Vinit

    I am currently working on a program that plays a MP4 video on disk on a RTSP server. I have created a simple RTSP server and I can publish the stream on it using FFMPEG but I was wondering if there was a less complicated way to publish the stream on the server so I can put that into the batch file and I won't have to use FFMPEG everytime.

    


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