
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (67)
-
Le profil des utilisateurs
12 avril 2011, parChaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...) -
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
XMP PHP
13 mai 2011, parDixit Wikipedia, XMP signifie :
Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)
Sur d’autres sites (5008)
-
StackOverflowException with Process in C#
4 juin 2015, par user3633222I have a process, which runs in a console app. It runs forever.
After a couple of days the app crashes with a StackOverflowException.
The essence of the app is where I spin up a Process with FFMpeg.exe and creates a sceenshot of a video stream. It works very good but only for a few days at the time.
I am pretty sure it has to do with the disposal of the FFMpeg or some internal Process stuff.
Here is the code
using ( Process ffmpegProcess = new Process() ) {
//arguments for running ffmpeg
ffmpegProcess.StartInfo.UseShellExecute = false;
ffmpegProcess.StartInfo.CreateNoWindow = true;
ffmpegProcess.StartInfo.RedirectStandardOutput = true;
//specific for our screenshots
ffmpegProcess.StartInfo.FileName = string.Concat( Environment.CurrentDirectory, Path.DirectorySeparatorChar, ffmpegProgramName );
try {
//todo: log this stopwatch somewhere perhaps
processWatch.Start();
//set arguments every time we want to create a new screen shot
ffmpegProcess.StartInfo.Arguments = string.Format( @"-y -i {0}{1} -threads 0 -ss 00:00:01.000 -f image2 -s 620x349 -vframes 1 ../../web/{2}.jpg", server, streamPath, slug );
ffmpegProcess.Start();
ffmpegProcess.WaitForExit( 500 );
Console.WriteLine( slug );
Console.WriteLine( processWatch.Elapsed );
processWatch.Reset();
runCount++;
cacheIndexer++;
//lets see how many spins we've had!
Console.WriteLine( string.Format( "SERVER CACHE INDEX : {0}", cacheIndexer ) );
Console.WriteLine( string.Format( "RUN : {0}", runCount ) );
Console.WriteLine( Environment.NewLine );
} catch ( Exception ex ) {
//Console.WriteLine( "Ex " + ex );
}
}The loop looks like this.
public void RecurseTask() {
/*
You can try one of these, but you will se CPU usage go crazy and perhaps concurrency errors due IO blocking
Parallel.ForEach( _videoStreamSlugs, ( e ) => _videoStreamScreenShots.GrabScreenShot( e ) );
foreach ( var slug in _videoStreamSlugs ) {
Task.Run( () => _videoStreamScreenShots.GrabScreenShot( slug ) );
}
*/
//we want to grab screen shots for every slug in out slug list!
foreach ( var slug in _videoStreamSlugs ) {
_videoStreamScreenShots.GrabScreenShot( slug );
}
//sleep for a little while
Thread.Sleep( _recurseInterval );
//A heavy clean up!
//We do this, trying to avoid a stackoverflow excecption in the recursive method
//Please inspect this if problems arise
GC.Collect();
//lets grab over again
RecurseTask();
}I added a GC.Collect out of curiosity to see if it made a difference.
I am not doing a Windows Service.
-
Pass both resolve and reject callbacks to the process pipe.
24 avril 2013, par blueimpm js/jquery.fileupload.js
Pass both resolve and reject callbacks to the process pipe.
-
ffmpeg how to ignore initial empty audio frames when decoding to loop a sound
1er décembre 2020, par cs guyI am trying to loop a ogg sound file. The goal is to make a loopable audio interface for my mobile app.


I decode the given ogg file into a buffer and that buffer is sent to audio card for playing. All good until it the audio finishes (end of file). When it finishes I use
av_seek_frame(avFormatContext, streamInfoIndex, 0, AVSEEK_FLAG_FRAME);
to basically loop back to beginning. And continue decoding into writing to the same buffer. At first sight I thought this would give me perfect loops. One problem I had was, the decoder in the end gives me extra empty frames. So I ignored them by keeping track of how many samples are decoded :

durationInMillis = avFormatContext->duration * 1000;
numOfTotalSamples =
 (uint64_t) avFormatContext->duration *
 (uint64_t) pLocalCodecParameters->sample_rate *
 (uint64_t) pLocalCodecParameters->channels /
 (uint64_t) AV_TIME_BASE;



