
Recherche avancée
Médias (2)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (80)
-
HTML5 audio and video support
13 avril 2011, parMediaSPIP 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, parLa 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, parMediaspip 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 wangt13I 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 
#include 
#include <alsa></alsa>asoundlib.h>

#include <libswresample></libswresample>swresample.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libswscale></libswscale>swscale.h>

int init_pcm_play(snd_pcm_t **playback_handle,snd_pcm_uframes_t chunk_size,unsigned int rate,int bits_per_sample,int channels)
{
 snd_pcm_hw_params_t *hw_params;
 snd_pcm_format_t format;

 //1. openPCM,
 if (0 > snd_pcm_open(playback_handle, "default", SND_PCM_STREAM_PLAYBACK, 0))
 {
 printf("snd_pcm_open err\n");
 return -1;
 }
 //2. snd_pcm_hw_params_t
 if(0 > snd_pcm_hw_params_malloc (&hw_params))
 {
 printf("snd_pcm_hw_params_malloc err\n");
 return -1;
 }
 //3. hw_params
 if(0 > snd_pcm_hw_params_any (*playback_handle, hw_params))
 {
 printf("snd_pcm_hw_params_any err\n");
 return -1;
 }
 //4.
 if (0 > snd_pcm_hw_params_set_access (*playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED))
 {
 printf("snd_pcm_hw_params_any err\n");
 return -1;
 }

 //5. SND_PCM_FORMAT_U8,8
 if(8 == bits_per_sample) {
 format = SND_PCM_FORMAT_U8;
 }
 if(16 == bits_per_sample) {
 format = SND_PCM_FORMAT_S16_LE;
 }
 if (0 > snd_pcm_hw_params_set_format (*playback_handle, hw_params, format))
 {
 printf("snd_pcm_hw_params_set_format err\n");
 return -1;
 }

 //6.
 if (0 > snd_pcm_hw_params_set_rate_near (*playback_handle, hw_params, &rate, 0))
 {
 printf("snd_pcm_hw_params_set_rate_near err\n");
 return -1;
 }
 //7.
 if (0 > snd_pcm_hw_params_set_channels(*playback_handle, hw_params, 2))
 {
 printf("snd_pcm_hw_params_set_channels err\n");
 return -1;
 }

 //8. set hw_params
 if (0 > snd_pcm_hw_params (*playback_handle, hw_params))
 {
 printf("snd_pcm_hw_params err\n");
 return -1;
 }

 snd_pcm_hw_params_get_period_size(hw_params, &chunk_size, 0);

 snd_pcm_hw_params_free (hw_params);

 return 0;
}

