
Recherche avancée
Autres articles (95)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Le plugin : Gestion de la mutualisation
2 mars 2010, parLe plugin de Gestion de mutualisation permet de gérer les différents canaux de mediaspip depuis un site maître. Il a pour but de fournir une solution pure SPIP afin de remplacer cette ancienne solution.
Installation basique
On installe les fichiers de SPIP sur le serveur.
On ajoute ensuite le plugin "mutualisation" à la racine du site comme décrit ici.
On customise le fichier mes_options.php central comme on le souhaite. Voilà pour l’exemple celui de la plateforme mediaspip.net :
< ?php (...) -
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation"
Sur d’autres sites (10654)
-
How do you use Node.js to stream an MP4 file with ffmpeg ?
27 avril 2023, par LaserJesusI've been trying to solve this problem for several days now and would really appreciate any help on the subject.



I'm able to successfully stream an mp4 audio file stored on a Node.js server using fluent-ffmpeg by passing the location of the file as a string and transcoding it to mp3. If I create a file stream from the same file and pass that to fluent-ffmpeg instead it works for an mp3 input file, but not a mp4 file. In the case of the mp4 file no error is thrown and it claims the stream completed successfully, but nothing is playing in the browser. I'm guessing this has to do with the meta data being stored at the end of an mp4 file, but I don't know how to code around this. This is the exact same file that works correctly when it's location is passed to ffmpeg, rather than the stream. When I try and pass a stream to the mp4 file on s3, again no error is thrown, but nothing streams to the browser. This isn't surprising as ffmpeg won't work with the file locally as stream, so expecting it to handle the stream from s3 is wishful thinking.



How can I stream the mp4 file from s3, without storing it locally as a file first ? How do I get ffmpeg to do this without transcoding the file too ? The following is the code I have at the moment which isn't working. Note that it attempts to pass the s3 file as a stream to ffmpeg and it's also transcoding it into an mp3, which I'd prefer not to do.



.get(function(req,res) {
 aws.s3(s3Bucket).getFile(s3Path, function (err, result) {
 if (err) {
 return next(err);
 }
 var proc = new ffmpeg(result)
 .withAudioCodec('libmp3lame')
 .format('mp3')
 .on('error', function (err, stdout, stderr) {
 console.log('an error happened: ' + err.message);
 console.log('ffmpeg stdout: ' + stdout);
 console.log('ffmpeg stderr: ' + stderr);
 })
 .on('end', function () {
 console.log('Processing finished !');
 })
 .on('progress', function (progress) {
 console.log('Processing: ' + progress.percent + '% done');
 })
 .pipe(res, {end: true});
 });
});




This is using the knox library when it calls aws.s3... I've also tried writing it using the standard aws sdk for Node.js, as shown below, but I get the same outcome as above.



var AWS = require('aws-sdk');

var s3 = new AWS.S3({
 accessKeyId: process.env.AWS_ACCESS_KEY_ID,
 secretAccessKey: process.env.AWS_SECRET_KEY,
 region: process.env.AWS_REGION_ID
});
var fileStream = s3.getObject({
 Bucket: s3Bucket,
 Key: s3Key
 }).createReadStream();
var proc = new ffmpeg(fileStream)
 .withAudioCodec('libmp3lame')
 .format('mp3')
 .on('error', function (err, stdout, stderr) {
 console.log('an error happened: ' + err.message);
 console.log('ffmpeg stdout: ' + stdout);
 console.log('ffmpeg stderr: ' + stderr);
 })
 .on('end', function () {
 console.log('Processing finished !');
 })
 .on('progress', function (progress) {
 console.log('Processing: ' + progress.percent + '% done');
 })
 .pipe(res, {end: true});




=====================================



Updated



I placed an mp3 file in the same s3 bucket and the code I have here worked and was able to stream the file through to the browser without storing a local copy. So the streaming issues I face have something to do with the mp4/aac container/encoder format.



I'm still interested in a way to bring the m4a file down from s3 to the Node.js server in it's entirety, then pass it to ffmpeg for streaming without actually storing the file in the local file system.



