
Recherche avancée
Médias (1)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (60)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
(Dés)Activation de fonctionnalités (plugins)
18 février 2011, parPour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)
Sur d’autres sites (11487)
-
ffmpeg app using node occasionally crashes as file doesn't appear to be read correctly
31 mai 2022, par ZabsI have an simple Node application that allows me to pass an AWS S3 URL link to a file (in this case video files). It uses the FFMPEG library to read the video file and return data like codecs, duration, bitrate etc..


The script is called from PHP script which in turn send the data to the Node endpoint and passes the Amazon S3 URL to node. Sometimes for no obvious reasons the video file fails to return the expected values regarding container, codec, duration etc... and just returns '0'. But when I try the exact same file/request again it returns this data correctly e.g
container:mp4


I'm not sure but I think the script somehow needs the
createWriteStream
to be closed but I cannot be sure, the problem is the issue I have found doesn't happen all the time but sporadically so its hard to get to the issue when its difficult to replicate it.

Any ideas ?


router.post('/', async function(req, res) {
 const fileURL = new URL(req.body.file);
 var path = fileURL.pathname;
 path = 'tmp/'+path.substring(1); // removes the initial / from the path

 let file = fs.createWriteStream(path); // create the file locally
 const request = https.get(fileURL, function(response) {
 response.pipe(file);
 });
 
 // after file has saved
 file.on('finish', function () {
 var process = new ffmpeg(path);
 process.then(function (video) {
 let metadata = formatMetadata(video.metadata);

 res.send ({
 status: '200',
 data: metadata,
 errors: errors,
 response: 'success'
 });

 }, function (err) {
 console.warn('Error: ' + err);

 res.send ({
 status: '400',
 data: 'Something went wrong processing this video',
 response: 'fail',
 });
 });
 });

 file.on('error', function (err) {
 console.warn(err);
 });

});

function formatMetadata(metadata) {
 const data = {
 'video' : metadata.video,
 'audio' : metadata.audio,
 'duration' : metadata.duration
 };
 return data;
}



// Expected output


