
Recherche avancée
Médias (91)
-
Spitfire Parade - Crisis
15 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Wired NextMusic
14 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
-
Sintel MP4 Surround 5.1 Full
13 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (20)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
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 (...) -
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 (...)
Sur d’autres sites (5633)
-
Trying to decode and encode audio files with the FFMPEG C API
1er février 2023, par Giulio IacominoMy ultimate goal will be to split multi channel WAV files into single mono ones, after few days of experiments my plan is the sequence :


- 

- Decode audio file into a frame.
- Convert interleaved frame into a planar one. (in order to separate the data buffer into multiple ones)
- Grab the planar frame buffers and encode each of them into a new file.








So far I'm stuck trying to convert a wav file from interleaved to a planar one, and reprint the wav file.


edit :
I've turned on guard malloc and apparently the error is within the convert function


Here's the code :


AVCodecContext* initializeAndOpenCodecContext(AVFormatContext* formatContext, AVStream* stream){
 // grab our stream, most audio files only have one anyway
 const AVCodec* decoder = avcodec_find_decoder(stream->codecpar->codec_id);
 if (!decoder){
 std::cout << "no decoder, can't go ahead!\n";
 return nullptr;
 }
 AVCodecContext* codecContext = avcodec_alloc_context3(decoder);
 avcodec_parameters_to_context(codecContext, stream->codecpar);
 int err = avcodec_open2(codecContext, decoder, nullptr);
 if (err < 0){
 std::cout << "couldn't open codex!\n";
 }
 return codecContext;
}

