Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (80)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (9032)

  • 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 wrong codecstring for DASH manifest [closed]

    21 novembre 2024, par Suxsem

    I'm trying to create a DASH stream with ffmpeg with the following command :

    &#xA;

    ffmpeg -i rtsp://admin:***@camera-retro.lan/ch0_0 ^&#xA;       -map 0 ^&#xA;       -codec:v copy ^&#xA;       -codec:a copy ^&#xA;       -f dash ^&#xA;       -use_template 1 ^&#xA;       -use_timeline 1 ^&#xA;       -window_size 50 ^&#xA;       -extra_window_size 5 ^&#xA;       -seg_duration 5 ^&#xA;       tmp/output.mpd&#xA;

    &#xA;

    The problem is the generated manifest doesn't contain a valid codecstring for the video part (note the codecs="hev1" part) and thus is not playable by the browser :

    &#xA;

    &lt;?xml version="1.0" encoding="utf-8"?>&#xA;<mpd xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="dynamic" minimumupdateperiod="PT6S" suggestedpresentationdelay="PT6S" availabilitystarttime="2024-11-21T12:05:52.604Z" publishtime="2024-11-21T12:05:57.559Z" timeshiftbufferdepth="PT5M1.9S" maxsegmentduration="PT5.0S" minbuffertime="PT12.0S">&#xA;    <programinformation>&#xA;        &#xA;    </programinformation>&#xA;    <servicedescription>&#xA;    </servicedescription>&#xA;    <period start="PT0.0S">&#xA;        <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" maxwidth="2304" maxheight="1296" par="16:9">&#xA;            <representation mimetype="video/mp4" codecs="hev1" bandwidth="822093" width="2304" height="1296" scantype="unknown" sar="1:1">&#xA;                <segmenttemplate timescale="90000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="542990"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="34143" audiosamplingrate="16000">&#xA;                <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1"></audiochannelconfiguration>&#xA;                <segmenttemplate timescale="16000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startnumber="1">&#xA;                    <segmenttimeline>&#xA;                        <s t="0" d="81001"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;    </period>&#xA;</mpd>&#xA;

    &#xA;

    This is the output of ffprobe :

    &#xA;

    SDP:&#xA;v=0&#xA;o=- 1732188474342789 1 IN IP4 192.168.12.162&#xA;s=Session streamed by "rRTSPServer"&#xA;i=ch0_0.h264&#xA;t=0 0&#xA;a=tool:LIVE555 Streaming Media v2023.01.19&#xA;a=type:broadcast&#xA;a=control:*&#xA;a=range:npt=now-&#xA;a=x-qt-text-nam:Session streamed by "rRTSPServer"&#xA;a=x-qt-text-inf:ch0_0.h264&#xA;m=video 0 RTP/AVP 96&#xA;c=IN IP4 0.0.0.0&#xA;b=AS:700&#xA;a=rtpmap:96 H265/90000&#xA;a=fmtp:96 profile-space=0;profile-id=1;tier-flag=0;level-id=186;interop-constraints=000000000000;sprop-vps=QAEMAf//AWAAAAMAAAMAAAMAAAMAuqwJ;sprop-sps=QgEBAWAAAAMAAAMAAAMAAAMAuqABICAFEf5a7kSIi/Lc1AQEBAI=;sprop-pps=RAHA8oSJAzJA&#xA;a=control:track1&#xA;m=audio 0 RTP/AVP 97&#xA;c=IN IP4 0.0.0.0&#xA;b=AS:32&#xA;a=rtpmap:97 MPEG4-GENERIC/16000&#xA;a=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408&#xA;a=control:track2&#xA;

    &#xA;

    it seems to me that all codec informations are present :

    &#xA;

    a=fmtp:96 profile-space=0;profile-id=1;tier-flag=0;level-id=186;interop-constraints=000000000000;&#xA;

    &#xA;

    why ffmpeg is putting only codecs="hev1" instead of the full codecstring (containing the profile, the level and the constraints) ?

    &#xA;

    Thank you

    &#xA;

  • aarch64 : hevc : Implement a neon version of put_hevc_epel_h*_8

    1er mars 2024, par Martin Storsjö
    aarch64 : hevc : Implement a neon version of put_hevc_epel_h*_8
    

    AWS Graviton 3 :
    put_hevc_epel_h4_8_c : 64.7
    put_hevc_epel_h4_8_neon : 25.0
    put_hevc_epel_h4_8_i8mm : 21.2
    put_hevc_epel_h6_8_c : 130.0
    put_hevc_epel_h6_8_neon : 40.7
    put_hevc_epel_h6_8_i8mm : 36.5
    put_hevc_epel_h8_8_c : 209.0
    put_hevc_epel_h8_8_neon : 45.2
    put_hevc_epel_h8_8_i8mm : 41.2
    put_hevc_epel_h12_8_c : 465.5
    put_hevc_epel_h12_8_neon : 104.5
    put_hevc_epel_h12_8_i8mm : 86.5
    put_hevc_epel_h16_8_c : 830.7
    put_hevc_epel_h16_8_neon : 134.2
    put_hevc_epel_h16_8_i8mm : 114.0
    put_hevc_epel_h24_8_c : 1844.7
    put_hevc_epel_h24_8_neon : 282.2
    put_hevc_epel_h24_8_i8mm : 277.2
    put_hevc_epel_h32_8_c : 3227.5
    put_hevc_epel_h32_8_neon : 501.5
    put_hevc_epel_h32_8_i8mm : 396.0
    put_hevc_epel_h48_8_c : 7229.2
    put_hevc_epel_h48_8_neon : 1120.2
    put_hevc_epel_h48_8_i8mm : 901.2
    put_hevc_epel_h64_8_c : 12869.0
    put_hevc_epel_h64_8_neon : 1999.2
    put_hevc_epel_h64_8_i8mm : 1610.5

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

    • [DH] libavcodec/aarch64/hevcdsp_epel_neon.S
    • [DH] libavcodec/aarch64/hevcdsp_init_aarch64.c