Recherche avancée

Médias (91)

Autres articles (51)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

  • Submit enhancements and plugins

    13 avril 2011

    If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
    You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.

Sur d’autres sites (6145)

  • FFMPEG AAC encoding causes audio to be lower in pitch

    14 février 2017, par Paul Knopf

    I built a sample application that encodes AAC (from PortAudio) into a MP4 container (no video stream).

    The resulting audio is lower in pitch.

    #include "stdafx.h"
    #include "TestRecording.h"
    #include "libffmpeg.h"

    TestRecording::TestRecording()
    {
    }


    TestRecording::~TestRecording()
    {
    }

    struct RecordingContext
    {
       RecordingContext()
       {
           formatContext = NULL;
           audioStream = NULL;
           audioFrame = NULL;
           audioFrameframeNumber = 0;
       }

       libffmpeg::AVFormatContext* formatContext;
       libffmpeg::AVStream* audioStream;
       libffmpeg::AVFrame* audioFrame;
       int audioFrameframeNumber;
    };

    static int AudioRecordCallback(const void *inputBuffer, void *outputBuffer,
       unsigned long framesPerBuffer,
       const PaStreamCallbackTimeInfo* timeInfo,
       PaStreamCallbackFlags statusFlags,
       void *userData)
    {
       RecordingContext* recordingContext = (RecordingContext*)userData;

       libffmpeg::avcodec_fill_audio_frame(recordingContext->audioFrame,
           recordingContext->audioFrame->channels,
           recordingContext->audioStream->codec->sample_fmt,
           static_cast<const unsigned="unsigned">(inputBuffer),
           (framesPerBuffer * sizeof(float) * recordingContext->audioFrame->channels),
           0);

       libffmpeg::AVPacket pkt;
       libffmpeg::av_init_packet(&amp;pkt);
       pkt.data = NULL;
       pkt.size = 0;

       int gotpacket;
       int result = avcodec_encode_audio2(recordingContext->audioStream->codec, &amp;pkt, recordingContext->audioFrame, &amp;gotpacket);

       if (result &lt; 0)
       {
           LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't encode the audio frame to acc");
           return paContinue;
       }

       if (gotpacket)
       {
           pkt.stream_index = recordingContext->audioStream->index;
           recordingContext->audioFrameframeNumber++;

           // this codec requires no bitstream filter, just send it to the muxer!
           result = libffmpeg::av_write_frame(recordingContext->formatContext, &amp;pkt);
           if (result &lt; 0)
           {
               LOG(ERROR) &lt;&lt; "Couldn't write the encoded audio frame";
               libffmpeg::av_free_packet(&amp;pkt);
               return paContinue;
           }

           libffmpeg::av_free_packet(&amp;pkt);
       }

       return paContinue;
    }

    static bool InitializeRecordingContext(RecordingContext* recordingContext)
    {
       int result = libffmpeg::avformat_alloc_output_context2(&amp;recordingContext->formatContext, NULL, NULL, "C:\\Users\\Paul\\Desktop\\test.mp4");
       if (result &lt; 0)
       {
           LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't create output format context");
           return false;
       }

       libffmpeg::AVCodec *audioCodec;
       audioCodec = libffmpeg::avcodec_find_encoder(libffmpeg::AV_CODEC_ID_AAC);
       if (audioCodec == NULL)
       {
           LOG(ERROR) &lt;&lt; "Couldn't find the encoder for AAC";
       }

       recordingContext->audioStream = libffmpeg::avformat_new_stream(recordingContext->formatContext, audioCodec);
       if (!recordingContext->audioStream)
       {
           LOG(ERROR) &lt;&lt; "Couldn't create the audio stream";
           return false;
       }

       recordingContext->audioStream->codec->bit_rate = 64000;
       recordingContext->audioStream->codec->sample_fmt = libffmpeg::AV_SAMPLE_FMT_FLTP;
       recordingContext->audioStream->codec->sample_rate = 48000;
       recordingContext->audioStream->codec->channel_layout = AV_CH_LAYOUT_STEREO;
       recordingContext->audioStream->codec->channels = libffmpeg::av_get_channel_layout_nb_channels(recordingContext->audioStream->codec->channel_layout);

       recordingContext->audioStream->codecpar->bit_rate = recordingContext->audioStream->codec->bit_rate;
       recordingContext->audioStream->codecpar->format = recordingContext->audioStream->codec->sample_fmt;
       recordingContext->audioStream->codecpar->sample_rate = recordingContext->audioStream->codec->sample_rate;
       recordingContext->audioStream->codecpar->channel_layout = recordingContext->audioStream->codec->channel_layout;
       recordingContext->audioStream->codecpar->channels = recordingContext->audioStream->codec->channels;

       result = libffmpeg::avcodec_open2(recordingContext->audioStream->codec, audioCodec, NULL);
       if (result &lt; 0)
       {
           LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't open the audio codec");
           return false;
       }

       // create a new frame to store the audio samples
       recordingContext->audioFrame = libffmpeg::av_frame_alloc();
       if (!recordingContext->audioFrame)
       {
           LOG(ERROR) &lt;&lt; "Couldn't alloce the output audio frame";
           return false;
       }

       recordingContext->audioFrame->nb_samples = recordingContext->audioStream->codec->frame_size;
       recordingContext->audioFrame->channel_layout = recordingContext->audioStream->codec->channel_layout;
       recordingContext->audioFrame->channels = recordingContext->audioStream->codec->channels;
       recordingContext->audioFrame->format = recordingContext->audioStream->codec->sample_fmt;
       recordingContext->audioFrame->sample_rate = recordingContext->audioStream->codec->sample_rate;

       result = libffmpeg::av_frame_get_buffer(recordingContext->audioFrame, 0);
       if (result &lt; 0)
       {
           LOG(ERROR) &lt;&lt; "Coudln't initialize the output audio frame buffer";
           return false;
       }

       // some formats want video_stream headers to be separate  
       if (!strcmp(recordingContext->formatContext->oformat->name, "mp4") || !strcmp(recordingContext->formatContext->oformat->name, "mov") || !strcmp(recordingContext->formatContext->oformat->name, "3gp"))
       {
           recordingContext->audioStream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }

       // open the ouput file
       if (!(recordingContext->formatContext->oformat->flags &amp; AVFMT_NOFILE))
       {
           result = libffmpeg::avio_open(&amp;recordingContext->formatContext->pb, recordingContext->formatContext->filename, AVIO_FLAG_WRITE);
           if (result &lt; 0)
           {
               LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't open the output file");
               return false;
           }
       }

       // write the stream headers
       result = libffmpeg::avformat_write_header(recordingContext->formatContext, NULL);
       if (result &lt; 0)
       {
           LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't write the headers to the file");
           return false;
       }

       return true;
    }

    static bool FinalizeRecordingContext(RecordingContext* recordingContext)
    {
       int result = 0;

       // write the trailing information
       if (recordingContext->formatContext->pb)
       {
           result = libffmpeg::av_write_trailer(recordingContext->formatContext);
           if (result &lt; 0)
           {
               LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't write the trailer information");
               return false;
           }
       }

       // close all the codes
       for (int i = 0; i &lt; (int)recordingContext->formatContext->nb_streams; i++)
       {
           result = libffmpeg::avcodec_close(recordingContext->formatContext->streams[i]->codec);
           if (result &lt; 0)
           {
               LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't close the codec");
               return false;
           }
       }

       // close the output file
       if (recordingContext->formatContext->pb)
       {
           if (!(recordingContext->formatContext->oformat->flags &amp; AVFMT_NOFILE))
           {
               result = libffmpeg::avio_close(recordingContext->formatContext->pb);
               if (result &lt; 0)
               {
                   LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't close the output file");
                   return false;
               }
           }
       }

       // free the format context and all of its data
       libffmpeg::avformat_free_context(recordingContext->formatContext);

       recordingContext->formatContext = NULL;
       recordingContext->audioStream = NULL;

       if (recordingContext->audioFrame)
       {
           libffmpeg::av_frame_free(&amp;recordingContext->audioFrame);
           recordingContext->audioFrame = NULL;
       }

       return true;
    }

    int TestRecording::Test()
    {
       PaError result = paNoError;

       result = Pa_Initialize();
       if (result != paNoError) LOGINT_WITH_MESSAGE(ERROR, result, "Error initializing audio device framework");

       RecordingContext recordingContext;
       if (!InitializeRecordingContext(&amp;recordingContext))
       {
           LOG(ERROR) &lt;&lt; "Couldn't start recording file";
           return 0;
       }

       auto defaultDevice = Pa_GetDefaultInputDevice();
       auto deviceInfo = Pa_GetDeviceInfo(defaultDevice);

       PaStreamParameters  inputParameters;
       inputParameters.device = defaultDevice;
       inputParameters.channelCount = 2;
       inputParameters.sampleFormat = paFloat32;
       inputParameters.suggestedLatency = deviceInfo->defaultLowInputLatency;
       inputParameters.hostApiSpecificStreamInfo = NULL;

       PaStream* stream = NULL;
       result = Pa_OpenStream(
           &amp;stream,
           &amp;inputParameters,
           NULL,
           48000,
           1024,
           paClipOff,
           AudioRecordCallback,
           &amp;recordingContext);
       if (result != paNoError)LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't open the audio stream");

       result = Pa_StartStream(stream);
       if (result != paNoError)LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't start the audio stream");

       Sleep(1000 * 5);

       result = Pa_StopStream(stream);
       if (result != paNoError)LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't stop the audio stream");

       if (!FinalizeRecordingContext(&amp;recordingContext)) LOG(ERROR) &lt;&lt; "Couldn't stop recording file";

       result = Pa_CloseStream(stream);
       if (result != paNoError)LOGINT_WITH_MESSAGE(ERROR, result, "Couldn't stop the audio stream");

       return 0;
    }
    </const>

    Here is the stdout, in case it helps.

    https://gist.github.com/pauldotknopf/9f24a604ce1f8a081aa68da1bf169e98

    Why is the audio lower in pitch ? I assume I am overlooking a parameter that needs to be configured between PortAudio and FFMPEG. Is there something super obvious that I am missing ?

  • ffmpeg stream replication of multiple sources to multiple destinations

    16 mars 2017, par dpx

    I’m looking to replicate multiple streams from a single source, to multiple destinations. So for instance 12 streams with a dest of 1.1.1.1:1000-1011 being reflected to two destinations @ 2.2.2.2:1000-1011 and 3.3.3.3:1000-1011

    I don’t want any stream processing, no modification, just using -vcodec / -acodec. Receiving MPEG-TS and reflecting MPEG-TS at the same bitrate.

    How would I run this with FFMPEG ? Trying to read the documentation but it’s not quite clear on how to handle this.

  • FFMpeg extremely slow - when called from asp.net

    9 juillet 2013, par Daveo

    I have a C# .NET website hosted on WIN2003 IIS6. This calls a .exe I have made (also in .net) using System.Diagnostics.Process which in turn calls a .bat script to convert a video into web formats (h264/MP4 and WEBM)

    ::Make MP4 ffmpeg.exe -i "%1" -y -vcodec libx264 -pix_fmt yuv420p
    -vprofile high -b:v 600k -maxrate 600k -bufsize 1200k -s 480x320 -threads 0 -acodec libvo_aacenc -b:a 128k "%2\video.mp4"

    ::Make WemM (VP8 / Vorbis) ffmpeg.exe -i "%1" -y -vcodec libvpx -b:v
    600k -maxrate 600k -bufsize 1200k -s 480x320 -threads 3 -acodec
    libvorbis -f webm "%2\video.webm"

    When I test it it seems to work fine a 70Mb input file will take about 4 minute to convert to mp4 then 6 minutes to convert to webm. Which is fine ! However whenever the customer test it the ffmpeg encoding taking HOURS (5 - 10 hours for one video) .

    When I look at windows task manager it shows a 2-3 instances of ffmpeg using cpu. When I refresh the output folder I can see the file increasing at 1Kb / second very slow. Why could this be happening ?

    my .net code

    private  bool Convert(string inputFile, string outputFolder)
           {
               string exePath = ConfigurationManager.AppSettings["BatchFile"];
               ProcessStartInfo startInfo = new ProcessStartInfo(exePath);

               startInfo.Arguments = string.Format("{0} {1}", inputFile, outputFolder);
               startInfo.FileName = exePath;
               startInfo.UseShellExecute = true;
               startInfo.CreateNoWindow = true;


               using (Process process = new Process())
               {
                   process.StartInfo = startInfo;

                   try
                   {
                       bool success;
                       int waitTimeInMinutes = int.Parse(ConfigurationManager.AppSettings["VideoConversionTimeout"]);
                       process.Start();
                       process.WaitForExit(1000 * 60 * waitTimeInMinutes); // Give up after Xmins

                       success = (process.ExitCode == 0);

                       return success;

                   }
                   catch (Exception e)
                   {
                       log.ErrorException("Main exception", e);
                       return false;
                   }
               }
           }