void initialiseResampler(SwrContext* resampler, AVFrame* inputFrame, AVFrame* outputFrame){
 av_opt_set_chlayout(resampler, "in_channel_layout", &inputFrame->ch_layout, 0);
 av_opt_set_chlayout(resampler, "out_channel_layout", &outputFrame->ch_layout, 0);
 av_opt_set_int(resampler, "in_sample_fmt", inputFrame->format, 0);
 av_opt_set_int(resampler, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
 av_opt_set_int(resampler, "in_sample_rate", inputFrame->sample_rate, 0);
 av_opt_set_int(resampler, "out_sample_rate", outputFrame->sample_rate, 0);
}

AVFrame* initialisePlanarFrame(AVFrame* frameToInit, AVFrame* inputFrame){
 //AVFrame *planar_frame = av_frame_alloc();
 frameToInit->nb_samples = inputFrame->nb_samples;
 frameToInit->ch_layout = inputFrame->ch_layout;
 frameToInit->format = AV_SAMPLE_FMT_FLTP;
 frameToInit->sample_rate = inputFrame->sample_rate;
 return nullptr;
}

int main() {
 AVCodecContext *codingContext= NULL;
 const AVCodec *codec;
 codec = avcodec_find_encoder(AV_CODEC_ID_PCM_F32LE);
 codingContext = avcodec_alloc_context3(codec);
 codingContext->bit_rate = 16000;
 codingContext->sample_fmt = AV_SAMPLE_FMT_FLT;
 codingContext->sample_rate = 48000;
 codingContext->ch_layout.nb_channels = 2;
 codingContext->ch_layout.order = (AVChannelOrder)0;
 uint8_t **buffer_ = NULL;
 AVFrame* planar_frame = NULL;
 
 // open input
 AVFormatContext* formatContext = nullptr;
 int err = avformat_open_input(&formatContext, "/Users/tonytorm/Desktop/drum kits/DECAP - Drums That Knock Vol. 9/Kicks/Brash Full Metal Kick.wav", nullptr, nullptr);
 if (err < 0){
 fprintf(stderr, "Unable to open file!\n");
 return;
 }

 // find audio stream
 err = avformat_find_stream_info(formatContext, nullptr);
 if (err > 0){
 fprintf(stderr, "Unable to retrieve stream info!\n");
 return;
 }
 
 int index = av_find_best_stream(formatContext, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0);
 if (index < 0){
 std::cout<< "coudn't find audio stream in this file" << '\n';
 }
 AVStream* stream = formatContext->streams[index];
 
 auto fileName = "/Users/tonytorm/Desktop/newFile.wav";
 FILE* newFile = fopen(fileName, "w+");
 
 // find right codec and open it
 if (auto openCodecContext = initializeAndOpenCodecContext(formatContext, stream)){
 AVPacket* packet = av_packet_alloc();
 AVFrame* frame = av_frame_alloc();
 AVFrame* planar_frame = av_frame_alloc();
 SwrContext *avr = swr_alloc(); //audio resampling context
 AVChannelLayout monoChannelLayout{(AVChannelOrder)0};
 monoChannelLayout.nb_channels = 2;
 

 while (!av_read_frame(formatContext, packet)){
 if (packet->stream_index != stream->index) continue; // we only care about audio
 int ret = avcodec_send_packet(openCodecContext, packet);
 if ( ret < 0) {
 if (ret != AVERROR(EAGAIN)){ // if error is actual error not EAGAIN
 std::cout << "can't do shit\n";
 return;
 }
 }
 while (int bret = avcodec_receive_frame(openCodecContext, frame) == 0){
 initialisePlanarFrame(planar_frame, frame);
 
 
 
 int buffer_size_in = av_samples_get_buffer_size(nullptr,
 frame->ch_layout.nb_channels,
 frame->nb_samples,
 (AVSampleFormat)frame->format,
 0);
 int buffer_size_out = buffer_size_in/frame->ch_layout.nb_channels;

 //planar_frame->linesize[0] = buffer_size_out;
 
 int ret = av_samples_alloc(planar_frame->data,
 NULL,
 planar_frame->ch_layout.nb_channels,
 planar_frame->nb_samples,
 AV_SAMPLE_FMT_FLTP,
 0);
 
 initialiseResampler(avr, frame, planar_frame);
 if (int errRet = swr_init(avr) < 0) {
 fprintf(stderr, "Failed to initialize the resampling context\n");
 }

 if (ret < 0){
 char error_message[AV_ERROR_MAX_STRING_SIZE];
 av_strerror(ret, error_message, AV_ERROR_MAX_STRING_SIZE);
 fprintf(stderr, "Error allocating sample buffer: %s\n", error_message);
 return -1;
 }
 
 int samples_converted = swr_convert(avr,
 planar_frame->data,
 buffer_size_out,
 (const uint8_t **)frame->data,
 buffer_size_in);
 if (samples_converted < 0) {
 // handle error
 std::cout << "error in conversion\n";
 return;
 }
 if (avcodec_open2(codingContext, codec, NULL) < 0) {
 std::cout << "can't encode!\n";
 return;
 }
 AVPacket* nu_packet = av_packet_alloc();
 while (int copy = avcodec_send_frame(codingContext, planar_frame) != 0){
 if (copy == AVERROR(EAGAIN) || copy == AVERROR_EOF){
 std::cout << "can't encode file\n";
 return;
 }
 if (avcodec_receive_packet(codingContext, nu_packet) >=0){
 fwrite(nu_packet->data, 4, nu_packet->size, newFile);
 //av_write_frame(avc, nu_packet);
 }
 }
 av_freep(planar_frame->data);
 av_frame_unref(frame);
 av_frame_unref(planar_frame);
 }
// av_packet_free(&packet);
// av_packet_free(&nu_packet);
 }
 swr_free(&avr);
 avcodec_free_context(&codingContext);
 
 }
 fclose(newFile);
}



I know i should write a header to the new wave file but for now I'm just trying to write the raw audio data. I'm getting always the same error but in different parts of the code (randomly), sometimes the code even compiles (writing the raw audio data, but filling it with some rubbish as well, i end up with a data file that is thrice the original one, sometimes i end up with a slightly smaller file - i guess the raw audio without the headers), results are basically random.


Here are some of the functions that trigger the error :


int ret = av_samples_alloc(); //(this the most common one)
swr_convert()
av_freep();



the error is :


main(64155,0x101b5d5c0) malloc: Incorrect checksum for freed object 0x106802600: probably modified after being freed.
Corrupt value: 0x0
main(64155,0x101b5d5c0) malloc: *** set a breakpoint in malloc_error_break to debug */



-
Error : Cannot find ffmpeg in firebase cloud function
6 novembre 2024, par Ahmed Wagdii'm trying to compress some uploaded files to firebase storage .. using firebase cloud functions but it give me the error
Error: Cannot find ffmpeg


here is my function :


const functions = require("firebase-functions");
const admin = require("firebase-admin");
const ffmpeg = require("fluent-ffmpeg");
const ffmpegStatic = require("ffmpeg-static");
const axios = require("axios");

// const {onSchedule} = require("firebase-functions/v2/scheduler");

admin.initializeApp();

// Ensure fluent-ffmpeg uses the binary
ffmpeg.setFfmpegPath(ffmpegStatic.path);

const db = admin.firestore();
const bucket = admin.storage().bucket();
const fs = require("fs");
const downloadVideo = async (url, outputPath) => {
 const response = await axios.get(url, {responseType: "stream"});
 const writer = fs.createWriteStream(outputPath);
 response.data.pipe(writer);
 return new Promise((resolve, reject) => {
 writer.on("finish", () => resolve(outputPath));
 writer.on("error", reject);
 });
};

const compressVideo = (videoFullPath, outputFileName, targetSize) => {
 return new Promise((resolve, reject) => {
 ffmpeg.ffprobe(videoFullPath, (err, metadata) => {
 if (err) return reject(err);
 const duration = parseFloat(metadata.format.duration);
 const targetTotalBitrate =
 (targetSize * 1024 * 8) / (1.073741824 * duration);

 let audioBitrate =
 metadata.streams.find((s) => s.codec_type === "audio").bit_rate;
 if (10 * audioBitrate > targetTotalBitrate) {
 audioBitrate = targetTotalBitrate / 10;
 }

 const videoBitrate = targetTotalBitrate - audioBitrate;
 ffmpeg(videoFullPath)
 .output(outputFileName)
 .videoCodec("libx264")
 .audioCodec("aac")
 .videoBitrate(videoBitrate)
 .audioBitrate(audioBitrate)
 .on("end", resolve)
 .on("error", reject)
 .run();
 });
 });
};

const uploadVideoWithResumableUpload = (filePath, destinationBlobName) => {
 const blob = bucket.file(destinationBlobName);
 const options = {resumable: true, validation: "crc32c"};
 return blob.createWriteStream(options).end(fs.readFileSync(filePath));
};

exports.processLessonsOnDemand =
functions.https.onRequest({timeoutSeconds: 3600, memory: "2GB"}
 , async (context) => {
 console.log("Fetching lessons from Firestore...");
 const lessonsRef = db.collection("leassons");
 const lessonsSnapshot = await lessonsRef.get();

 if (lessonsSnapshot.empty) {
 console.log("No lessons found in Firestore.");
 return; // Exit if no lessons are available
 }

 const lessonDoc = lessonsSnapshot.docs[0]; // Get the first document
 const lessonData = lessonDoc.data();

 if (lessonData.shrinked) {
 console.log(
 `Skipping lesson ID ${lessonDoc.id} as it's already shrunk.`,
 );
 return; // Exit if the first lesson is already shrunk
 }

 const videoURL = lessonData.videoURL;
 if (!videoURL) {
 console.log(
 `No video URL for lesson ID: ${lessonDoc.id}. Skipping...`,
 );
 return; // Exit if no video URL is available
 }

 const tempVideoPath = "/tmp/temp_video.mp4";

 try {
 await downloadVideo(videoURL, tempVideoPath);

 const targetSize = (fs.statSync(tempVideoPath).size * 0.30) / 1024;
 const outputCompressedVideo = `/tmp/compressed_${lessonDoc.id}.mp4`;

 await compressVideo(tempVideoPath, outputCompressedVideo, targetSize);

 await uploadVideoWithResumableUpload(
 outputCompressedVideo,
 `compressed_videos/compressed_${lessonDoc.id}.mp4`,
 );

 const newVideoURL = `https://storage.googleapis.com/${bucket.name}/compressed_videos/compressed_${lessonDoc.id}.mp4`;

 const oldVideoPath = videoURL.replace(`https://storage.googleapis.com/${bucket.name}/`, "");
 const oldBlob = bucket.file(oldVideoPath);
 await oldBlob.delete();

 await lessonsRef.doc(lessonDoc.id).update({
 videoURL: newVideoURL,
 shrinked: true,
 });

 console.log(`Processed lesson ID: ${lessonDoc.id}`);
 fs.unlinkSync(tempVideoPath); // Clean up temporary files
 fs.unlinkSync(outputCompressedVideo); // Clean up compressed file
 } catch (error) {
 console.error(`Error processing lesson ID ${lessonDoc.id}:`, error);
 }
 });





-
Help us Reset The Net today on June 5th
This blog post explains why the Piwik project is joining ResetTheNet online protest and how you can help make a difference against mass surveillance. It also includes an infographic and links to useful resources which may be of interest to you.
Snowden revelations, a year ago today
On June 5, 2013 the Guardian newspaper published the first of Edward Snowden’s astounding revelations. It was the first of a continuous stream of stories that pointed out what we’ve suspected for a long time : that the world’s digital communications are being continuously spied upon by nation states with precious little oversight.
Unfortunately, mass surveillance is affecting the internet heavily. The Internet is a powerful force that can promote democracy, innovation, and creativity, but it’s being subverted as a tool for government spying. That is why Piwik has decided to join Reset The Net.
June 5, 2014 marks a new year : a year that will not just be about listening to the inside story of mass surveillance, but a new year of fighting back !
How do I protect myself and others ?
Reset the Net is asking everyone to help by installing free software tools that are designed to protect your privacy on a computer or a mobile device.
Reset the Net is also calling on websites and developers to add surveillance resistant features such as HTTPS and forward secrecy.
Participate in ResetTheNet online protest
Have you got your own website, blog or tumblr ? Maybe you can show the Internet Defense League’s “Cat Signal !” on your website.Get the code now to run the Reset the Net splash screen or banner to help make privacy viral on June 5th.
Message from Edward Snowden
Evan from FFTF sent us this message from Edward Snowden and we thought we would share it with you :
One year ago, we learned that the internet is under surveillance, and our activities are being monitored to create permanent records of our private lives — no matter how innocent or ordinary those lives might be.
Today, we can begin the work of effectively shutting down the collection of our online communications, even if the US Congress fails to do the same. That’s why I’m asking you to join me on June 5th for Reset the Net, when people and companies all over the world will come together to implement the technological solutions that can put an end to the mass surveillance programs of any government. This is the beginning of a moment where we the people begin to protect our universal human rights with the laws of nature rather than the laws of nations.
We have the technology, and adopting encryption is the first effective step that everyone can take to end mass surveillance. That’s why I am excited for Reset the Net — it will mark the moment when we turn political expression into practical action, and protect ourselves on a large scale.
Join us on June 5th, and don’t ask for your privacy. Take it back.
– Message by Edward Snowden
ResetTheNet privacy pack infographic
Additional Resources
Configure Piwik for Security and Privacy
- Turn on automatic SSL redirection in your Piwik.
- Configure Piwik for advanced Privacy.
- Best security practises for Piwik.
More info
- Learn why this matters (EFF)
- Data Privacy Day – Why is privacy important ? (Piwik)
- Web Analytics Privacy (Piwik)