=====================================



Updated Again



I've managed to get the server streaming the file, as mp4, straight to the browser. This half answers my original question. My only issue now is that I have to download the file to a local store first, before I can stream it. I'd still like to find a way to stream from s3 without needing the temporary file.



aws.s3(s3Bucket).getFile(s3Path, function(err, result){
 result.pipe(fs.createWriteStream(file_location));
 result.on('end', function() {
 console.log('File Downloaded!');
 var proc = new ffmpeg(file_location)
 .outputOptions(['-movflags isml+frag_keyframe'])
 .toFormat('mp4')
 .withAudioCodec('copy')
 .seekInput(offset)
 .on('error', function(err,stdout,stderr) {
 console.log('an error happened: ' + err.message);
 console.log('ffmpeg stdout: ' + stdout);
 console.log('ffmpeg stderr: ' + stderr);
 })
 .on('end', function() {
 console.log('Processing finished !');
 })
 .on('progress', function(progress) {
 console.log('Processing: ' + progress.percent + '% done');
 })
 .pipe(res, {end: true});
 });
});




On the receiving side I just have the following javascript in an empty html page :



window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();

function process(Data) {
 source = context.createBufferSource(); // Create Sound Source
 context.decodeAudioData(Data, function(buffer){
 source.buffer = buffer;
 source.connect(context.destination);
 source.start(context.currentTime);
 });
};

function loadSound() {
 var request = new XMLHttpRequest();
 request.open("GET", "/stream/", true);
 request.responseType = "arraybuffer";

 request.onload = function() {
 var Data = request.response;
 process(Data);
 };

 request.send();
};

loadSound()




=====================================



The Answer



The code above under the title 'updated again' will stream an mp4 file, from s3, via a Node.js server to a browser without using flash. It does require that the file be stored temporarily on the Node.js server so that the meta data in the file is moved from the end of the file to the front. In order to stream without storing the temporary file, you need to actual modify the file on S3 first and make this meta data change. If you have changed the file in this way on S3 then you can modify the code under the title 'updated again' so that the result from S3 is piped straight into the ffmpeg constructor, rather than into a file stream on the Node.js server, then providing that file location to ffmepg, as the code does now. You can change the final 'pipe' command to 'save(location)' to get a version of the mp4 file locally with the meta data moved to the front. You can then upload that new version of the file to S3 and try out the end to end streaming. Personally I'm now going to create a task that modifies the files in this way as they are uploaded to s3 in the first place. This allows me to record and stream in mp4 without transcoding or storing a temp file on the Node.js server.


-
Is there a way to use ffmpeg binary on anroid platform in MAUI project ?
18 août 2023, par MrandCurrently I'm working on my test project about capabilities of MAUI and ffmpeg, so I can create my own applications. I got stuck on problem about using ffmpeg on platforms other than Windows (for example Anroid).


I tried googling the problem, didn't find anything helpful. Right now my ffmpeg for Android binary is situated inside
Platforms/Android/Assets/libs
as AndroidAsset. And I'm using code below to put my binary on Android to execute in the future

protected override void OnCreate(Bundle bundle)
{
 base.OnCreate(bundle);

 if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != Permission.Granted 
 || ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != Permission.Granted 
 || ContextCompat.CheckSelfPermission(this, Manifest.Permission.Internet) != Permission.Granted) 
 {
 ActivityCompat.RequestPermissions(this, new string[] {
 Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage, Manifest.Permission.Internet
 }, 0);
 }

 PrepareFFmpeg();
}

private void PrepareFFmpeg()
{
 var assetManager = Android.App.Application.Context.Assets;
 string path = "libs/ffmpeg";
 string destinationPath = Path.Combine(Android.App.Application.Context.ApplicationInfo.DataDir, "ffmpeg");

 var directoryPath = Path.GetDirectoryName(destinationPath);
 if (!Directory.Exists(directoryPath))
 {
 Directory.CreateDirectory(directoryPath);
 }

 using (var inputStream = assetManager.Open(path))
 {
 if (File.Exists(destinationPath)) 
 {
 File.Delete(destinationPath);
 }

 using (var outputStream = File.Create(destinationPath))
 {
 inputStream.CopyTo(outputStream);
 }
 }

 Java.Lang.JavaSystem.SetProperty("java.io.tmpdir", destinationPath);
 Java.Lang.Runtime.GetRuntime().Exec("chmod 700 " + destinationPath);

 FFmpeg.SetExecutablesPath(destinationPath);
}