int main(int argc, char *argv[])
{
 AVFormatContext *pFormatCtx = NULL; //for opening multi-media file
 int audioStream = -1;
 AVCodecContext *pCodecCtx = NULL;
 AVCodec *pCodec = NULL; // the codecer
 AVFrame *pFrame = NULL;
 AVPacket *packet;
 uint8_t *out_buffer;
 struct SwrContext *au_convert_ctx;
 snd_pcm_t *playback_handle;
 int bits_per_sample = 0;

 if (avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) != 0) {
 printf("Failed to open video file!");
 return -1; // Couldn't open file
 }

 if(avformat_find_stream_info(pFormatCtx,NULL)<0)
 {
 printf("Failed to find stream info.\n");
 return -1;
 }

 audioStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0);
 if (audioStream == -1) {
 printf("Din't find a video stream!");
 return -1;// Didn't find a video stream
 }

 av_dump_format(pFormatCtx, audioStream, NULL, false);

 // Find the decoder for the video stream
 pCodec = avcodec_find_decoder(pFormatCtx->streams[audioStream]->codecpar->codec_id);
 if (pCodec == NULL) {
 printf("Unsupported codec!\n");
 return -1; // Codec not found
 }

 // Copy context
 pCodecCtx = avcodec_alloc_context3(pCodec);
 AVCodecParameters *pCodecParam = pFormatCtx->streams[audioStream]->codecpar;

 if (avcodec_parameters_to_context(pCodecCtx, pCodecParam) < 0) {
 printf("Failed to set codec params\n");
 return -1;
 }
 // Open codec
 if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) {
 printf("Failed to open decoder!\n");
 return -1; // Could not open codec
 }
 packet = av_packet_alloc();
 pFrame = av_frame_alloc();

 uint64_t iInputLayout = av_get_default_channel_layout(pCodecCtx->channels);
 enum AVSampleFormat eInputSampleFormat = pCodecCtx->sample_fmt;
 int iInputSampleRate = pCodecCtx->sample_rate;


 uint64_t iOutputLayout = av_get_default_channel_layout(pCodecCtx->channels);
 int iOutputChans = pCodecCtx->channels;
 enum AVSampleFormat eOutputSampleFormat = AV_SAMPLE_FMT_S16;
 int iOutputSampleRate = pCodecCtx->sample_rate;

 au_convert_ctx = swr_alloc_set_opts(NULL,iOutputLayout, eOutputSampleFormat, iOutputSampleRate,
 iInputLayout,eInputSampleFormat, iInputSampleRate, 0, NULL);
 swr_init(au_convert_ctx);
 int iConvertLineSize = 0;
 int iConvertBuffSize = av_samples_get_buffer_size(&iConvertLineSize, iOutputChans, pCodecCtx->frame_size, eOutputSampleFormat, 0);
 printf("ochans: %d, ifrmsmp: %d, osfmt: %d, cbufsz: %d\n", iOutputChans, pCodecCtx->frame_size, eOutputSampleFormat, iConvertBuffSize);
 out_buffer = (uint8_t *) av_malloc(iConvertBuffSize);

 if(eOutputSampleFormat == AV_SAMPLE_FMT_S16 )
 {
 bits_per_sample = 16;
 }
 /*** alsa handle ***/
 init_pcm_play(&playback_handle,256, iOutputSampleRate,bits_per_sample,2);

 if (0 > snd_pcm_prepare (playback_handle))
 {
 printf("snd_pcm_prepare err\n");
 return -1;
 }

 while (av_read_frame(pFormatCtx, packet) >= 0) {
 if (packet->stream_index == audioStream) {
 avcodec_send_packet(pCodecCtx, packet);
 while (avcodec_receive_frame(pCodecCtx, pFrame) == 0) {
 int outframes = swr_convert(au_convert_ctx, &out_buffer, pCodecCtx->frame_size, (const uint8_t **) pFrame->data, pFrame->nb_samples); // 转换音频
 snd_pcm_writei(playback_handle, out_buffer, outframes);
 av_frame_unref(pFrame);
 }
 }
 av_packet_unref(packet);
 }
 swr_free(&au_convert_ctx);
 snd_pcm_close(playback_handle);
 av_freep(&out_buffer);

 return 0;
}



Running the codes can show following logs.


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



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


-
FFmpeg wrong codecstring for DASH manifest [closed]
21 novembre 2024, par SuxsemI'm trying to create a DASH stream with ffmpeg with the following command :


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



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 :


<?xml version="1.0" encoding="utf-8"?>
<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">
 <programinformation>
 
 </programinformation>
 <servicedescription>
 </servicedescription>
 <period start="PT0.0S">
 <adaptationset contenttype="video" startwithsap="1" segmentalignment="true" bitstreamswitching="true" maxwidth="2304" maxheight="1296" par="16:9">
 <representation mimetype="video/mp4" codecs="hev1" bandwidth="822093" width="2304" height="1296" scantype="unknown" sar="1:1">
 <segmenttemplate timescale="90000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startnumber="1">
 <segmenttimeline>
 <s t="0" d="542990"></s>
 </segmenttimeline>
 </segmenttemplate>
 </representation>
 </adaptationset>
 <adaptationset contenttype="audio" startwithsap="1" segmentalignment="true" bitstreamswitching="true">
 <representation mimetype="audio/mp4" codecs="mp4a.40.2" bandwidth="34143" audiosamplingrate="16000">
 <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1"></audiochannelconfiguration>
 <segmenttemplate timescale="16000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startnumber="1">
 <segmenttimeline>
 <s t="0" d="81001"></s>
 </segmenttimeline>
 </segmenttemplate>
 </representation>
 </adaptationset>
 </period>
</mpd>



This is the output of ffprobe :


SDP:
v=0
o=- 1732188474342789 1 IN IP4 192.168.12.162
s=Session streamed by "rRTSPServer"
i=ch0_0.h264
t=0 0
a=tool:LIVE555 Streaming Media v2023.01.19
a=type:broadcast
a=control:*
a=range:npt=now-
a=x-qt-text-nam:Session streamed by "rRTSPServer"
a=x-qt-text-inf:ch0_0.h264
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:700
a=rtpmap:96 H265/90000
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
a=control:track1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:32
a=rtpmap:97 MPEG4-GENERIC/16000
a=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408
a=control:track2



it seems to me that all codec informations are present :


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



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


Thank you


-
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.5Signed-off-by : Martin Storsjö <martin@martin.st>