
Recherche avancée
Autres articles (57)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...)
Sur d’autres sites (10331)
-
ffmpeg decoding mixing frames
4 avril, par Paulo MorgadoI'm using FFmpeg.AutoGen in a .NET 8.0 application for decoding H264 and JPEG.


Every usage uses its own instance (there are no shared objects) and there isn't simultanous use of each object.


However, they can be used from different threads.


But I'm getting the encoded results with mixed data from all sources. It happens mostly for the same origin codeec, but not esclusivelly.


I have a base class that looks like this :


public abstract unsafe class Decoder : IDisposable
{
 protected readonly object sync = new();
 protected AVCodecContext* codecContext;
 protected AVFrame* frame;
 protected AVPacket* packet;
 protected SwsContext* swsContext;
 private bool disposed = false;

 protected Decoder(AVCodecID codecId, ChannelWriter<(ArraySegment<byte> decodedData, int width, int height)> writer)
 {
 Writer = writer;
 var codec = ffmpeg.avcodec_find_decoder(codecId);
 codecContext = ffmpeg.avcodec_alloc_context3(codec);
 ffmpeg.avcodec_open2(codecContext, codec, null);

 frame = ffmpeg.av_frame_alloc();
 packet = ffmpeg.av_packet_alloc();
 }
...
</byte>


This is the H264 decoding code :


public override void Decode(ReadOnlySpan<byte> data)
{
 CheckDisposed();

 lock (sync)
 {
 fixed (byte* pData = data)
 {
 ffmpeg.av_packet_unref(packet);

 packet->data = pData;
 packet->size = data.Length;

 var result = ffmpeg.avcodec_send_packet(codecContext, packet);
 if (result < 0 && result != ffmpeg.AVERROR(ffmpeg.EAGAIN))
 {
 EvalResult(result);
 }

 while (true)
 {
 ffmpeg.av_frame_unref(frame);

 result = ffmpeg.avcodec_receive_frame(codecContext, frame);
 if (result == ffmpeg.AVERROR(ffmpeg.EAGAIN))
 {
 // Need more input data, continue sending packets
 return;
 }
 else if (result < 0)
 {
 EvalResult(result);
 }

 var width = frame->width;
 var height = frame->height;

 if (swsContext == null)
 {
 swsContext = ffmpeg.sws_getContext(
 width, height, (AVPixelFormat)frame->format,
 width, height, AVPixelFormat.AV_PIX_FMT_BGRA,
 ffmpeg.SWS_BILINEAR, null, null, null);
 }

 var bgraFrame = ffmpeg.av_frame_alloc();
 bgraFrame->format = (int)AVPixelFormat.AV_PIX_FMT_BGRA;
 bgraFrame->width = width;
 bgraFrame->height = height;
 ffmpeg.av_frame_get_buffer(bgraFrame, 32);

 ffmpeg.sws_scale(
 swsContext,
 frame->data, frame->linesize, 0, height,
 bgraFrame->data, bgraFrame->linesize);

 var bgraSize = width * height * 4;
 var bgraArray = ArrayPool<byte>.Shared.Rent(bgraSize);
 var bgraSegment = new ArraySegment<byte>(bgraArray, 0, bgraSize);

 fixed (byte* pBGRAData = bgraSegment.Array)
 {
 var data4 = new byte_ptr4();
 data4.UpdateFrom(bgraFrame->data.ToArray());

 var linesize4 = new int4();
 linesize4.UpdateFrom(bgraFrame->linesize.ToArray());

 ffmpeg.av_image_copy_to_buffer(
 pBGRAData, bgraSize,
 data4, linesize4,
 (AVPixelFormat)bgraFrame->format, width, height, 1);
 }

 ffmpeg.av_frame_free(&bgraFrame);

 Writer.TryWrite((bgraSegment, width, height));
 }
 }
 }
}
</byte></byte></byte>


And this is the JPEG decoding code :


public override void Decode(ReadOnlySpan<byte> data)
{
 CheckDisposed();

 lock (sync)
 {
 fixed (byte* pData = data)
 {
 ffmpeg.av_packet_unref(packet);

 packet->data = pData;
 packet->size = data.Length;

 var result = ffmpeg.avcodec_send_packet(codecContext, packet);
 if (result < 0 && result != ffmpeg.AVERROR(ffmpeg.EAGAIN))
 {
 EvalResult(result);
 }

 while (true)
 {
 ffmpeg.av_frame_unref(frame);

 result = ffmpeg.avcodec_receive_frame(codecContext, frame);

 if (result == ffmpeg.AVERROR(ffmpeg.EAGAIN))
 {
 // Need more input data, continue sending packets
 return;
 }
 else if (result < 0)
 {
 EvalResult(result);
 }

 var width = frame->width;
 var height = frame->height;

 if (swsContext == null)
 {
 swsContext = ffmpeg.sws_getContext(
 width, height, (AVPixelFormat)frame->format,
 width, height, AVPixelFormat.AV_PIX_FMT_BGRA,
 ffmpeg.SWS_BILINEAR, null, null, null);
 }

 var bgraFrame = ffmpeg.av_frame_alloc();
 bgraFrame->format = (int)AVPixelFormat.AV_PIX_FMT_BGRA;
 bgraFrame->width = frame->width;
 bgraFrame->height = frame->height;
 ffmpeg.av_frame_get_buffer(bgraFrame, 32);

 ffmpeg.sws_scale(
 swsContext,
 frame->data, frame->linesize, 0, frame->height,
 bgraFrame->data, bgraFrame->linesize);

 int bgraDataSize = bgraFrame->linesize[0] * bgraFrame->height;
 byte[] bgraData = ArrayPool<byte>.Shared.Rent(bgraDataSize);
 var bgraSegment = new ArraySegment<byte>(bgraData, 0, bgraDataSize);
 Marshal.Copy((IntPtr)bgraFrame->data[0], bgraData, 0, bgraDataSize);

 ffmpeg.av_frame_free(&bgraFrame);

 Writer.TryWrite((bgraSegment, width, height));
 }
 }
 }
}
</byte></byte></byte>


What am I doing wrong here ?


-
Anomalie #3239 : _CACHE_CONTEXTES_AJAX génère un dossier /tmp/cache/contextes qui grossit à l’infini
19 juillet 2014, par marcimat ☺☮☯♫Juste un mot tout de même :
En SPIP 3, il ne faut pas déclarer cette constante. La solution intermédiaire qu’on utilise est de passer automatiquement par tmp/cache/contexte SI certaines conditions sont requises, au cas par cas. Particulièrement :
- si bug lors du décryptage du hash ajax (un bug sur une version de php) => on met le contexte en fichier cache
- si la longueur du hash dépasse la longueur autorisée pah suhosin (si présent) => on met le contexte en fichier cache.De la sorte, ça limite grandement le nombre de fichiers créés dans ce cache (et c’est fait de façon automatique).
Mais… ça ne résout pas du tout le problème : ces fichiers restent en cache et ne se nettoient jamais, ce qui potentiellement peut créer le même problème signalé ici.
-
Evolution #4363 : mot de passe vide bloque le formulaire de réinitialisation du mot de passe d’un ...
12 février 2021, par cy_altern -cedric - a écrit :
mais du coup maintenant qu’on sait qu’il y a une raison, est-il vraiment nécessaire de casser ça et de prendre un risque sécu dessus ?
perso je dirais que oui vu le nombre de fois où je me suis retrouvé à faire des bricolages à cause de ce mot de passe vide...
Ou alors il faut prévoir un upgrade de base qui fait le tout des auteurs sans mot de passe et vide le login si jamais il y en a un pour pas prendre de risque ?
si la réponse à question précédente est oui, ça semble être une soluce raisonnable
Je postpone car c’est super pas urgent, mais si quelqu’un veut faire une PR, gogogo
si besoin je finalise dès que les points ci-dessus sont tranchés :)