
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 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)
-
Cannot convert video file to audio file inside AWS lambda function using Node js
21 février 2019, par ArunI cannot convert a video file into an audio file inside AWS lambda function using Node JS. While running my lambda function it doesn’t throw any error it executes without any error. But the audio file size is still 0 MB size. I am not able to find bugs or any issues in my code.
Here is my code,
const fs = require('fs');
const childProcess = require('child_process');
const AWS = require('aws-sdk');
const path = require('path');
AWS.config.update({
region : 'us-east-2'
});
const s3 = new AWS.S3({apiVersion: '2006-03-01'});
exports.handler = (event, context, callback) => {
process.env.PATH = process.env.PATH + ':/tmp/';
process.env['FFMPEG_PATH'] = '/tmp/ffmpeg';
const BIN_PATH = process.env['LAMBDA_TASK_ROOT'];
process.env['PATH'] = process.env['PATH'] + ':' + BIN_PATH;
childProcess.exec(
'cp /var/task/ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg;',
function (error, stdout, stderr) {
if (error) {
console.log('Error occured',error);
} else {
var ffmpeg = '/tmp/ffmpeg';
var createStream = fs.createWriteStream("/tmp/video.mp3");
createStream.end();
var params = {
Bucket: "test-bucket",
Key: event.Records[0].s3.object.key
};
s3.getObject(params, function(err, data) {
if (err) {
console.log("Error", err);
}
fs.writeFile("/tmp/vid.mp4", data.Body, function (err) {
if (err) console.log(err.code, "-", err.message);
return callback(err);
}, function() {
try {
var stats = fs.statSync("/tmp/vid.mp4");
console.log("size of the file1 ", stats["size"]);
try {
console.log("Yeah");
const inputFilename = "/tmp/vid.mp4";
const mp3Filename = "/tmp/video.mp3";
// // Convert the FLV file to an MP3 file using ffmpeg.
const ffmpegArgs = [
'-i', inputFilename,
'-vn', // Disable the video stream in the output.
'-acodec', 'libmp3lame', // Use Lame for the mp3 encoding.
'-ac', '2', // Set 2 audio channels.
'-q:a', '6', // Set the quality to be roughly 128 kb/s.
mp3Filename,
];
try {
const process = childProcess.spawnSync(ffmpeg, ffmpegArgs);
console.log("stdout ", process.stdout);
console.log("stderr ", process.stderr);
console.log("tmp files ");
fs.readdir('/tmp/', (err, files) => {
files.forEach(file => {
var stats = fs.statSync(`/tmp/${file}`);
console.log("size of the file2 ", stats["size"]);
console.log(file);
});
});
} catch (e) {
console.log("error while converting video to audio ", e);
}
// return process;
} catch (e) {
console.log(e);
}
} catch (e) {
console.log("file is not complete", e);
}
}, function () {
console.log("checking ");
var stats = fs.statSync("/tmp/video.mp3");
console.log("size of the file2 ", stats["size"]);
});
return callback(err);
});
}
}
)
}Code workflow
First of all, I have downloaded ffmpeg binary exec file and put into my project directory. After that, I compressed my project and put it into the lambda function. This lambda function will be triggered whenever the new files are uploaded into an S3 bucket. I have checked /tmp/ storage files and the audio file .mp3 present but the size is 0 MB.
Note
And also, in my code the below is not calling or this part is not reaching. When I look into Cloudwatch logs I can’t see this console log messages. I don’t know why this function is not calling.
function () {
console.log("checking ");
var stats = fs.statSync("/tmp/video.mp3");
console.log("size of the file2 ", stats["size"]);
});Please help me to find the solution of this issue. I have spent a lot of times to figure out this issue. But I am not able to find the solution. Any suggestions are welcome !!
Thanks, -
Stream webm to node.js from c# application in chunks
29 mai 2018, par Dan-Levi TømtaI am in the process of learning about streaming between node.js with socket.io and c#.
I have code that successfully records the screen with ffmpeg, redirects it StandardOutput.BaseStream and stores it into a Memorybuffer, when i click stop in my application it sends the memorystream as a byte array to the node.js server which are storing the file so the clients can play it. This are working just fine and here are my setup for that :
C#
bool ffWorkerIsWorking = false;
private void btnFFMpeg_Click(object sender, RoutedEventArgs e)
{
BackgroundWorker ffWorker = new BackgroundWorker();
ffWorker.WorkerSupportsCancellation = true;
ffWorker.DoWork += ((ffWorkerObj,ffWorkerEventArgs) =>
{
ffWorkerIsWorking = true;
using (var FFProcess = new Process())
{
var processStartInfo = new ProcessStartInfo
{
FileName = "ffmpeg.exe",
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = false,
Arguments = " -loglevel panic -hide_banner -y -f gdigrab -draw_mouse 1 -i desktop -threads 2 -deadline realtime -f webm -"
};
FFProcess.StartInfo = processStartInfo;
FFProcess.Start();
byte[] buffer = new byte[32768];
using (MemoryStream ms = new MemoryStream())
{
while (!FFProcess.HasExited)
{
int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
ms.Write(buffer, 0, read);
Console.WriteLine(ms.Length);
if (!ffWorkerIsWorking)
{
clientSocket.Emit("video", ms.ToArray());
ffWorker.CancelAsync();
break;
}
}
}
}
});
ffWorker.RunWorkerAsync();
}JS (Server)
socket.on('video', function(data) {
fs.appendFile('public/fooTest.webm', data, function (err) {
if (err) throw err;
console.log('File uploaded');
});
});Now i need to change this code so it instead of sending the whole file it should sends chunks of byte arrays instead of the whole video, and node will then initially create a file and then append those chunks of byte arrays as they are received. Ok sound easy enough, but apparently not.
I need to somehow instruct the code to use a offset and just the bytes after that offset and then update the offset.
On the server side i think the best approach is to create a file and append the byte arrays to that file as they are received.
On the server side i would do something like this :
JS (Server)
var buffer = new Buffer(32768);
var isBuffering = false;
socket.on('video', function(data) {
//concatenate the buffer with the incoming data and broadcast.emit to clients
});How am i able to setup the offset for the bytes to be sent and update that offset, and how would i approach the way of concatenating the data to the initialized buffer ?
I have tried to write some code that only reads from the offset to the end and it seems like this is working although the video when added up in node is just black :
C#
while (!FFProcess.HasExited)
{
int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
int offset = (read - buffer.Length > 0 ? read - buffer.Length : 0);
ms.Write(buffer, offset, read);
clientSocket.Emit("videoChunk", buffer.ToArray());
if (!ffWorkerIsWorking)
{
ffWorker.CancelAsync();
break;
}
}Node console output
JS (Server)
socket.on('videoChunk', function(data) {
if (!isBufferingDone) {
buffer = Buffer.concat([buffer, data]);
console.log(data.length);
}
});
socket.on('cancelVideo', function() {
isBufferingDone = true;
setTimeout(function() {
fs.writeFile("public/test.webm", buffer, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
buffer = new Buffer(32768);
});
}, 1000);
});JS (Client)
socket.on('video', function(filePath) {
console.log('path: ' + filePath);
$('#videoSource').attr('src',filePath);
$('#video').play();
});Thanks !
-
Stream webm to node.js from c# application in chunks
7 août 2015, par Dan-Levi TømtaI am in the process of learning about streaming between node.js with socket.io and c#.
I have code that successfully records the screen with ffmpeg, redirects it StandardOutput.BaseStream and stores it into a Memorybuffer, when i click stop in my application it sends the memorystream as a byte array to the node.js server which are storing the file so the clients can play it. This are working just fine and here are my setup for that :
C#
bool ffWorkerIsWorking = false;
private void btnFFMpeg_Click(object sender, RoutedEventArgs e)
{
BackgroundWorker ffWorker = new BackgroundWorker();
ffWorker.WorkerSupportsCancellation = true;
ffWorker.DoWork += ((ffWorkerObj,ffWorkerEventArgs) =>
{
ffWorkerIsWorking = true;
using (var FFProcess = new Process())
{
var processStartInfo = new ProcessStartInfo
{
FileName = "ffmpeg.exe",
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = false,
Arguments = " -loglevel panic -hide_banner -y -f gdigrab -draw_mouse 1 -i desktop -threads 2 -deadline realtime -f webm -"
};
FFProcess.StartInfo = processStartInfo;
FFProcess.Start();
byte[] buffer = new byte[32768];
using (MemoryStream ms = new MemoryStream())
{
while (!FFProcess.HasExited)
{
int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
ms.Write(buffer, 0, read);
Console.WriteLine(ms.Length);
if (!ffWorkerIsWorking)
{
clientSocket.Emit("video", ms.ToArray());
ffWorker.CancelAsync();
break;
}
}
}
}
});
ffWorker.RunWorkerAsync();
}JS (Server)
socket.on('video', function(data) {
fs.appendFile('public/fooTest.webm', data, function (err) {
if (err) throw err;
console.log('File uploaded');
});
});Now i need to change this code so it instead of sending the whole file it should sends chunks of byte arrays instead of the whole video, and node will then initially create a file and then append those chunks of byte arrays as they are received. Ok sound easy enough, but apparently not.
I need to somehow instruct the code to use a offset and just the bytes after that offset and then update the offset.
On the server side i think the best approach is to create a file and append the byte arrays to that file as they are received.
On the server side i would do something like this :
JS (Server)
var buffer = new Buffer(32768);
var isBuffering = false;
socket.on('video', function(data) {
//concatenate the buffer with the incoming data and broadcast.emit to clients
});How am i able to setup the offset for the bytes to be sent and update that offset, and how would i approach the way of concatenating the data to the initialized buffer ?
I have tried to write some code that only reads from the offset to the end and it seems like this is working although the video when added up in node is just black :
C#
while (!FFProcess.HasExited)
{
int read = FFProcess.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
int offset = (read - buffer.Length > 0 ? read - buffer.Length : 0);
ms.Write(buffer, offset, read);
clientSocket.Emit("videoChunk", buffer.ToArray());
if (!ffWorkerIsWorking)
{
ffWorker.CancelAsync();
break;
}
}Node console output
JS (Server)
socket.on('videoChunk', function(data) {
if (!isBufferingDone) {
buffer = Buffer.concat([buffer, data]);
console.log(data.length);
}
});
socket.on('cancelVideo', function() {
isBufferingDone = true;
setTimeout(function() {
fs.writeFile("public/test.webm", buffer, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
buffer = new Buffer(32768);
});
}, 1000);
});JS (Client)
socket.on('video', function(filePath) {
console.log('path: ' + filePath);
$('#videoSource').attr('src',filePath);
$('#video').play();
});Thanks !