Recherche avancée

Médias (91)

Autres articles (104)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • 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.

  • 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. (...)

Sur d’autres sites (7075)

  • convert pcm stream data to encoded aac data

    24 décembre 2019, par Kumar

    I tried to convert pulse-audio pcm stream data to aac encoded data using ffmpeg.
    But after encoding I get noise-full data, not the correct one. Here I post my code, anyone help me with some ideas.

    Initial configuration :

       av_register_all();

       int error;
       if ((error = avio_open(&output_io_context,"out.aac",AVIO_FLAG_WRITE))<0) {
               printf("could not open output file\n");
       }

       if (!(output_format_context = avformat_alloc_context())) {
               printf("output_format_context error\n");
       }

       output_format_context->pb = output_io_context;

       if(!(output_format_context->oformat = av_guess_format(NULL, "out.aac", NULL))) {
               printf("guess format error\n");
       }

       codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
       if (codec == NULL) {
               printf("avcodec_find_encoder: ERROR\n");
       }

       if (!(stream = avformat_new_stream(output_format_context, NULL))) {
               printf("stream create error\n");
       }
       output_codec_context = avcodec_alloc_context3(codec);
       if(!output_codec_context) {
               printf("output_codec_context is null\n");
       }

       output_codec_context->channels       = CHANNELS;
       output_codec_context->channel_layout = av_get_default_channel_layout(CHANNELS);
       output_codec_context->sample_rate    = SAMPLE_RATE; //input_codec_context->sample_rate;
       output_codec_context->sample_fmt     = codec->sample_fmts[0];
       output_codec_context->bit_rate       = 48000; //OUTPUT_BIT_RATE;

       stream->time_base.den = SAMPLE_RATE;//input_codec_context->sample_rate;
       stream->time_base.num = 1;

       if(output_format_context->oformat->flags & AVFMT_GLOBALHEADER)
               output_codec_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;

       if ((error = avcodec_open2(output_codec_context, codec, NULL)) < 0) {
           printf("error");
       }

       error = avcodec_parameters_from_context(stream->codecpar, output_codec_context);

       if (write_output_file_header(output_format_context)) {
               printf("write header failure...\n");
       }

    Data encoding :

    AVFrame *output_frame;
    int frame_pos = 0, ctx_frame_size = output_codec_context->frame_size;
    int size = av_samples_get_buffer_size(NULL, CHANNELS,
                 output_codec_context->frame_size,output_codec_context->sample_fmt, 1);
    if((x =  avcodec_fill_audio_frame(output_frame, CHANNELS,
                  output_codec_context->sample_fmt, data, length, 1)) < 0) {
         printf("avcodec_fill_audio_frame error : %s\n", av_err2str(x));
    }

    int data_written;
    if (encode_audio_frame(output_frame, output_format_context,
               output_codec_context, &data_written)) {
           printf("encode_audio_frame error\n");
     }

     av_frame_free(&output_frame);

    helper_function :

    int encode_audio_frame(AVFrame *frame,AVFormatContext *output_format_context,
                 AVCodecContext *output_codec_context, int *data_present)
    {
      AVPacket output_packet;
      int error;
      init_packet(&output_packet);

      if (frame) {
         frame->pts = pts;
         pts += frame->nb_samples;
      }

      error = avcodec_send_frame(output_codec_context, frame);
      if (error == AVERROR_EOF) {
        error = 0;
        goto cleanup;
      } else if (error < 0) {
         fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
               av_err2str(error));
         return error;
      }

      error = avcodec_receive_packet(output_codec_context, &output_packet);
      if (error == AVERROR(EAGAIN)) {
        error = 0;
        goto cleanup;
      } else if (error == AVERROR_EOF) {
         error = 0;
         goto cleanup;
      } else if (error < 0) {
         fprintf(stderr, "Could not encode frame (error '%s')\n",
               av_err2str(error));
         goto cleanup;
      } else {
         *data_present = 1;
     }

     if (*data_present &&
         (error = av_write_frame(output_format_context, &output_packet)) < 0) {
         fprintf(stderr, "Could not write frame (error '%s')\n",
                av_err2str(error));
         goto cleanup;
     }

     cleanup:
         av_packet_unref(&output_packet);
         return error;
    }
    • Do we need to fill AVFrame with sizeof(av_samples_get_buffer_size) or context->frame_size ?

    TYIA :) !!

  • How to save synthesized audio during streaming distribution

    7 avril 2022, par its-ogawa

    I would like to stream a composite of microphone audio and digital sound sources by ffmpeg and save the delivery to an m3u8 file.

    


    Below are the commands I have actually tried.

    


    ffmpeg -rtbufsize 100M -f dshow -i video=<my webcam="webcam">:audio=<my microphone="microphone"> -re -stream_loop -1 -i <my sound="sound" source="source"> -filter_complex "[0]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,adelay=2100|2100,volume@voice=volume=10dB[voice],[1]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,azmq,volume@bgm=volume=0.2[bgm],[voice][bgm]amerge=inputs=2[out]" -map 0:v -map [out]:a -f mpegts -flush_packets 0 udp://XXX.XXX.XXX.XXX:XXX?pkt_size=1316 -f hls -hls_time 5 hls.m3u8&#xA;</my></my></my>

    &#xA;

    I have played an m3u8 created this way, but I cannot hear the digital sound source that I am supposed to have synthesized.&#xA;Even though the synthesized audio was audible when streamed.

    &#xA;

    Perhaps you need to set up something like -map 0:v -map [out]:a when saving to the m3u8 file, in which case the Output with label &#x27;out&#x27; does not exist in any defined filter graph, or was already used elsewhere. message appears and does not work.

    &#xA;

  • Python ffmpeg does not save the mp4 clips to file

    30 janvier 2021, par oo92

    I'm using the ffmpeg Python library to save 60 second mp4 clips to file from Twitch livestreams using its API. This is my code :

    &#xA;

    current_dir = os.getcwd()&#xA;&#xA;client = TwitchClient(client_id=&#x27;&#x27;)&#xA;streams_now = client.streams.get_live_streams(limit=100, offset=900)&#xA;epoch = str(math.ceil(time.time()))&#xA;&#xA;if not os.path.exists(current_dir &#x2B; &#x27;/twitch_videos/&#x27;):&#xA;    os.mkdir(current_dir &#x2B; &#x27;/twitch_videos/&#x27;)&#xA;&#xA;for i in range(0, 1):&#xA;    try:&#xA;        username = streams_now[i][&#x27;channel&#x27;][&#x27;name&#x27;]&#xA;        id = streams_now[i][&#x27;id&#x27;]&#xA;        game = streams_now[i][&#x27;game&#x27;]&#xA;        game = game.translate(str.maketrans({&#x27;:&#x27;: &#x27;-&#x27;, &#x27; &#x27;: &#x27;-&#x27;, "&#x27;": &#x27;&#x27;, &#x27;!&#x27;: &#x27;&#x27;, &#x27;&amp;&#x27;: &#x27;_&#x27;, &#x27;.&#x27;: &#x27;&#x27;, &#x27;&#x2B;&#x27;: &#x27;_&#x27;}))&#xA;        streaming = streamlink.streams(&#x27;http://twitch.tv/&#x27; &#x2B; username)&#xA;        stream = streaming["best"].url&#xA;&#xA;        twitch_stream = ffmpeg.input(stream)&#xA;&#xA;        twitch_stream = ffmpeg.filter(twitch_stream,&#xA;                                      &#x27;fps&#x27;,&#xA;                                      fps=1,&#xA;                                      round=&#x27;up&#x27;)&#xA;&#xA;        twitch_stream = ffmpeg.output(twitch_stream,&#xA;                                      current_dir &#x2B; &#x27;/twitch_videos/&#x27; &#x2B; &#x27;%d_&#x27; &#x2B; username &#x2B; &#x27;_&#x27; &#x2B; epoch &#x2B; &#x27;.mp4&#x27;,&#xA;                                      sc_threshold=&#x27;0&#x27;,&#xA;                                      g=&#x27;60&#x27;,&#xA;                                      f=&#x27;segment&#x27;,&#xA;                                      segment_time=&#x27;600&#x27;,&#xA;                                      segment_format_options=&#x27;movflags=&#x2B;faststart&#x27;,&#xA;                                      reset_timestamps=&#x27;1&#x27;)frl3dqgn21bbpp6tajjvg5pdevczac&#xA;        ffmpeg.run(twitch_stream)&#xA;&#xA;&#xA;    except:&#xA;        pass&#xA;

    &#xA;

    I am concatenating the path it should go to, to the name of the file. But the folder is empty after I take a look.

    &#xA;