
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (24)
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
ANNEXE : Les plugins utilisés spécifiquement pour la ferme
5 mars 2010, parLe site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)
-
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...)
Sur d’autres sites (3781)
-
How extract JPEG image from H264 stream in constant time
27 août 2021, par Ross GardinerI want to extract a JPEG frame from a H264 stream on disk. The extraction needs to be as fast as possible for my real-time requirements.


Until now I have been using
ffmpeg-python
lib which is just a python wrapper forffmpeg
. Here is a code snippet :

out, _ = (
 ffmpeg
 .input('./5sec.h264')
 .filter('select', 'gte(n,{})'.format(144))
 .output('pipe:', vframes=1, format='image2', vcodec='h264')
 .run(capture_stdout=True)
)



This outputs the jpeg to stdout, with some effort I could read this into my program.


However, as I use larger and larger stream files the extraction time to grab the JPEG increases. I thought lookup time would be constant as
ffmpeg
is highly optimised ?

Is there a constant time solution to lookup and return a frame from a h264 (or even mjpeg) format stream on disk ?


Edit :
Heres the command I use without the python wrapper :

ffmpeg -i 5sec.h264 -frames:v 1 -filter:v "select=gte(n\,25)" -f image2 frame.jpg


here's output :


ffmpeg version 4.1.6-1~deb10u1+rpt2 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 8 (Raspbian 8.3.0-6+rpi1)
 configuration: --prefix=/usr --extra-version='1~deb10u1+rpt2' --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-vout-drm --enable-v4l2-request --enable-libudev --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
 libavutil 56. 22.100 / 56. 22.100
 libavcodec 58. 35.100 / 58. 35.100
 libavformat 58. 20.100 / 58. 20.100
 libavdevice 58. 5.100 / 58. 5.100
 libavfilter 7. 40.101 / 7. 40.101
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 3.100 / 5. 3.100
 libswresample 3. 3.100 / 3. 3.100
 libpostproc 55. 3.100 / 55. 3.100
Input #0, h264, from '5sec.h264':
 Duration: N/A, bitrate: N/A
 Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x480, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x1a25390] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'frame.jpg':
 Metadata:
 encoder : Lavf58.20.100
 Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x480, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
 Metadata:
 encoder : Lavc58.35.100 mjpeg
 Side data:
 cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 1 fps=0.4 q=6.8 Lsize=N/A time=00:00:01.04 bitrate=N/A speed=0.467x 
video:63kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown



Note, achieved FPS is 0.4. When I increase the requested frame to be the 125th frame rather than the 25th, the FPS goes down to 0.1.


-
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);
 }
 }



-
doc/developer.texi : drop a misplaced sentence from code formatting section
15 novembre 2022, par Anton Khirnov