
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 (9)
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Les thèmes de MediaSpip
4 juin 20133 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
Thèmes MediaSPIP
3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...) -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...)
Sur d’autres sites (2816)
-
FFmpeg conversion RGB to YUV420 to RGB wrong result
29 août 2020, par sipwizI'm attempting to sort out a video encoding issue and along the way making sure I can convert between pixel formats with FFmpeg. I'm having a problem converting a dummy RGB24 bitmap to YUV420 and back again.


Below is my test program :


#include "Windows.h"

#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavformat></libavformat>avio.h>
#include <libavutil></libavutil>imgutils.h>
#include <libswscale></libswscale>swscale.h>
#include <libavutil></libavutil>time.h>

#define WIDTH 32
#define HEIGHT 32
#define ERROR_LEN 128
#define SWS_FLAGS SWS_BICUBIC

char _errorLog[ERROR_LEN];
void CreateBitmapFile(LPCWSTR fileName, long width, long height, WORD bitsPerPixel, BYTE* bitmapData, DWORD bitmapDataLength);

int main()
{
 printf("FFmpeg Pixel Conversion Test\n");

 av_log_set_level(AV_LOG_DEBUG);

 int w = WIDTH;
 int h = HEIGHT;

 struct SwsContext* rgbToI420Context;
 struct SwsContext* i420ToRgbContext;

 rgbToI420Context = sws_getContext(w, h, AV_PIX_FMT_RGB24, w, h, AV_PIX_FMT_YUV420P, SWS_FLAGS, NULL, NULL, NULL);
 if (rgbToI420Context == NULL) {
 fprintf(stderr, "Failed to allocate RGB to I420 conversion context.\n");
 }

 i420ToRgbContext = sws_getContext(w, h, AV_PIX_FMT_YUV420P, w, h, AV_PIX_FMT_RGB24, SWS_FLAGS, NULL, NULL, NULL);
 if (i420ToRgbContext == NULL) {
 fprintf(stderr, "Failed to allocate I420 to RGB conversion context.\n");
 }

 // Create dummy bitmap.
 uint8_t rgbRaw[WIDTH * HEIGHT * 3];
 for (int row = 0; row < 32; row++)
 {
 for (int col = 0; col < 32; col++)
 {
 int index = row * WIDTH * 3 + col * 3;

 int red = (row < 16 && col < 16) ? 255 : 0;
 int green = (row < 16 && col > 16) ? 255 : 0;
 int blue = (row > 16 && col < 16) ? 255 : 0;

 rgbRaw[index] = (byte)red;
 rgbRaw[index + 1] = (byte)green;
 rgbRaw[index + 2] = (byte)blue;
 }
 }

 CreateBitmapFile(L"test-reference.bmp", WIDTH, HEIGHT, 24, rgbRaw, WIDTH * HEIGHT * 3);

 printf("Converting RGB to I420.\n");

 uint8_t* rgb[3];
 uint8_t* i420[3];
 int rgbStride[3], i420Stride[3];

 rgbStride[0] = w * 3;
 i420Stride[0] = w * h;
 i420Stride[1] = w * h / 4;
 i420Stride[2] = w * h / 4;

 rgb[0] = rgbRaw;
 i420[0] = (uint8_t*)malloc((size_t)i420Stride[0] * h);
 i420[1] = (uint8_t*)malloc((size_t)i420Stride[1] * h);
 i420[2] = (uint8_t*)malloc((size_t)i420Stride[2] * h);

 int toI420Res = sws_scale(rgbToI420Context, rgb, rgbStride, 0, h, i420, i420Stride);
 if (toI420Res < 0) {
 fprintf(stderr, "Conversion from RGB to I420 failed, %s.\n", av_make_error_string(_errorLog, ERROR_LEN, toI420Res));
 }

 printf("Converting I420 to RGB.\n");

 uint8_t* rgbOut[3];
 int rgbOutStride[3];

 rgbOutStride[0] = w * 3;
 rgbOut[0] = (uint8_t*)malloc((size_t)rgbOutStride[0] * h);

 int toRgbRes = sws_scale(i420ToRgbContext, i420, i420Stride, 0, h, rgbOut, rgbOutStride);
 if (toRgbRes < 0) {
 fprintf(stderr, "Conversion from RGB to I420 failed, %s.\n", av_make_error_string(_errorLog, ERROR_LEN, toRgbRes));
 }

 CreateBitmapFile(L"test-output.bmp", WIDTH, HEIGHT, 24, rgbOut, WIDTH * HEIGHT * 3);

 free(rgbOut[0]);

 for (int i = 0; i < 3; i++) {
 free(i420[i]);
 }

 sws_freeContext(rgbToI420Context);
 sws_freeContext(i420ToRgbContext);

 return 0;
}