When the threshold is reached I ignore the frames sent by the codec. I thought this was it and ran some test. I recorded 5 minutes of my app and in the end I compared the results in FL studio by customly adding the same sound clip several times to match the length of my audio recording :


Here it is after 5 minutes :




In the first loops the difference is very low I thought it was working and I used this for several days until I tested this on 5 minute recording. As the looping approached to 5 minutes mark the difference got very huge. My code is not looping the audio correctly. I suspect that the codec is adding 1 or 2 empty frames at the very beginning in each loop caused by
av_seek_frame
knowing that a frame can contain up several audio samples. These probably accumulate and cause the mismatch.

My question is : how can I drop the empty frames that is sent by codec while decoding so that I can create a perfect loop of the audio ?


My code is below here. Please be aware that I deleted lots of if checks that was inteded for safety to make it more readable in the code below, these removed checks are always false so it doesnt matter for the reader.


helper.cpp


int32_t
outputAudioFrame(AVCodecContext *avCodecContext, AVFrame *avResampledDecFrame, int32_t &ret,
 LockFreeQueue<float> *&buffer, int8_t *&mediaLoadPointer,
 AVFrame *avDecoderFrame, SwrContext *swrContext,
 std::atomic_bool *&signalExitFuture,
 uint64_t &currentNumSamples, uint64_t &numOfTotalSamples) {
 // resampling is done here but its boiler code so I removed it.
 auto *floatArrPtr = (float *) (avResampledDecFrame->data[0]);

 int32_t numOfSamples = avResampledDecFrame->nb_samples * avResampledDecFrame->channels;

 for (int32_t i = 0; i < numOfSamples; i++) {
 if (currentNumSamples == numOfTotalSamples) {
 break;
 }

 buffer->push(*floatArrPtr);
 currentNumSamples++;
 floatArrPtr++;
 }

 return 0;
}



int32_t decode(int32_t &ret, AVCodecContext *avCodecContext, AVPacket *avPacket,
 LockFreeQueue<float> *&buffer,
 AVFrame *avDecoderFrame,
 AVFrame *avResampledDecFrame,
 std::atomic_bool *&signalExitFuture,
 int8_t *&mediaLoadPointer, SwrContext *swrContext,
 uint64_t &currentNumSamples, uint64_t &numOfTotalSamples) {
 
 ret = avcodec_send_packet(avCodecContext, avPacket);
 if (ret < 0) {
 LOGE("decode: Error submitting a packet for decoding %s", av_err2str(ret));
 return ret;
 }

 // get all the available frames from the decoder
 while (ret >= 0) {

 // submit the packet to the decoder
 ret = avcodec_receive_frame(avCodecContext, avDecoderFrame);
 if (ret < 0) {
 // those two return values are special and mean there is no output
 // frame available, but there were no errors during decoding
 if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) {
 //LOGD("avcodec_receive_frame returned special %s", av_err2str(ret));
 return 0;
 }

 LOGE("avcodec_receive_frame Error during decoding %s", av_err2str(ret));
 return ret;
 }

 ret = outputAudioFrame(avCodecContext, avResampledDecFrame, ret, buffer,
 mediaLoadPointer, avDecoderFrame, swrContext, signalExitFuture,
 currentNumSamples, numOfTotalSamples);

 av_frame_unref(avDecoderFrame);
 av_frame_unref(avResampledDecFrame);

 if (ret < 0)
 return ret;
 }

 return 0;
}
</float></float>


Main.cpp


while (!*signalExitFuture) {
 while ((ret = av_read_frame(avFormatContext, avPacket)) >= 0) {

 ret = decode(ret, avCodecContext, avPacket, buffer, avDecoderFrame,
 avResampledDecFrame, signalExitFuture,
 mediaLoadPointer, swrContext,
 currentNumSamples, numOfTotalSamples);

 // The packet must be freed with av_packet_unref() when it is no longer needed.
 av_packet_unref(avPacket);

 if (ret < 0) {
 LOGE("Error! %s", av_err2str(ret));

 goto cleanup;
 }
 }

 if (ret == AVERROR_EOF) {

 ret = av_seek_frame(avFormatContext, streamInfoIndex, 0, AVSEEK_FLAG_FRAME);

 currentNumSamples = 0;
 avcodec_flush_buffers(avCodecContext);
 }
 }