Recherche avancée

Médias (0)

Mot : - Tags -/protocoles

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

Autres articles (55)

  • MediaSPIP en mode privé (Intranet)

    17 septembre 2013, par

    À partir de la version 0.3, un canal de MediaSPIP peut devenir privé, bloqué à toute personne non identifiée grâce au plugin "Intranet/extranet".
    Le plugin Intranet/extranet, lorsqu’il est activé, permet de bloquer l’accès au canal à tout visiteur non identifié, l’empêchant d’accéder au contenu en le redirigeant systématiquement vers le formulaire d’identification.
    Ce système peut être particulièrement utile pour certaines utilisations comme : Atelier de travail avec des enfants dont le contenu ne doit pas (...)

  • Formulaire personnalisable

    21 juin 2013, par

    Cette page présente les champs disponibles dans le formulaire de publication d’un média et il indique les différents champs qu’on peut ajouter. Formulaire de création d’un Media
    Dans le cas d’un document de type média, les champs proposés par défaut sont : Texte Activer/Désactiver le forum ( on peut désactiver l’invite au commentaire pour chaque article ) Licence Ajout/suppression d’auteurs Tags
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire. (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (7306)

  • How to decode mp3 to raw sample data for FFMpeg using FFMediaToolkit

    28 décembre 2022, par Lee

    My objective is to create a video slideshow with audio using a database as the source. The final implementation video and audio inputs need to be memory streams or byte arrays, not a file system path. The sample code is file based for portability. It's just trying to read a file based mp3 then write it to the output.

    


    I've tried a few FFMpeg wrappers and I'm open to alternatives. This code is using FFMediaToolkit. The video portion of the code works. It's the audio that I can't get to work.

    


    The input is described as "A 2D jagged array of multi-channel sample data with NumChannels rows and NumSamples columns." The datatype is float[][].

    


    My mp3 source is mono. I'm using NAudio.Wave to decode the mp3. It is then split into chunks equal to the frame size for the sample rate. It is then converted into the jagged float with the data on channel 0.

    


    The FFMpeg decoder displays a long list of "buffer underflow" and "packet too large, ignoring buffer limits to mux it". C# returns "Specified argument was out of the range of valid values." The offending line of code being "file.Audio.AddFrame(frameAudio)".

    


    The source is 16 bit samples. The PCM_S16BE codec is the only one that I could get to accept 16 bit sample format. I could only get the MP3 encoder to work with "Signed 32-bit integer (planar)" as the sample format. I'm not certain if the source data needs to be converted from 16 to 32 bit to use the codec.

    


    `

    


    using FFMediaToolkit;
using FFMediaToolkit.Decoding;
using FFMediaToolkit.Encoding;
using FFMediaToolkit.Graphics;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FFMediaToolkit.Audio;
using NAudio.Wave;
using FFmpeg.AutoGen;

    internal class FFMediaToolkitTest
    {
        const int frameRate = 30;
        const int vWidth = 1920;
        const int vHeight = 1080;
        const int aSampleRate = 24_000; // source sample rate
        //const int aSampleRate = 44_100;
        const int aSamplesPerFrame = aSampleRate / frameRate;
        const int aBitRate = 32_000;
        const string dirInput = @"D:\Websites\Vocabulary\Videos\source\";
        const string pathOutput = @"D:\Websites\Vocabulary\Videos\example.mpg";

        public FFMediaToolkitTest()
        {
            try
            {
                FFmpegLoader.FFmpegPath = ".";  //  FFMpeg  DLLs in root project directory
                var settings = new VideoEncoderSettings(width: vWidth, height: vHeight, framerate: frameRate, codec: VideoCodec.H264);
                settings.EncoderPreset = EncoderPreset.Fast;
                settings.CRF = 17;

                //var settingsAudio = new AudioEncoderSettings(aSampleRate, 1, (AudioCodec)AVCodecID.AV_CODEC_ID_PCM_S16BE);  // Won't run with low bitrate.
                var settingsAudio = new AudioEncoderSettings(aSampleRate, 1, AudioCodec.MP3); // mpg runs with SampleFormat.SignedDWordP
                settingsAudio.Bitrate = aBitRate;
                //settingsAudio.SamplesPerFrame = aSamplesPerFrame;
                settingsAudio.SampleFormat = SampleFormat.SignedDWordP;

                using (var file = MediaBuilder.CreateContainer(pathOutput).WithVideo(settings).WithAudio(settingsAudio).Create())
                {
                    var files = Directory.GetFiles(dirInput, "*.jpg");
                    foreach (var inputFile in files)
                    {
                        Console.WriteLine(inputFile);
                        var binInputFile = File.ReadAllBytes(inputFile);
                        var memInput = new MemoryStream(binInputFile);
                        var bitmap = Bitmap.FromStream(memInput) as Bitmap;
                        var rect = new System.Drawing.Rectangle(System.Drawing.Point.Empty, bitmap.Size);
                        var bitLock = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                        var bitmapData = ImageData.FromPointer(bitLock.Scan0, ImagePixelFormat.Bgr24, bitmap.Size);

                        for (int i = 0; i < 60; i++)
                            file.Video.AddFrame(bitmapData); 
                        bitmap.UnlockBits(bitLock);
                    }

                    var mp3files = Directory.GetFiles(dirInput, "*.mp3");
                    foreach (var inputFile in mp3files)
                    {
                        Console.WriteLine(inputFile);
                        var binInputFile = File.ReadAllBytes(inputFile);
                        var memInput = new MemoryStream(binInputFile);

                        foreach (float[][] frameAudio in GetFrames(memInput))
                        {
                            file.Audio.AddFrame(frameAudio); // encode the frame
                        }
                    }
                    //Console.WriteLine(file.Audio.CurrentDuration);
                    Console.WriteLine(file.Video.CurrentDuration);
                    Console.WriteLine(file.Video.Configuration);
                }
            }
            catch (Exception e)
            {
                Vocab.LogError("FFMediaToolkitTest", e.StackTrace + " " + e.Message);
                Console.WriteLine(e.StackTrace + " " + e.Message);
            }

            Console.WriteLine();
            Console.WriteLine("Done");
            Console.ReadLine();
        }


        public static List GetFrames(MemoryStream mp3stream)
        {
            List output = new List();
            
            int frameCount = 0;

            NAudio.Wave.StreamMediaFoundationReader smfReader = new StreamMediaFoundationReader(mp3stream);
            Console.WriteLine(smfReader.WaveFormat);
            Console.WriteLine(smfReader.WaveFormat.AverageBytesPerSecond); //48000
            Console.WriteLine(smfReader.WaveFormat.BitsPerSample);  // 16
            Console.WriteLine(smfReader.WaveFormat.Channels);  // 1 
            Console.WriteLine(smfReader.WaveFormat.SampleRate);     //24000

            Console.WriteLine("PCM bytes: " + smfReader.Length);
            Console.WriteLine("Total Time: " + smfReader.TotalTime);

            int samplesPerFrame = smfReader.WaveFormat.SampleRate / frameRate;
            int bytesPerFrame = samplesPerFrame * smfReader.WaveFormat.BitsPerSample / 8;
            byte[] byteBuffer = new byte[bytesPerFrame];

            while (smfReader.Read(byteBuffer, 0, bytesPerFrame) != 0)
            {
                float[][] buffer = Convert16BitToFloat(byteBuffer);
                output.Add(buffer);
                frameCount++;
            }
            return output;
        }

        public static float[][] Convert16BitToFloat(byte[] input)
        {
            // Only works with single channel data
            int inputSamples = input.Length / 2;
            float[][] output = new float[1][]; 
            output[0] = new float[inputSamples];
            int outputIndex = 0;
            for (int n = 0; n < inputSamples; n++)
            {
                short sample = BitConverter.ToInt16(input, n * 2);
                output[0][outputIndex++] = sample / 32768f;
            }
            return output;
        }

    }




    


    `

    


    I've tried multiple codecs with various settings. I couldn't get any of the codecs to accept a mp4 output file extension. FFMpeg will run but error out with mpg as the output file.

    


  • how to add duration to mjpeg or how to make mjpeg faster

    10 octobre 2014, par n2v2rda2

    i have ip-cam mjpeg that i made and it have total 240 frames

    encode souce is
    ffmpeg.exe -framerate 25 -i c :\%06d.jpg\ -s 1920x1080 -qscale 1 -vcodec mjpeg -r 25 C :\result.mjpg -y

    now i want to play result.mjpg by mjpeg player i made

    my problem
    1. i can't get mjpeg's play time or duration time

    2. playing is slower then other movie player so i want to sync it and play more faster

    below is ffprobe result

    Input #0, mjpeg, from 'result.mjpg':
    Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg), 1920x1080, 25 tbr, 1200k tbn, 25 tbc

    below is result added -show_frame

    [FRAME]
    media_type=video
    key_frame=1
    pkt_pts=720000
    pkt_pts_time=0.600000
    pkt_dts=720000
    pkt_dts_time=0.600000
    best_effort_timestamp=720000
    best_effort_timestamp_time=0.600000
    pkt_duration=48000
    pkt_duration_time=0.040000
    pkt_pos=4731406
    pkt_size=313289
    width=1920
    height=1080
    pix_fmt=yuvj444p
    sample_aspect_ratio=333:320
    pict_type=I
    coded_picture_number=0
    display_picture_number=0
    interlaced_frame=0
    top_field_first=0
    repeat_pict=0
    [/FRAME]

    ffprobe show me there are Duration : N/A, bitrate : N/A

    how do i set Duration and bitrate
    is there any encode-option i have to set ?

    when i decode mjpeg like below

    i can’t get duration just 0

    AVFormatContext*  pFC;
    int               ret;

    pFC = avformat_alloc_context();

    ret  = avformat_open_input(&pFC, filename, NULL, NULL);
    if (ret < 0) {
       // fail .
    }

    ret  = avformat_find_stream_info(pFC, NULL);
    if (ret < 0) {
       // fail
    }
    printf("duration %ld", pFC->duration);   <----- only 0
  • ffmpeg - creating segments of equivalent duration

    13 octobre 2014, par Code_Ed_Student

    I am testing out segment to split a video into segments of 10 seconds each, but I’m noticing some unusual results. In particular, some of the segments generated have varying lengths from 5 seconds to 11 seconds. I’ve tried playing around with segment_time_delta and force_key_frames to make the segments as close to 10 seconds as possible, but it doesn’t seem to be working out so well. How could I make all segments the same duration ?

    ffmpeg -i input.mp4 -force_key_frames 10,20,30,40,50,60,70,80,90,100,110,120 -c copy -map 0 -segment_time 10 -f segment output%01d.mp4

    Results :

    My_vid.mp4 – total duration - 00:02:08
    Output1.mp4 00:00:07
    Output2.mp4 00:00:07
    Output3.mp4 00:00:08
    Output4.mp4 00:00:08
    Output5.mp4 00:00:09
    Output6.mp4 00:00:09
    Output7.mp4 00:00:10
    Output8.mp4 00:00:10
    Output9.mp4 00:00:10
    Output10.mp4 00:00:11
    Output11.mp4  00:00:11
    Output12.mp4 00:00:11
    Output12.mp4 00:00:13