/**
* Creates a bitmap file and writes to disk.
* @param[in] fileName: the path to save the file at.
* @param[in] width: the width of the bitmap.
* @param[in] height: the height of the bitmap.
* @param[in] bitsPerPixel: colour depth of the bitmap pixels (typically 24 or 32).
* @param[in] bitmapData: a pointer to the bytes containing the bitmap data.
* @param[in] bitmapDataLength: the number of pixels in the bitmap.
*/
void CreateBitmapFile(LPCWSTR fileName, long width, long height, WORD bitsPerPixel, BYTE* bitmapData, DWORD bitmapDataLength)
{
 HANDLE file;
 BITMAPFILEHEADER fileHeader;
 BITMAPINFOHEADER fileInfo;
 DWORD writePosn = 0;

 file = CreateFile(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); //Sets up the new bmp to be written to

 fileHeader.bfType = 19778; //Sets our type to BM or bmp
 fileHeader.bfSize = sizeof(fileHeader.bfOffBits) + sizeof(RGBTRIPLE); //Sets the size equal to the size of the header struct
 fileHeader.bfReserved1 = 0; //sets the reserves to 0
 fileHeader.bfReserved2 = 0;
 fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); //Sets offbits equal to the size of file and info header
 fileInfo.biSize = sizeof(BITMAPINFOHEADER);
 fileInfo.biWidth = width;
 fileInfo.biHeight = height;
 fileInfo.biPlanes = 1;
 fileInfo.biBitCount = bitsPerPixel;
 fileInfo.biCompression = BI_RGB;
 fileInfo.biSizeImage = width * height * (bitsPerPixel / 8);
 fileInfo.biXPelsPerMeter = 2400;
 fileInfo.biYPelsPerMeter = 2400;
 fileInfo.biClrImportant = 0;
 fileInfo.biClrUsed = 0;

 WriteFile(file, &fileHeader, sizeof(fileHeader), &writePosn, NULL);

 WriteFile(file, &fileInfo, sizeof(fileInfo), &writePosn, NULL);

 WriteFile(file, bitmapData, bitmapDataLength, &writePosn, NULL);

 CloseHandle(file);
}



The source bitmap is :




The output bmp after the two conversions is :




-
Streaming a programatically created video to youtube using node and ffmpeg
23 septembre 2020, par CaltropI've been trying to Livestream a programmatically created image to youtube using node. I've had very limited success using FFmpeg. While I have managed to create and save an image thanks to this insightful thread, I have yet to make the code work for streaming to an RTMP server.


const cp = require('child_process'),
 destination = 'rtmp://a.rtmp.youtube.com/live2/[redacted]', //stream token redacted
 proc = cp.spawn('./ffmpeg/bin/ffmpeg.exe', [
 '-f', 'rawvideo',
 '-pix_fmt', 'rgb24',
 '-s', '426x240',
 '-i', '-', //allow us to insert a buffer through stdin
 '-f', 'flv',
 destination
 ]);

proc.stderr.pipe(process.stdout);

(function loop() {
 setTimeout(loop, 1000 / 30); //run loop at 30 fps
 const data = Array.from({length: 426 * 240 * 4}, () => ~~(Math.random() * 0xff)); //create array with random data
 proc.stdin.write(Buffer.from(data)); //convert array to buffer and send it to ffmpeg
})();



When running this code no errors appear and everything appears to be working, however, YouTube reports that no data is being received. Does anybody know what is going wrong here ?


Update : This is really counter-intuitive but adding a slash to the destination like this
'rtmp://a.rtmp.youtube.com/live2/[redacted]/'
causes ffmpeg to throw a genericI/O error
. This is really weird to me. Apologies if the answer to this is obvious, I'm really inexperienced with ffmpeg.

-
Convert audio blob to mp3 on expressjs server
27 septembre 2020, par islaloboI have a little app that captures sound and stores the audio as an audio blob encoded as base64 on an expressjs server. I would like to convert these audio files into
.mp3
or.wav
- any binary usable format. My understanding of audio files is very basic and I'm looking to gain a better understanding. Any guidance is appreciated. I've read through several posts and issues, but I'm just a bit lost right now.

Here is my client-side capture of the audio, encoding and then posting to expressjs server.


const saveMessage = async function(base64AudioMessage) {
 await fetch('/messages', {
 method: 'POST',
 headers: { 'Content-Type': 'application/json' },
 body: JSON.stringify({ message: base64AudioMessage })
 }).then(res => {
 if (res.status === 201) {
 const response = res.json()
 .then(response => {
 console.log(response);
 populateAudioMessages(response.id); // shows the recording that was just saved
 });
 }
 console.log('Invalid status saving audio message: ' + res.status);
 });
 return true;
 }

 sendButton.addEventListener('click', () => {
 const reader = new FileReader();
 reader.readAsDataURL(audio.audioBlob);
 reader.onload = async () => {
 const base64AudioMessage = reader.result.split(',')[1];
 
 await saveMessage(base64AudioMessage);
 };
 });



Here is the post method on my expressjs server. It's very messy as I have been trying to use
ffmpeg
to convert the posted files to.mp3
format.

app.post('/messages', (req, res) => {
 if (!req.body.message) {
 return res.status(400).json({ error: 'No req.body.message' });
 }
 const messageId = v4();
 writeFile(messageFolder + messageId, req.body.message, 'base64')
 .then(() => {
 console.log('messages was saved!');
 try {
 console.log('attempting to make an mp3 ', audioFolder + messageId);
 const process = new ffmpeg(`${messageFolder}${messageId}`);
 process.then((audio) => {
 console.log('audio is ready to be processed ', audio);
 audio.fnExtractSoundToMP3(`${audioFolder}${messageId}.mp3`, (error, file) => {
 console.log('There is an error ', error);
 console.log('There is a file ', file);
 if (!error) {
 console.log('Audio File ', file);
 const file = file;
 console.log('what a success! ', messageId && messageId, file && file);
 res.status(201).json({
 message: 'Saved message',
 });
 }
 })
 }, (err) => {
 console.log('An error occurred, ', err);
 });
 } catch(e) {
 console.log('error code ', e.code);
 console.log('error message ', e.msg);
 }
 })
 .catch(err => {
 console.log('Error writing message to file', err);
 res.sendStatus(500);
 });
});