public static class FFmpegService
{
 public static async Task ConvertVideoAsync(string inputPath, string outputPath, string format)
 {
 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
 {
 string ffmpegPath = GetFFmpegPath();
 string arguments = $"-i \"{inputPath}\" \"{outputPath}.{format}\"";

 ProcessStartInfo startInfo = new ProcessStartInfo
 {
 FileName = ffmpegPath,
 Arguments = arguments,
 RedirectStandardOutput = true,
 RedirectStandardError = true,
 UseShellExecute = false,
 CreateNoWindow = true,
 };

 using Process process = new Process { StartInfo = startInfo };
 process.Start();
 await process.WaitForExitAsync();
 }
 else
 {
 //IConversion conversion = await FFmpeg.Conversions.FromSnippet.Convert(inputPath, $"{outputPath}.{f*- .ormat}");
 //string command = $"-i {inputPath} -f {format} {outputPath}";

 //ProcessStartInfo psi = new ProcessStartInfo();
 //psi.FileName = FFmpeg.ExecutablesPath;
 //psi.Arguments = command;
 //psi.RedirectStandardOutput = true;
 //psi.RedirectStandardError = true;
 //psi.UseShellExecute = false;

 //Process process = Process.Start(psi);
 //process.WaitForExit();

 //string output = process.StandardOutput.ReadToEnd();
 //string error = process.StandardError.ReadToEnd();

 string outputPathWithFormat = $"{outputPath}.{format}";
 IConversion conversion = await FFmpeg.Conversions.FromSnippet.Convert(inputPath, outputPathWithFormat);
 IConversionResult result = await conversion.Start();
 }
 }

 private static string GetFFmpegPath()
 {
 //string platformFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows" : "Android";
 //return Path.Combine("Platforms", platformFolder, "ffmpeg", "ffmpeg");
 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
 {
 return Path.Combine("Platforms", "Windows", "ffmpeg", "ffmpeg");
 }
 else
 {
 return null;
 }
 }
}



I'm trying to use
FFmpegService
to convert video in any desired format I can by passing it in the arguments of the method (Windows works fine).

In my service I also tried to use
Xabe.FFmpeg
but it always givescouldn't find part of path (path here)
. When using more manual approach I face another problem every time :Permission denied
.
For path I tried/data/data/APPNAME
and cache directories. It always results in problems mentioned above.

I downloaded FFmpeg binary from this repository : https://github.com/tomaszzmuda/Xabe.FFmpeg/releases/tag/executables


My goal is to get conversion working for any format and for at least two platforms : Android and Windows, but if you can tell me how to do it on other platforms as well - I would be grateful.


Additional question : If you can tell me the best practice setting standard path for storing converted audio and video, thanks.


If you need more details, please specify I would happily provide them.
P.S. : don't look at the quality of code, I tried to code this for week so I didn't care about quality, I just want to learn how can I do this.


Thanks for your time and attention !


Project : Maui Blazor .Net 7.0


