Recherche avancée

Médias (91)

Autres articles (106)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

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

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

Sur d’autres sites (10159)

  • Failed to play MP3 audio with ffmpeg API in Linux

    15 janvier, par wangt13

    I am working on an audioplayer by using FFMPEG library, and ALSA.
    
The following codes failed to playback the MP3 media smoothly (it is slower and noisy), I checked the FFMPEG codes and examples, but I did not the right solutions.

    


    #include &#xA;#include &#xA;#include <alsa></alsa>asoundlib.h>&#xA;&#xA;#include <libswresample></libswresample>swresample.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;&#xA;int init_pcm_play(snd_pcm_t **playback_handle,snd_pcm_uframes_t chunk_size,unsigned int rate,int bits_per_sample,int channels)&#xA;{&#xA;    snd_pcm_hw_params_t *hw_params;&#xA;    snd_pcm_format_t format;&#xA;&#xA;    //1. openPCM,&#xA;    if (0 > snd_pcm_open(playback_handle, "default", SND_PCM_STREAM_PLAYBACK, 0))&#xA;    {&#xA;        printf("snd_pcm_open err\n");&#xA;        return -1;&#xA;    }&#xA;    //2. snd_pcm_hw_params_t&#xA;    if(0 > snd_pcm_hw_params_malloc (&amp;hw_params))&#xA;    {&#xA;        printf("snd_pcm_hw_params_malloc err\n");&#xA;        return -1;&#xA;    }&#xA;    //3. hw_params&#xA;    if(0 > snd_pcm_hw_params_any (*playback_handle, hw_params))&#xA;    {&#xA;        printf("snd_pcm_hw_params_any err\n");&#xA;        return -1;&#xA;    }&#xA;    //4.&#xA;    if (0 > snd_pcm_hw_params_set_access (*playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED))&#xA;    {&#xA;        printf("snd_pcm_hw_params_any err\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    //5. SND_PCM_FORMAT_U8,8&#xA;    if(8 == bits_per_sample) {&#xA;        format = SND_PCM_FORMAT_U8;&#xA;    }&#xA;    if(16 == bits_per_sample) {&#xA;        format = SND_PCM_FORMAT_S16_LE;&#xA;    }&#xA;    if (0 > snd_pcm_hw_params_set_format (*playback_handle, hw_params, format))&#xA;    {&#xA;        printf("snd_pcm_hw_params_set_format err\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    //6.&#xA;    if (0 > snd_pcm_hw_params_set_rate_near (*playback_handle, hw_params, &amp;rate, 0))&#xA;    {&#xA;        printf("snd_pcm_hw_params_set_rate_near err\n");&#xA;        return -1;&#xA;    }&#xA;    //7.&#xA;    if (0 > snd_pcm_hw_params_set_channels(*playback_handle, hw_params, 2))&#xA;    {&#xA;        printf("snd_pcm_hw_params_set_channels err\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    //8. set hw_params&#xA;    if (0 > snd_pcm_hw_params (*playback_handle, hw_params))&#xA;    {&#xA;        printf("snd_pcm_hw_params err\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    snd_pcm_hw_params_get_period_size(hw_params, &amp;chunk_size, 0);&#xA;&#xA;    snd_pcm_hw_params_free (hw_params);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int main(int argc, char *argv[])&#xA;{&#xA;    AVFormatContext *pFormatCtx = NULL; //for opening multi-media file&#xA;    int audioStream = -1;&#xA;    AVCodecContext *pCodecCtx = NULL;&#xA;    AVCodec *pCodec = NULL; // the codecer&#xA;    AVFrame *pFrame = NULL;&#xA;    AVPacket *packet;&#xA;    uint8_t *out_buffer;&#xA;    struct SwrContext *au_convert_ctx;&#xA;    snd_pcm_t *playback_handle;&#xA;    int bits_per_sample = 0;&#xA;&#xA;    if (avformat_open_input(&amp;pFormatCtx, argv[1], NULL, NULL) != 0) {&#xA;        printf("Failed to open video file!");&#xA;        return -1; // Couldn&#x27;t open file&#xA;    }&#xA;&#xA;    if(avformat_find_stream_info(pFormatCtx,NULL)&lt;0)&#xA;    {&#xA;        printf("Failed to find stream info.\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    audioStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0);&#xA;    if (audioStream == -1) {&#xA;        printf("Din&#x27;t find a video stream!");&#xA;        return -1;// Didn&#x27;t find a video stream&#xA;    }&#xA;&#xA;    av_dump_format(pFormatCtx, audioStream, NULL, false);&#xA;&#xA;    // Find the decoder for the video stream&#xA;    pCodec = avcodec_find_decoder(pFormatCtx->streams[audioStream]->codecpar->codec_id);&#xA;    if (pCodec == NULL) {&#xA;        printf("Unsupported codec!\n");&#xA;        return -1; // Codec not found&#xA;    }&#xA;&#xA;    // Copy context&#xA;    pCodecCtx = avcodec_alloc_context3(pCodec);&#xA;    AVCodecParameters *pCodecParam = pFormatCtx->streams[audioStream]->codecpar;&#xA;&#xA;     if (avcodec_parameters_to_context(pCodecCtx, pCodecParam) &lt; 0) {&#xA;        printf("Failed to set codec params\n");&#xA;        return -1;&#xA;    }&#xA;    // Open codec&#xA;    if (avcodec_open2(pCodecCtx, pCodec, NULL) &lt; 0) {&#xA;        printf("Failed to open decoder!\n");&#xA;        return -1; // Could not open codec&#xA;    }&#xA;    packet = av_packet_alloc();&#xA;    pFrame = av_frame_alloc();&#xA;&#xA;    uint64_t iInputLayout                    = av_get_default_channel_layout(pCodecCtx->channels);&#xA;    enum AVSampleFormat eInputSampleFormat   = pCodecCtx->sample_fmt;&#xA;    int         iInputSampleRate             = pCodecCtx->sample_rate;&#xA;&#xA;&#xA;    uint64_t iOutputLayout                   = av_get_default_channel_layout(pCodecCtx->channels);&#xA;    int      iOutputChans                    = pCodecCtx->channels;&#xA;    enum AVSampleFormat eOutputSampleFormat  = AV_SAMPLE_FMT_S16;&#xA;    int         iOutputSampleRate            = pCodecCtx->sample_rate;&#xA;&#xA;    au_convert_ctx = swr_alloc_set_opts(NULL,iOutputLayout, eOutputSampleFormat, iOutputSampleRate,&#xA;        iInputLayout,eInputSampleFormat, iInputSampleRate, 0, NULL);&#xA;    swr_init(au_convert_ctx);&#xA;    int iConvertLineSize = 0;&#xA;    int iConvertBuffSize  = av_samples_get_buffer_size(&amp;iConvertLineSize, iOutputChans, pCodecCtx->frame_size, eOutputSampleFormat, 0);&#xA;    printf("ochans: %d, ifrmsmp: %d, osfmt: %d, cbufsz: %d\n", iOutputChans, pCodecCtx->frame_size, eOutputSampleFormat, iConvertBuffSize);&#xA;    out_buffer = (uint8_t *) av_malloc(iConvertBuffSize);&#xA;&#xA;    if(eOutputSampleFormat == AV_SAMPLE_FMT_S16 )&#xA;    {&#xA;        bits_per_sample = 16;&#xA;    }&#xA;    /*** alsa handle ***/&#xA;    init_pcm_play(&amp;playback_handle,256, iOutputSampleRate,bits_per_sample,2);&#xA;&#xA;    if (0 > snd_pcm_prepare (playback_handle))&#xA;    {&#xA;        printf("snd_pcm_prepare err\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    while (av_read_frame(pFormatCtx, packet) >= 0) {&#xA;        if (packet->stream_index == audioStream) {&#xA;            avcodec_send_packet(pCodecCtx, packet);&#xA;            while (avcodec_receive_frame(pCodecCtx, pFrame) == 0) {&#xA;                int outframes = swr_convert(au_convert_ctx, &amp;out_buffer, pCodecCtx->frame_size, (const uint8_t **) pFrame->data, pFrame->nb_samples); // 转换音频&#xA;                snd_pcm_writei(playback_handle, out_buffer, outframes);&#xA;                av_frame_unref(pFrame);&#xA;            }&#xA;        }&#xA;        av_packet_unref(packet);&#xA;    }&#xA;    swr_free(&amp;au_convert_ctx);&#xA;    snd_pcm_close(playback_handle);&#xA;    av_freep(&amp;out_buffer);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    Running the codes can show following logs.

    &#xA;

    ./ap_alsa ./dooralarm.mp3&#xA;[mp3 @ 0x1e72020] Estimating duration from bitrate, this may be inaccurate&#xA;Input #0, mp3, from &#x27;(null)&#x27;:&#xA;  Metadata:&#xA;    genre           : Blues&#xA;    id3v2_priv.XMP  : &lt;?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a\x0a \x0a  s&#xA;  Stream #0:0: Audio: mp3, 22050 Hz, mono, fltp, 48 kb/s&#xA;ochans: 1, ifrmsmp: 576, osfmt: 1, cbufsz: 1152&#xA;

    &#xA;

    I am using the FFMPEG-4.4.4, and Linux-kernel-5.10.20.

    &#xA;

  • FFMPEG : Specifying Output Stream Type When Combing Multiple Filters

    7 mai 2021, par Leonard Bedner

    I currently have 3 separate ffmpeg commands that do the following :

    &#xA;

      &#xA;
    1. Overlay a watermark on a video : ffmpeg -i samplegreen.webm -i foregrounds/myimage.png -r 30 -filter_complex "overlay=(W-w)/2:H-h" -af "adelay=700" output.mp4
    2. &#xA;

    3. Overlay the results of 1) onto a beach video : ffmpeg -i backgrounds/beachsunsetmp4.mp4 -i output.mp4 -filter_complex "[1:v]chromakey=0x005d0b:0.1485:0.03[ckout];[0:v][ckout]overlay[o]" -map [o] -map 1:a -shortest somefolder/sample_video.mp4
    4. &#xA;

    5. Merge the audio of the results of 2) with another audio file : ffmpeg -i somefolder/sample_video.mp4 -i backgrounds/beachsunsetmp4.mp3 -filter_complex &#x27;[0:a][1:a]amerge=inputs=2[a]&#x27; -map 0:v -map &#x27;[a]&#x27; -c:v copy -ac 2 -shortest anotherfolder/sample_video.mp4
    6. &#xA;

    &#xA;

    Now, this all works as intended, however, I was looking into attempting to combine them all into a single command, combining all the filters, like so :

    &#xA;

    ffmpeg -i samplegreen.webm -i foregrounds/myimage.png -r 30 -i backgrounds/beachsunsetmp4.mp4 -i backgrounds/beachsunsetmp4.mp3 -filter_complex \&#xA;    "[0]overlay=(W-w)/2:H-h[output_1]; \&#xA;     [output_1]chromakey=0x005d0b:0.1485:0.03[ckout]; \&#xA;     [2:v][ckout]overlay[output_2]; \&#xA;     [output_2][3:a] amerge=inputs=2 [output_3]" \&#xA;    -af "adelay=700" -map [output_3] shortest final.mp4&#xA;

    &#xA;

    It fails with the following error (Media type mismatch between the &#x27;Parsed_overlay_2&#x27; filter output pad 0 (video) and the &#x27;Parsed_amerge_3&#x27; filter input pad 0 (audio)) :

    &#xA;

    ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with Apple clang version 11.0.0 (clang-1100.0.33.17)&#xA;  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;Input #0, matroska,webm, from &#x27;samplegreen.webm&#x27;:&#xA;  Metadata:&#xA;    encoder         : Chrome&#xA;  Duration: N/A, start: 0.000000, bitrate: N/A&#xA;    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1280x720, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn, 1k tbc (default)&#xA;    Metadata:&#xA;      alpha_mode      : 1&#xA;    Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)&#xA;Input #1, png_pipe, from &#x27;foregrounds/myimage.png&#x27;:&#xA;  Duration: N/A, bitrate: N/A&#xA;    Stream #1:0: Video: png, rgba(pc), 350x86, 25 tbr, 25 tbn, 25 tbc&#xA;Input #2, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;backgrounds/beachsunsetmp4.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: mp42mp41&#xA;    creation_time   : 2021-02-16T18:24:40.000000Z&#xA;  Duration: 00:00:32.53, start: 0.000000, bitrate: 3032 kb/s&#xA;    Stream #2:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 3027 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-02-16T18:24:40.000000Z&#xA;      handler_name    : ?Mainconcept Video Media Handler&#xA;      encoder         : AVC Coding&#xA;[mp3 @ 0x7f86cf809000] Estimating duration from bitrate, this may be inaccurate&#xA;Input #3, mp3, from &#x27;backgrounds/beachsunsetmp4.mp3&#x27;:&#xA;  Metadata:&#xA;    date            : 2021-02-18 06:49&#xA;    id3v2_priv.XMP  : &lt;?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a\x0a \x0a  s&#xA;    Stream #3:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s&#xA;[Parsed_overlay_2 @ 0x7f86cd4039c0] Media type mismatch between the &#x27;Parsed_overlay_2&#x27; filter output pad 0 (video) and the &#x27;Parsed_amerge_3&#x27; filter input pad 0 (audio)&#xA;[AVFilterGraph @ 0x7f86cd402a40] Cannot create the link overlay:0 -> amerge:0&#xA;Error initializing complex filters.&#xA;Invalid argument&#xA;

    &#xA;

    As far as I can tell, the issue is that the filter, amerge, wants 2 audio streams. Normally, I could take the input stream argument (which is a video), and make it use the audio by doing something like [0:a][1:a]amerge=inputs=2[results]. However, since my input stream is the output of a preceding filter, that doesn't seem to work (i.e. [output_2:a]). It bombs out with :

    &#xA;

    [matroska,webm @ 0x7fecca000000] Invalid stream specifier: output_2:a.&#xA;    Last message repeated 1 times&#xA;Stream specifier &#x27;output_2:a&#x27; in filtergraph description [0]overlay=(W-w)/2:H-h[output_1];      [output_1]chromakey=0x005d0b:0.1485:0.03[ckout];      [2:v][ckout]overlay[output_2];      [output_2:a][3:a] amerge=inputs=2 [output_3] matches no streams.&#xA;

    &#xA;

    So all of that said... Is there a way to specify that I'd like to use the audio stream from the output of a preceding filter ? Or any other ways to combine all of these filters into a single command ?

    &#xA;

    Thanks.

    &#xA;

    Any help would be greatly appreciated !

    &#xA;

  • movenc : Add an F4V muxer

    17 septembre 2012, par Clément Bœsch
    movenc : Add an F4V muxer
    

    F4V is Adobe’s mp4/iso media variant, with the most significant
    addition/change being supporting other flash codecs than just
    aac/h264.

    Signed-off-by : Martin Storsjö <martin@martin.st>

    • [DBH] Changelog
    • [DBH] configure
    • [DBH] libavformat/allformats.c
    • [DBH] libavformat/movenc.c
    • [DBH] libavformat/movenc.h
    • [DBH] libavformat/version.h