{"data":{"video":{"container":"mov","bitrate":400,"stream":0,"codec":"h264","resolution":{"w":1280,"h":720},"resolutionSquare":{"w":1280,"h":720},"aspect":{"x":16,"y":9,"string":"16:9","value":1.7777777777777777},"rotate":0,"fps":25,"pixelString":"1:1","pixel":1},"audio":{"codec":"aac","bitrate":"127","sample_rate":44100,"stream":0,"channels":{"raw":"stereo","value":2}},"duration":{"raw":"00:00:25.68","seconds":25}}



// Actual output


{"data":{"video":{"container":"","bitrate":0,"stream":0,"codec":"","resolution":{"w":0,"h":0},"resolutionSquare":{"w":0,"h":null},"aspect":{},"rotate":0,"fps":0,"pixelString":"","pixel":0},"audio":{"codec":"","bitrate":"","sample_rate":0,"stream":0,"channels":{"raw":"","value":""}},"duration":{"raw":"","seconds":0}}



Note - this happens sporadically


-
node.js ffmpeg pass directly to aws s3 bucket
30 décembre 2022, par Eivydas VickusHow to pass ffmpeg output directly to aws s3 bucket ? It should not store output file on my pc. This is my code.



 import {
 DeleteObjectCommand,
 GetObjectCommand,
 PutObjectCommand,
 PutObjectCommandInput,
 S3,
 S3Client,
 } from '@aws-sdk/client-s3';
 import { Inject, Injectable } from '@nestjs/common';
 import { ConfigType } from '@nestjs/config';
 import { nanoid } from 'nanoid';
 import awsConfig from './aws.config';
 import * as path from 'path';
 import { VideoInterface } from '../video/video.interface';
 import { PassThrough } from 'node:stream';

 @Injectable()
 export class S3BucketService {
 public readonly client = new S3Client({
 region: this.config.AWS_BUCKET_REGION,
 credentials: {
 accessKeyId: this.config.AWS_ACCESS_KEY,
 secretAccessKey: this.config.AWS_SECRET_KEY,
 },
 });
 constructor(
 @Inject(awsConfig.KEY)
 private readonly config: ConfigType<typeof awsconfig="awsconfig">,
 ) {}

 async videoPut(putObjectInput: Omit) {
 return new PutObjectCommand({
 ...putObjectInput,
 Bucket: this.config.AWS_BUCKET_NAME,
 });
 }

 async uploadFile({ fileName, file, folder }: VideoInterface) {
 const fullPath = path.normalize(`${folder}/${fileName}`);
 return await this.client.send(
 await this.videoPut({
 Key: fullPath,
 Body: file,
 }),
 );
 }
 }
</typeof>



 const passthroughs = new PassThrough();
 await new Promise<void>(async (resolve, reject) => {
 ffmpeg(fs.createReadStream(file.path))
 .format('webm')
 .outputOptions([
 `-vf scale=${videoOptions[2].scale}`,
 `-b:v ${videoOptions[2].avgBitRate}`,
 `-minrate ${videoOptions[2].minBitRate}`,
 `-maxrate ${videoOptions[2].maxBitRate}`,
 `-tile-columns ${videoOptions[2].tileColumns}`,
 `-g ${videoOptions[2].g}`,
 `-threads ${videoOptions[2].threads}`,
 `-quality ${videoOptions[2].quality}`,
 `-crf ${videoOptions[2].crf}`,
 `-c:v ${videoOptions[2].videoCodec}`,
 `-c:a ${videoOptions[2].audioCodec}`,
 `-speed ${videoOptions[2].speed}`,
 `-y`,
 ])
 .pipe(passthroughs, { end: true })
 .on('error', (err) => {
 reject(err);
 throw new InternalServerErrorException(err);
 })
 .on('data', (data) => {
 console.log({ data });
 })
 .on('end', async () => {
 console.log('Video conversion complete');
 resolve();
 });
 });

 await this.s3BucketService.uploadFile({
 folder: AwsFolder.VIDEOS,
 file: passthroughs,
 fileName: `${nanoid()}_${videoOptions[2].scale}.webm`,
 });

</void>


However i am getting error
Error: Output stream closed
. I saw on google different variants withPassthrough
none of them are working. So how it should be done ? By The Way I am using@aws-sdk/client-s3
and most solutions on google is using aws sdk-2. Maybe streams work different with version 3 ?

-
Title : Getting "invalid_request_error" when trying to pass converted audio file to OpenAI API
19 avril 2023, par Dummy CronI am working on a project where I receive a URL from a webhook on my server whenever users share a voice note on my WhatsApp. I am using WATI as my WhatsApp API Provder


The file URL received is in the .opus format, which I need to convert to WAV and pass to the OpenAI Whisper API translation task.


I am trying convert it to .wav using ffmpeg, and pass it to the OpenAI API for translation processing.
However, I am getting an "invalid_request_error"


import requests
import io
import subprocess
file_url = #.opus file url
api_key = #WATI API Keu

def transcribe_audio_to_text():
 # Fetch the audio file and convert to wav format

 headers = {'Authorization': f'Bearer {api_key}'}
 response = requests.get(file_url, headers=headers)
 audio_bytes = io.BytesIO(response.content)

 process = subprocess.Popen(['ffmpeg', '-i', '-', '-f', 'wav', '-acodec', 'libmp3lame', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
 wav_audio, _ = process.communicate(input=audio_bytes.read())

 # Set the Whisper API endpoint and headers
 WHISPER_API_ENDPOINT = 'https://api.openai.com/v1/audio/translations'
 whisper_api_headers = {'Authorization': 'Bearer ' + WHISPER_API_KEY,
 'Content-Type': 'application/json'}
 print(whisper_api_headers)
 # Send the audio file for transcription

 payload = {'model': 'whisper-1'}
 files = {'file': ('audio.wav', io.BytesIO(wav_audio), 'audio/wav')}

 # files = {'file': ('audio.wav', io.BytesIO(wav_audio), 'application/octet-stream')}

 # files = {'file': ('audio.mp3', io.BytesIO(mp3_audio), 'audio/mp3')}
 response = requests.post(WHISPER_API_ENDPOINT, headers=whisper_api_headers, data=payload)
 print(response)
 # Get the transcription text
 if response.status_code == 200:
 result = response.json()
 text = result['text']
 print(response, text)
 else:
 print('Error:', response)
 err = response.json()
 print(response.status_code)
 print(err)
 print(response.headers)

transcribe_audio_to_text()



Output :


Error: <response>
400
{'error': {'message': "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to support@openai.com and include any relevant code you'd like help with.)", 'type': 'invalid_request_error', 'param': None, 'code': None}}
</response>