-
Anomalie #4128 : Bug de génération de boucle avec les modèles Spip
11 avril 2018, par Julien PORIAUSalut,
parfois le jeu de caractère "binaire" est visible uniquement dans le
code source (ligne 1233). Mais on observe tout de même un soucis dans la
mise en page.view-source:http://spip-dev.nidecker.com/probleme-de-langue.html?lang=ca
Julien.
Le 11.04.2018 à 14:28, redmine@spip.org a écrit :
La demande #4128 a été mise à jour par b b.
- Statut changé de /Nouveau/ à /En cours/
- Priorité changé de /Haut/ à /Bas/
Salut, peux-tu fournir le code du modèle en question ?
De mon côté, je n’ai aucun problème sur la page que tu cites en exemple...
Anomalie #4128 : Bug de génération de boucle avec les modèles Spip
<https://core.spip.net/issues/4128#change-13824>- Auteur : Julien PORIAU
- Statut : En cours
- Priorité : Bas
- Assigné à :
- Catégorie : code généré
- Version cible : 3.2
- Resolution :
- Navigateur : Firefox
Dans les modèles personnalisés Spip, les images (boucle documents ou
logos) sont mal générées et provoque un bug d’encodage visible dans le
front-end lors du passage dans une autre langue (balises multi).
Nous n’avons pas trouvé où était le souci dans Spip, mais les
caractères qui remontent dans le code source, ressemblent aux octets
qui composent le fichier binaire d’une image.
Voir en live ici :
http://spip-dev.nidecker.com/probleme-de-langue.html?lang=ca.Pour essayer d’isoler cette anomalie, nous avons procédé de la sorte
avec l’aide de mon développeur :1. Nous sommes reparti d’un SPIP 3.1.7 entièrement neuf (minimal),
avec deux modèles Spip, rien d’autre.
Le bug se reproduit, ce qui exclus un problème lié aux squelettes ou
autres plugins.Nous n’avons pas réussi a déterminer précisément ce qui génère ce bug,
à part que c’est dans un contexte où on appelle une langue pas définie
dans le multi.
En fonction du contenu de l’article, du nombre de modèles dans
l’article, en fonction des boucles dans les inclure, le bug n’arrive
pas au même endroit...Le problème vient de la génération des logos ou documents : si on
supprime les balises |#LOGO_*| ou si on renomme |IMG| en |IMG_|, plus
d’erreur.
Même sans traitements, avec juste |[(#LOGO_*)]|, rien à faire.2. Nous avons pensé que c’était peut être une image au mauvais format :
On a alors tenté de passer |ImageOptim| sur tout le répertoire |/IMG|,
redimensionné tous les logos en vignettes png de 320x240, rien à faire...3. On a fini par passer ce site de test en 3.2, pas mieux.
4. Nous avons épluché les caches générés dans |/tmp/cache| et
|/tmp/cache/skel|, tout paraît normal de ce côté là..5. On a ensuite un peu avancé en enlevant dans |mes_options.php| la
variable |$GLOBALS[’forcer_lang’] = true|".
Sur la version minimal, plus de bug. Mais sur le site de production,
le problème réside toujours.
Mais en faisant des tests avec et sans (et en supprimant bien
|/tmp/cache/| à chaque fois), ça se confirme pour la version minimal.6. A partir d’une copie de la version production, nous avons désactivé
tout les plugins, passer |ImageOptim| sur |/IMG| et rien a faire..
Impossible de déterminé d’où vient le problème :(7. Nous avons essayé d’écrire comme ceci : |[
src="(#LOGO_MOT|image_reduire50,*|extraire_attributsrc)" alt="">]|
Cela fonctionne sur la version minimal mais pas sur la version production.8. Dans la version minimal, j’ai encore récemment testé une dernière
chose. J’ai supprimé les documents non sollicités sur ma page de teste
(spip.php ?article1441&lang=ca).
Avec la requête SQL suivante : |DELETE FROM jones_documents WHERE
id_document NOT IN
(1948,1949,2534,2535,630,631,1783,1784,1785,1786,1787,1788,1781,1782)|
Le bug n’apparait plus..Je sèche..
Vous trouverez ici en téléchargement une archive de la version minimal
(Spip 3.1.7) :
https://www.dropbox.com/s/dek0zg7jafl8uxe/jones.zip?dl=0] ( 20mo)
Pour reproduire le bug, il suffit de passer la variable "&lang=ca"
dans l’article 1441 (localhost/spip.php ?article1441&lang=ca).Je donne volontiers un accès à la version production si besoin.
Vous recevez ce mail car vous êtes impliqués sur ce projet.
Pour changer les préférences d’envoi de mail, allez sur
http://core.spip.org/my/account---
L’absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus