
Recherche avancée
Autres articles (111)
-
Gestion générale des documents
13 mai 2011, parMédiaSPIP ne modifie jamais le document original mis en ligne.
Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...) -
(Dés)Activation de fonctionnalités (plugins)
18 février 2011, parPour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...) -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
Sur d’autres sites (8222)
-
Ffmpeg AVAudioFifo memory leak
10 août 2020, par ExpressingxI'm encoding audio to
AAC
with encoder. Because it requires I'm usingAVAudioFifo
following https://ffmpeg.org/doxygen/4.0/transcode_aac_8c-example.html

Everything works, but I can see my memory slowly growing up. If I comment out
PushToFifo()
no memory leaks. And not sure why. I've profiled the app withANTS Profiler
and I can see a lot of unmanaged memory allocated byavutil-x.dll
.

while (ffmpeg.av_read_frame(_inputContext.InputFormatContext, pkt) >= 0)
{
 // decode
 int ret = ffmpeg.avcodec_send_packet(decCtx, pkt);

 if (ret < 0)
 {
 ffmpeg.av_packet_unref(pkt);
 return;
 }

 while (ret >= 0)
 {
 ret = ffmpeg.avcodec_receive_frame(decCtx, frame);

 if (ret == ffmpeg.AVERROR(ffmpeg.EAGAIN) || ret == ffmpeg.AVERROR_EOF)
 {
 return;
 }
 
 // push to fifo
 PushToFifo();
 TryFlushSamples();
 }
}



PushToFifo()


byte* samples = null;

 if (ffmpeg.av_samples_alloc(&samples, null, _outputContext->channels, inputFrame->nb_samples, _outputContext->sample_fmt, 0) < 0)
 {
 ffmpeg.av_freep(&samples[0]);
 ffmpeg.av_free(samples);
 // throw
 }

 if (ffmpeg.swr_convert(_resamplerCtx, &samples, inputFrame->nb_samples, inputFrame->extended_data, inputFrame->nb_samples) < 0)
 {
 throw new Exception();
 }

 if (ffmpeg.av_audio_fifo_realloc(AudioFifo, ffmpeg.av_audio_fifo_size(AudioFifo) + inputFrame->nb_samples) < 0)
 {
 throw new Exception();
 }

 if (ffmpeg.av_audio_fifo_write(AudioFifo, (void**)&samples, inputFrame->nb_samples) < 0)
 {
 throw new Exception();
 }



And in
TryFlushSamples();


while (ffmpeg.av_audio_fifo_size(_audioFifo.AudioFifo) >= _outputContext.AudioEncodeContext->frame_size)
 {
 int fifoSize = ffmpeg.av_audio_fifo_size(_audioFifo.AudioFifo);
 int frameSize = fifoSize > _outputContext.AudioEncodeContext->frame_size
 ? _outputContext.AudioEncodeContext->frame_size
 : fifoSize;

 var outputContext = _outputContext.AudioEncodeContext;
 var frame = ffmpeg.av_frame_alloc();
 frame->nb_samples = frameSize;
 frame->channel_layout = outputContext->channel_layout;
 frame->format = (int)outputContext->sample_fmt;
 frame->sample_rate = outputContext->sample_rate;

 if (ffmpeg.av_frame_get_buffer(frame, 0) < 0)
 ffmpeg.av_frame_free(&frame);

 // read frame
 if (ffmpeg.av_audio_fifo_read(_audioFifo.AudioFifo, (void**)&frame->data, frameSize) < frameSize)
 {
 ffmpeg.av_frame_free(&frame);
 return;
 }

 frame->pts = _audioFrameCount;
 _audioFrameCount += frame->nb_samples;

 // send to encoder 

 ffmpeg.av_frame_free(&frame);
 }



-
Discord BOT Music player : plays 3 songs at once
15 août 2020, par LaCalientaI am developing my Discord bot that plays music, I am using DSahrpPlus as a wrapper and got the bot mostly working


Commands get parsed corecly


using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.VoiceNext;

using WolfBot.Attributes;
using WolfBot.Commands.Music;

namespace WolfBot.Commands
{
 class MusicCommands : BaseCommandModule
 {
 int SongID = 1;
 MusicPlayer player;
 [Command("join")]
 [RequirePermissionsCustom(Permissions.UseVoice)]
 public async Task Join(CommandContext ctx)
 {
 //Initialize music player
 player = new MusicPlayer(ctx);

 var vnext = ctx.Client.GetVoiceNext();

 var vnc = vnext.GetConnection(ctx.Guild);
 if (vnc != null)
 {
 await ctx.RespondAsync("Already connected in this guild.");
 throw new InvalidOperationException("Already connected in this guild.");
 }

 var chn = ctx.Member?.VoiceState?.Channel;
 if (chn == null)
 {
 await ctx.RespondAsync("You need to be in a voice channel.");
 throw new InvalidOperationException("You need to be in a voice channel.");
 }

 vnc = await vnext.ConnectAsync(chn);
 await ctx.RespondAsync(DiscordEmoji.FromName(ctx.Client, ":ok_hand:")); //-
-
Ffmpeg H264_qsv encoder memory leak
12 août 2020, par ExpressingxI'm using
h264_qsv
encoder if available. If its available I'm scaling the frame toNV12


public AVFrame* GetOutputFrame(AVFrame* sourceFrame, AVPixelFormat targePixFmt)
 {
 AVPixelFormat sourcePixFmt = (AVPixelFormat)sourceFrame->format;

 if (_pConvertContext == null)
 {
 _pConvertContext = CreateContext(sourcePixFmt, targePixFmt);
 }

 if (_convertedFrameBufferPtr == IntPtr.Zero)
 {
 int buffSize = ffmpeg.av_image_get_buffer_size(targePixFmt, sourceFrame->width, sourceFrame->height, 1);
 _convertedFrameBufferPtr = Marshal.AllocHGlobal(buffSize);
 ffmpeg.av_image_fill_arrays(ref _dstData, ref _dstLinesize, (byte*)_convertedFrameBufferPtr, targePixFmt, sourceFrame->width, sourceFrame->height, 1);
 }

 return ScaleImage(_pConvertContext, sourceFrame, targePixFmt, _dstData, _dstLinesize);
 }



ScaleImage
. Here if I commend outav_buffer_alloc
I still get memory leak, but a lot less

private AVFrame* ScaleImage(SwsContext* ctx, AVFrame* sourceFrame, AVPixelFormat targePixelFormat, byte_ptrArray4 dstData, int_array4 dstLinesize)
 {
 var outFrame = ffmpeg.av_frame_alloc();

 int ret = ffmpeg.sws_scale(ctx, sourceFrame->data, sourceFrame->linesize, 0, sourceFrame->height, dstData, dstLinesize);

 if (ret < 0)
 //throw;

 var data = new byte_ptrArray8();
 data.UpdateFrom(dstData);
 var linesize = new int_array8();
 linesize.UpdateFrom(dstLinesize);

 outFrame->data = data;
 outFrame->linesize = linesize;
 outFrame->width = sourceFrame->width;
 outFrame->height = sourceFrame->height;
 outFrame->format = (int)targePixelFormat;
 //outFrame->buf[0] = ffmpeg.av_buffer_alloc(
 // ffmpeg.av_image_get_buffer_size(targePixelFormat, sourceFrame->width, sourceFrame->height, 1) + ffmpeg.AV_INPUT_BUFFER_PADDING_SIZE); ;

 return outFrame;
 }



After the frame is ready send to codec


private void EncodeFrameToFile(AVCodecContext* ctx, AVFrame* outFrame, int streamIndex)
 {
 _outPkt->stream_index = streamIndex;

 // let the encoder assume what should be the type
 if (outFrame != null)
 {
 outFrame->pict_type = AVPictureType.AV_PICTURE_TYPE_NONE;
 }

 int ret = ffmpeg.avcodec_send_frame(ctx, outFrame);

 if (ret < 0)
 {
 ffmpeg.av_packet_unref(_outPkt);
 return;
 }

 while (ret >= 0)
 {
 ret = ffmpeg.avcodec_receive_packet(ctx, _outPkt);

 if (ret == ffmpeg.AVERROR(ffmpeg.EAGAIN) || ret == ffmpeg.AVERROR_EOF)
 {
 ffmpeg.av_packet_unref(_outPkt);
 return;
 }

 if (ret < 0)
 {
 ffmpeg.av_packet_unref(_outPkt);
 ffmpeg.av_log(null, ffmpeg.AV_LOG_ERROR, "Error during encoding.");
 break;
 }

 int out_stream_index = _inputContext.GetStreamIndex(_outPkt->stream_index);
 AVStream* out_stream = _outputContext.OutputFormatContext->streams[out_stream_index];

 ffmpeg.av_packet_rescale_ts(_outPkt, ctx->time_base, out_stream->time_base);

 ret = ffmpeg.av_interleaved_write_frame(_outputContext.OutputFormatContext, _outPkt);

 if (ret < 0)
 {
 ffmpeg.av_packet_unref(_outPkt);
 ffmpeg.av_log(null, ffmpeg.AV_LOG_ERROR, "Error muxing packet.");
 break;
 }

 ffmpeg.av_packet_unref(_outPkt);
 }
 }



And when the frame is written to the file


ffmpeg.av_frame_free(&frame);



If I comment


ret = ffmpeg.avcodec_receive_packet(ctx, _outPkt);



The leak is gone. But of course no file. Any suggestions ? I'm using
ffmpeg 4.3.1