
Recherche avancée
Autres articles (111)
-
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs
12 avril 2011, parLa manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras. -
Automated installation script of MediaSPIP
25 avril 2011, parTo overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
The documentation of the use of this installation script is available here.
The code of this (...)
Sur d’autres sites (6566)
-
What determine number of cpu core usage of filter select=gt(scene,0.1) ?
15 décembre 2022, par kocoten1992I've notice that when using filter gt(scene,0.1), for example :


ffmpeg -i big_buck_bunny.mkv -filter:v "select='gt(scene,0.1)',showinfo" -f null -


Depends on the video, number of cpu cores usage varies extremely (sometimes it 3 cores usage - other time 12 cores usage in different video).


Would like to ask what determine that logic ?


I try to read ffmpeg source code but not familiar with it, a general explanation would be enough, but much appreciate if you point out the line/directory determine that logic in https://github.com/FFmpeg/FFmpeg.


(Also not asking how to reduce cpu usage, interested in the logic determine that).


-
Detect volume via mic, start recording, end on silence, transcribe and sent to endpoint
15 juin 2023, par alphadmonI have been attempting to get this to work in many ways but I can't seem to get it right. Most of the time I get a part of it to work and then when I try to make other parts work, I generally break other things.


I am intercepting the volume coming from the mic and if it is louder than 50, I start a recording. I then keep recording until there is a silence, if the silence is equal to 5 seconds I then stop the recording.


I then send the recording to be transcribed by
whisper
using OpenAI API.

Once that is returned, I then want to send it to the open ai chat end point and get the response.


After that, I would like to start listening again.


Here is what I have that is sort of working so far, but the recording is an empty file always :


// DETECT SPEECH
const recorder = require('node-record-lpcm16');

// TRANSCRIBE
const fs = require("fs");
const ffmpeg = require("fluent-ffmpeg");
const mic = require("mic");
const { Readable } = require("stream");
const ffmpegPath = require("@ffmpeg-installer/ffmpeg").path;
require('dotenv').config();

// CHAT
const { Configuration, OpenAIApi } = require("openai");

// OPEN AI
const configuration = new Configuration({
 organization: process.env.OPENAI_ORG,
 apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

// SETUP
ffmpeg.setFfmpegPath(ffmpegPath);

// VARS
let isRecording = false;
const audioFilename = 'recorded_audio.wav';
const micInstance = mic({
 rate: '16000',
 channels: '1',
 fileType: 'wav',
});

// DETECT SPEECH
const file = fs.createWriteStream('determine_speech.wav', { encoding: 'binary' });
const recording = recorder.record();
recording.stream().pipe(file);


recording.stream().on('data', async (data) => {
 let volume = parseInt(calculateVolume(data));
 if (volume > 50 && !isRecording) {
 console.log('You are talking.');
 await recordAudio(audioFilename);
 } else {
 setTimeout(async () => {
 console.log('You are quiet.');
 micInstance.stop();
 console.log('Finished recording');
 const transcription = await transcribeAudio(audioFilename);
 console.log('Transcription:', transcription);
 setTimeout(async () => {
 await askAI(transcription);
 }, 5000);
 }, 5000);
 }
});

function calculateVolume(data) {
 let sum = 0;

 for (let i = 0; i < data.length; i += 2) {
 const sample = data.readInt16LE(i);
 sum += sample * sample;
 }

 const rms = Math.sqrt(sum / (data.length / 2));

 return rms;
}

// TRANSCRIBE
function recordAudio(filename) {
 const micInputStream = micInstance.getAudioStream();
 const output = fs.createWriteStream(filename);
 const writable = new Readable().wrap(micInputStream);

 console.log('Listening...');

 writable.pipe(output);

 micInstance.start();

 micInputStream.on('error', (err) => {
 console.error(err);
 });
}

// Transcribe audio
async function transcribeAudio(filename) {
 const transcript = await openai.createTranscription(
 fs.createReadStream(filename),
 "whisper-1",
 );
 return transcript.data.text;
}

// CHAT
async function askAI(text) {
 let completion = await openai.createChatCompletion({
 model: "gpt-4",
 temperature: 0.2,
 stream: false,
 messages: [
 { role: "user", content: text },
 { role: "system", content: "Act like you are a rude person." }
 ],
 });

 completion = JSON.stringify(completion.data, null, 2);
 console.log(completion);
}



-
select a screen section ffmpeg c++ on macos
21 avril 2022, par C1ngh10I am trying to record the screen on macos, with ffmpeg. I would like to be able to select a section of the screen instead of the whole desktop. I tried to set several options such as
vf
, with values like"crop=150:150:0:0"
, orvideo_size
with value"150x150"
. The result was that the output video had the correct dimensions (150x150) but whole screen has been recorded instead of the specified section. Does anybody know another way to do that ?

int ScreenRecorder::openVideoDevice() {
 value = 0;
 videoOptions = nullptr;
 pAVFormatContext = nullptr;

 pAVFormatContext = avformat_alloc_context();


 string dimension = to_string(width) + "x" + to_string(height);
 av_dict_set(&videoOptions, "video_size", dimension.c_str(), 0); //option to set the dimension of the screen section to record
 value = av_dict_set(&videoOptions, "framerate", "25", 0);
 if (value < 0) {
 cerr << "Error in setting dictionary value (setting framerate)" << endl;
 exit(-1);
 }

 value = av_dict_set(&videoOptions, "preset", "ultrafast", 0);
 if (value < 0) {
 cerr << "Error in setting dictionary value (setting preset value)" << endl;
 exit(-1);
 }

 //The distance from the left edge of the screen or desktop
 value = av_dict_set(&videoOptions, "vf", ("crop=" + to_string(width) + ":" + to_string(height) + ":" + to_string(x_offset) + ":" +
 to_string(y_offset)).c_str(), 0);

 if (value < 0) {
 cerr << "Error in setting crop" << endl;
 exit(-1);
 }

 value = av_dict_set(&videoOptions, "pixel_format", "yuv420p", 0);
 if (value < 0) {
 cerr << "Error in setting pixel format" << endl;
 exit(-1);
 }
 
 pAVInputFormat = av_find_input_format("avfoundation");

 if (avformat_open_input(&pAVFormatContext, "1:none", pAVInputFormat, &videoOptions) != 0) {
 cerr << "Error in opening input device" << endl;
 exit(-1);
 }
 //get video stream infos from context
 value = avformat_find_stream_info(pAVFormatContext, nullptr);
 if (value < 0) {
 cerr << "Error in retrieving the stream info" << endl;
 exit(-1);
 }

 VideoStreamIndx = -1;
 for (int i = 0; i < pAVFormatContext->nb_streams; i++) {
 if (pAVFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 VideoStreamIndx = i;
 break;
 }
 }
 if (VideoStreamIndx == -1) {
 cerr << "Error: unable to find video stream index" << endl;
 exit(-2);
 }

 pAVCodecContext = pAVFormatContext->streams[VideoStreamIndx]->codec;
 pAVCodec = avcodec_find_decoder(pAVCodecContext->codec_id/*params->codec_id*/);
 if (pAVCodec == nullptr) {
 cerr << "Error: unable to find decoder video" << endl;
 exit(-1);
 }

 return 0;
}