Recherche avancée

Médias (91)

Autres articles (99)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (10485)

  • How do I write audio and video to the same file using FFMPEG and C ?

    29 juin 2018, par benwiz

    I am consuming an audio file and a video file using ffmpeg in a C program. I am modifying both the audio and the video data. In working the code below I write both each of these streams to its own file. How can I write both streams to the same file ?

    #include
    #include
    #include

    // Video resolution
    #define W 1280
    #define H 720

    // Allocate a buffer to store one video frame
    unsigned char video_frame[H][W][3] = {0};

    int main()
    {
       // Audio pipes
       FILE *audio_pipein = popen("ffmpeg -i data/daft-punk.mp3 -f s16le -ac 1 -", "r");
       FILE *audio_pipeout = popen("ffmpeg -y -f s16le -ar 44100 -ac 1 -i - out/daft-punk.mp3", "w");

       // Video pipes
       FILE *video_pipein = popen("ffmpeg -i data/daft-punk.mp4 -f image2pipe -vcodec rawvideo -pix_fmt rgb24 -", "r");
       FILE *video_pipeout = popen("ffmpeg -y -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s 1280x720 -r 25 -i - -f mp4 -q:v 5 -an -vcodec mpeg4 out/daft-punk.mp4", "w");

       // Audio vars
       int16_t audio_sample;
       int audio_count;
       int audio_n = 0;

       // Video vars
       int x = 0;
       int y = 0;
       int video_count = 0;

       // Read, modify, and write one audio_sample and video_frame at a time
       while (1)
       {
           // Audio
           audio_count = fread(&audio_sample, 2, 1, audio_pipein); // read one 2-byte audio_sample
           if (audio_count == 1)
           {
               ++audio_n;
               audio_sample = audio_sample * sin(audio_n * 5.0 * 2 * M_PI / 44100.0);
               fwrite(&audio_sample, 2, 1, audio_pipeout);
           }

           // Video
           video_count = fread(video_frame, 1, H * W * 3, video_pipein); // Read a frame from the input pipe into the buffer
           if (video_count == H * W * 3)                                 // Only modify and write if frame exists
           {
               for (y = 0; y < H; ++y)     // Process this frame
                   for (x = 0; x < W; ++x) // Invert each colour component in every pixel
                   {
                       video_frame[y][x][0] = 255 - video_frame[y][x][0]; // red
                       video_frame[y][x][1] = 255 - video_frame[y][x][1]; // green
                       video_frame[y][x][2] = 255 - video_frame[y][x][2]; // blue
                   }
               fwrite(video_frame, 1, H * W * 3, video_pipeout); // Write this frame to the output pipe
           }

           // Break if both complete
           if (audio_count != 1 && video_count != H * W * 3)
               break;
       }

       // Close audio pipes
       pclose(audio_pipein);
       pclose(audio_pipeout);

       // Close video pipes
       fflush(video_pipein);
       fflush(video_pipeout);
       pclose(video_pipein);
       pclose(video_pipeout);

       return 0;
    }

    I took the base for this code from this article.

    Thanks !

  • How to import and use FFmpegInteropX.FFmpegUWP ?

    14 janvier, par Boris

    I am writing a WinUI3 app. I need it to play a .mkv video file using MediaPlayerElement control. Out of box, .mkv file types are not supported. So I came upon a package FFmpegInteropX.FFmpegUWP (current v5.1.100) and installed it to the solution via Visual Studio NuGet Package Manager. The installation went fine and the package is definitely part of the project :

    


    <packagereference include="FFmpegInteropX.FFmpegUWP" version="5.1.100"></packagereference>

    &#xA;

    The problem I have is that when I type using FFmpegInteropX; it is not recognized and I cannot use it. I've noticed there is also a FFmpegInteropX package (so without the ".FFmpegUWP" part) and I tried installing that one too, as I was trying to make the using statement work. However, it appears that that package is not intended for WinUI3 projects and NuGet removed it.

    &#xA;

    Now, I am clueless on how to use the FFmpegInteropX.FFmpegUWP in the project. Could anyone please explain why I might be experiencing this problem ?

    &#xA;

  • libav live transcode to SFML SoundStream, garbled and noise

    20 juin 2021, par William Lohan

    I'm so close to have this working but playing with the output sample format or codec context doesn't seem to solve and don't know where to go from here.

    &#xA;

    #include <iostream>&#xA;#include <sfml></sfml>Audio.hpp>&#xA;#include "MyAudioStream.h"&#xA;&#xA;extern "C"&#xA;{&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>avutil.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>audio_fifo.h>&#xA;#include <libswresample></libswresample>swresample.h>&#xA;}&#xA;&#xA;void setupInput(AVFormatContext *input_format_context, AVCodecContext **input_codec_context, const char *streamURL)&#xA;{&#xA;  // av_find_input_format("mp3");&#xA;  avformat_open_input(&amp;input_format_context, streamURL, NULL, NULL);&#xA;  avformat_find_stream_info(input_format_context, NULL);&#xA;&#xA;  AVDictionary *metadata = input_format_context->metadata;&#xA;  AVDictionaryEntry *name = av_dict_get(metadata, "icy-name", NULL, 0);&#xA;  if (name != NULL)&#xA;  {&#xA;    std::cout &lt;&lt; name->value &lt;&lt; std::endl;&#xA;  }&#xA;  AVDictionaryEntry *title = av_dict_get(metadata, "StreamTitle", NULL, 0);&#xA;  if (title != NULL)&#xA;  {&#xA;    std::cout &lt;&lt; title->value &lt;&lt; std::endl;&#xA;  }&#xA;&#xA;  AVStream *stream = input_format_context->streams[0];&#xA;  AVCodecParameters *codec_params = stream->codecpar;&#xA;  AVCodec *codec = avcodec_find_decoder(codec_params->codec_id);&#xA;  *input_codec_context = avcodec_alloc_context3(codec);&#xA;&#xA;  avcodec_parameters_to_context(*input_codec_context, codec_params);&#xA;  avcodec_open2(*input_codec_context, codec, NULL);&#xA;}&#xA;&#xA;void setupOutput(AVCodecContext *input_codec_context, AVCodecContext **output_codec_context)&#xA;{&#xA;  AVCodec *output_codec = avcodec_find_encoder(AV_CODEC_ID_PCM_S16LE); // AV_CODEC_ID_PCM_S16LE ?? AV_CODEC_ID_PCM_S16BE&#xA;  *output_codec_context = avcodec_alloc_context3(output_codec);&#xA;  (*output_codec_context)->channels = 2;&#xA;  (*output_codec_context)->channel_layout = av_get_default_channel_layout(2);&#xA;  (*output_codec_context)->sample_rate = input_codec_context->sample_rate;&#xA;  (*output_codec_context)->sample_fmt = output_codec->sample_fmts[0]; // AV_SAMPLE_FMT_S16 ??&#xA;  avcodec_open2(*output_codec_context, output_codec, NULL);&#xA;}&#xA;&#xA;void setupResampler(AVCodecContext *input_codec_context, AVCodecContext *output_codec_context, SwrContext **resample_context)&#xA;{&#xA;  *resample_context = swr_alloc_set_opts(&#xA;      *resample_context,&#xA;      output_codec_context->channel_layout,&#xA;      output_codec_context->sample_fmt,&#xA;      output_codec_context->sample_rate,&#xA;      input_codec_context->channel_layout,&#xA;      input_codec_context->sample_fmt,&#xA;      input_codec_context->sample_rate,&#xA;      0, NULL);&#xA;  swr_init(*resample_context);&#xA;}&#xA;&#xA;MyAudioStream::MyAudioStream()&#xA;{&#xA;  input_format_context = avformat_alloc_context();&#xA;  resample_context = swr_alloc();&#xA;}&#xA;&#xA;MyAudioStream::~MyAudioStream()&#xA;{&#xA;  // clean up&#xA;  avformat_close_input(&amp;input_format_context);&#xA;  avformat_free_context(input_format_context);&#xA;}&#xA;&#xA;void MyAudioStream::load(const char *streamURL)&#xA;{&#xA;&#xA;  setupInput(input_format_context, &amp;input_codec_context, streamURL);&#xA;  setupOutput(input_codec_context, &amp;output_codec_context);&#xA;  setupResampler(input_codec_context, output_codec_context, &amp;resample_context);&#xA;&#xA;  initialize(output_codec_context->channels, output_codec_context->sample_rate);&#xA;}&#xA;&#xA;bool MyAudioStream::onGetData(Chunk &amp;data)&#xA;{&#xA;&#xA;  // init&#xA;  AVFrame *input_frame = av_frame_alloc();&#xA;  AVPacket *input_packet = av_packet_alloc();&#xA;  input_packet->data = NULL;&#xA;  input_packet->size = 0;&#xA;&#xA;  // read&#xA;  av_read_frame(input_format_context, input_packet);&#xA;  avcodec_send_packet(input_codec_context, input_packet);&#xA;  avcodec_receive_frame(input_codec_context, input_frame);&#xA;&#xA;  // convert&#xA;  uint8_t *converted_input_samples = (uint8_t *)calloc(output_codec_context->channels, sizeof(*converted_input_samples));&#xA;  av_samples_alloc(&amp;converted_input_samples, NULL, output_codec_context->channels, input_frame->nb_samples, output_codec_context->sample_fmt, 0);&#xA;  swr_convert(resample_context, &amp;converted_input_samples, input_frame->nb_samples, (const uint8_t **)input_frame->extended_data, input_frame->nb_samples);&#xA;&#xA;  data.sampleCount = input_frame->nb_samples;&#xA;  data.samples = (sf::Int16 *)converted_input_samples;&#xA;&#xA;  // av_freep(&amp;converted_input_samples[0]);&#xA;  // free(converted_input_samples);&#xA;  av_packet_free(&amp;input_packet);&#xA;  av_frame_free(&amp;input_frame);&#xA;&#xA;  return true;&#xA;}&#xA;&#xA;void MyAudioStream::onSeek(sf::Time timeOffset)&#xA;{&#xA;  // no op&#xA;}&#xA;&#xA;sf::Int64 MyAudioStream::onLoop()&#xA;{&#xA;  // no loop&#xA;  return -1;&#xA;}&#xA;&#xA;</iostream>

    &#xA;

    Called with

    &#xA;

    #include <iostream>&#xA;&#xA;#include "./MyAudioStream.h"&#xA;&#xA;extern "C"&#xA;{&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>avutil.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;}&#xA;&#xA;const char *streamURL = "http://s5radio.ponyvillelive.com:8026/stream.mp3";&#xA;&#xA;int main(int, char **)&#xA;{&#xA;&#xA;  MyAudioStream myStream;&#xA;&#xA;  myStream.load(streamURL);&#xA;&#xA;  std::cout &lt;&lt; "Hello, world!" &lt;&lt; std::endl;&#xA;&#xA;  myStream.play();&#xA;&#xA;  while (myStream.getStatus() == MyAudioStream::Playing)&#xA;  {&#xA;    sf::sleep(sf::seconds(0.1f));&#xA;  }&#xA;&#xA;  return 0;&#xA;}&#xA;</iostream>

    &#xA;