Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Sur d’autres sites (333)
-
What permission ffmpeg-static need in AWS Lambda ?
17 février 2023, par JánosI have this code. It download a image, made a video from it and upload it to S3. It runs on Lambda. Added packages, intalled, zipped, uploaded.


npm install --production
zip -r my-lambda-function.zip ./



But get an
error code 126


2023-02-17T09:27:55.236Z 5c845bb6-02c1-41b0-8759-4459591b57b0 INFO Error: ffmpeg exited with code 126
 at ChildProcess.<anonymous> (/var/task/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
 at ChildProcess.emit (node:events:513:28)
 at ChildProcess._handle.onexit (node:internal/child_process:291:12)
2023-02-17T09:27:55.236Z 5c845bb6-02c1-41b0-8759-4459591b57b0 INFO Error: ffmpeg exited with code 126 at ChildProcess.<anonymous> (/var/task/node_modules/fluent-ffmpeg/lib/processor.js:182:22) at ChildProcess.emit (node:events:513:28) at ChildProcess._handle.onexit (node:internal/child_process:291:12)
</anonymous></anonymous>


Do I need to set a specific premission for ffmpeg ?


import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { fromNodeProviderChain } from '@aws-sdk/credential-providers'
import axios from 'axios'
import pathToFfmpeg from 'ffmpeg-static'
import ffmpeg from 'fluent-ffmpeg'
import fs from 'fs'
ffmpeg.setFfmpegPath(pathToFfmpeg)
const credentials = fromNodeProviderChain({
 clientConfig: {
 region: 'eu-central-1',
 },
})
const client = new S3Client({ credentials })

export const handler = async (event, context) => {
 try {
 let body
 let statusCode = 200
 const query = event?.queryStringParameters
 if (!query?.imgId && !query?.video1Id && !query?.video2Id) {
 return
 }

 const imgId = query?.imgId
 const video1Id = query?.video1Id
 const video2Id = query?.video2Id
 console.log(
 `Parameters received, imgId: ${imgId}, video1Id: ${video1Id}, video2Id: ${video2Id}`
 )
 const imgURL = getFileURL(imgId)
 const video1URL = getFileURL(`${video1Id}.mp4`)
 const video2URL = getFileURL(`${video2Id}.mp4`)
 const imagePath = `/tmp/${imgId}`
 const video1Path = `/tmp/${video1Id}.mp4`
 const video2Path = `/tmp/${video2Id}.mp4`
 const outputPath = `/tmp/${imgId}.mp4`
 await Promise.all([
 downloadFile(imgURL, imagePath),
 downloadFile(video1URL, video1Path),
 downloadFile(video2URL, video2Path),
 ])
 await new Promise((resolve, reject) => {
 console.log('Input files downloaded')
 ffmpeg()
 .input(imagePath)
 .inputFormat('image2')
 .inputFPS(30)
 .loop(1)
 .size('1080x1080')
 .videoCodec('libx264')
 .format('mp4')
 .outputOptions([
 '-tune animation',
 '-pix_fmt yuv420p',
 '-profile:v baseline',
 '-level 3.0',
 '-preset medium',
 '-crf 23',
 '-movflags +faststart',
 '-y',
 ])
 .output(outputPath)
 .on('end', () => {
 console.log('Output file generated')
 resolve()
 })
 .on('error', (e) => {
 console.log(e)
 reject()
 })
 .run()
 
 })
 await uploadFile(outputPath, imgId + '.mp4')
 .then((url) => {
 body = JSON.stringify({
 url,
 })
 })
 .catch((error) => {
 console.error(error)
 statusCode = 400
 body = error?.message ?? error
 })
 console.log(`File uploaded to S3`)
 const headers = {
 'Content-Type': 'application/json',
 'Access-Control-Allow-Headers': 'Content-Type',
 'Access-Control-Allow-Origin': 'https://tikex.com, https://borespiac.hu',
 'Access-Control-Allow-Methods': 'GET',
 }
 return {
 statusCode,
 body,
 headers,
 }
 } catch (error) {
 console.error(error)
 return {
 statusCode: 500,
 body: JSON.stringify('Error fetching data'),
 }
 }
}

const downloadFile = async (url, path) => {
 try {
 console.log(`Download will start: ${url}`)
 const response = await axios(url, {
 responseType: 'stream',
 })
 if (response.status !== 200) {
 throw new Error(
 `Failed to download file, status code: ${response.status}`
 )
 }
 response.data
 .pipe(fs.createWriteStream(path))
 .on('finish', () => console.log(`File downloaded to ${path}`))
 .on('error', (e) => {
 throw new Error(`Failed to save file: ${e}`)
 })
 } catch (e) {
 console.error(`Error downloading file: ${e}`)
 }
}
const uploadFile = async (path, id) => {
 const buffer = fs.readFileSync(path)
 const params = {
 Bucket: 't44-post-cover',
 ACL: 'public-read',
 Key: id,
 ContentType: 'video/mp4',
 Body: buffer,
 }
 await client.send(new PutObjectCommand(params))
 return getFileURL(id)
}
const getFileURL = (id) => {
 const bucket = 't44-post-cover'
 const url = `https://${bucket}.s3.eu-central-1.amazonaws.com/${id}`
 return url
}



Added
AWSLambdaBasicExecutionRole-16e770c8-05fa-4c42-9819-12c468cb5b49
permission, with policy :

{
 "Version": "2012-10-17",
 "Statement": [
 {
 "Effect": "Allow",
 "Action": "logs:CreateLogGroup",
 "Resource": "arn:aws:logs:eu-central-1:634617701827:*"
 },
 {
 "Effect": "Allow",
 "Action": [
 "logs:CreateLogStream",
 "logs:PutLogEvents"
 ],
 "Resource": [
 "arn:aws:logs:eu-central-1:634617701827:log-group:/aws/lambda/promo-video-composer-2:*"
 ]
 },
 {
 "Effect": "Allow",
 "Action": [
 "s3:GetObject",
 "s3:PutObject",
 "s3:ListBucket"
 ],
 "Resource": [
 "arn:aws:s3:::example-bucket",
 "arn:aws:s3:::example-bucket/*"
 ]
 },
 {
 "Effect": "Allow",
 "Action": [
 "logs:CreateLogGroup",
 "logs:CreateLogStream",
 "logs:PutLogEvents"
 ],
 "Resource": [
 "arn:aws:logs:*:*:*"
 ]
 },
 {
 "Effect": "Allow",
 "Action": [
 "ec2:DescribeNetworkInterfaces"
 ],
 "Resource": [
 "*"
 ]
 },
 {
 "Effect": "Allow",
 "Action": [
 "sns:*"
 ],
 "Resource": [
 "*"
 ]
 },
 {
 "Effect": "Allow",
 "Action": [
 "cloudwatch:*"
 ],
 "Resource": [
 "*"
 ]
 },
 {
 "Effect": "Allow",
 "Action": [
 "kms:Decrypt"
 ],
 "Resource": [
 "*"
 ]
 }
 ]
}



What do I miss ?


janoskukoda@Janoss-MacBook-Pro promo-video-composer-2 % ls -l $(which ffmpeg)
lrwxr-xr-x 1 janoskukoda admin 35 Feb 10 12:50 /opt/homebrew/bin/ffmpeg -> ../Cellar/ffmpeg/5.1.2_4/bin/ffmpeg



-
What is Multi-Touch Attribution ? (And How To Get Started)
2 février 2023, par Erin — Analytics Tips -
FFmpegAudio object has no attribute _process
28 janvier 2023, par Benjamin TsoumagasI'm trying to make a Discord music bot that is remotely hosted and to do that I need ffmpeg to work. I was able to add it using my Dockerfile but upon trying to play music with the bot I get the following errors. For context, I am hosting on Fly.io and using python with the Nextcord library. Below is my relevant code and the error message. Please let me know if any more information is required.


import nextcord, os, json, re, youtube_dl
from nextcord import Interaction, application_checks
from nextcord.ext import commands

youtube_dl.utils.bug_reports_message = lambda: ''

ytdl_format_options = {
 "format": "bestaudio/best",
 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
 'restrictfilenames': True,
 'noplaylist': True,
 'nocheckcertificate': True,
 'ignoreerrors': False,
 'logtostderr': False,
 'quiet': True,
 'no_warnings': True,
 'default_search': 'auto',
 'source_address': '0.0.0.0',
}

ffmpeg_options = {"options": "-vn"}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

class YTDLSource(nextcord.PCMVolumeTransformer):
 def __init__(self, source, *, data, volume=0.5):
 super().__init__(source, volume)
 self.data = data
 self.title = data.get("title")
 self.url = data.get("url")

 @classmethod
 async def from_url(cls, url, *, loop=None, stream=False):
 loop = loop or asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

 if "entries" in data:
 data = data["entries"][0]
 
 filename = data["url"] if stream else ytdl.prepare_filename(data)
 return cls(nextcord.FFmpegAudio(filename, *ffmpeg_options), data=data)

async def ensure_voice(interaction: Interaction):
 if interaction.guild.voice_client is None:
 if interaction.user.voice:
 await interaction.user.voice.channel.connect()
 else:
 await interaction.send("You are not connected to a voice channel.")
 raise commands.CommandError("Author not connected to a voice channel.")
 elif interaction.guild.voice_client.is_playing():
 interaction.guild.voice_client.stop()

class Music(commands.Cog, name="Music"):
 """Commands for playing music in voice channels"""

 COG_EMOJI = "🎵"

 def __init__(self, bot):
 self.bot = bot
 
 @application_checks.application_command_before_invoke(ensure_voice)
 @nextcord.slash_command()
 async def play(self, interaction: Interaction, *, query):
 """Plays a file from the local filesystem"""

 source = nextcord.PCMVolumeTransformer(nextcord.FFmpegPCMAudio(query))
 interaction.guild.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)

 await interaction.send(f"Now playing: {query}")

 @application_checks.application_command_before_invoke(ensure_voice)
 @nextcord.slash_command()
 async def yt(self, interaction: Interaction, *, url):
 """Plays from a URL (almost anything youtube_dl supports)"""

 async with interaction.channel.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 interaction.guild.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )

 await interaction.send(f"Now playing: {player.title}")

 @application_checks.application_command_before_invoke(ensure_voice)
 @nextcord.slash_command()
 async def stream(self, interaction: Interaction, *, url):
 """Streams from a URL (same as yt, but doesn't predownload)"""

 async with interaction.channel.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
 interaction.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )

 await interaction.send(f"Now playing: {player.title}")

def setup(bot):
 bot.add_cog(Music(bot))



2023-01-28T23:16:15Z app[7d3b734a] yyz [info]Exception ignored in: <function at="at" 0x7fa78ea61fc0="0x7fa78ea61fc0">
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]Traceback (most recent call last):
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/player.py", line 116, in __del__
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] self.cleanup()
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/player.py", line 235, in cleanup
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] self._kill_process()
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/player.py", line 191, in _kill_process
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]AttributeError: 'FFmpegA
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]AttributeError: 'FFmpegA
dio' object has no attribute '_process'
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]Ignoring exception in command :
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]Traceback (most recent call last):
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] await self(interaction, *args, **kwargs)
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] File "/main/cogs/music.py", line 153, in yt
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] player = await YTDLSource.from_url(url, loop=self.bot.loop)
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] File "/main/cogs/music.py", line 71, in from_url 
2023-01-28T23:16:15Z app[7d3b734a] yyz [info] return cls(nextcord.FFmpegAudio(filename, *ffmpeg_options), data=data)
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]
The above exception was the direct cause of the following exception:

re given
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]The above exception was the direct cause of the following exception:
2023-01-28T23:16:15Z app[7d3b734a] yyz [info]nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: FFmpegAudio.__init__() takes 2 positional arguments but 3 were given 
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]Exception ignored in: <function at="at" 0x7fa78ea61fc0="0x7fa78ea61fc0">
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]Traceback (most recent call last):
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/player.py", line 116, in __del__
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] self.cleanup()
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/player.py", line 235, in cleanup
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] self._kill_process()
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/player.py", line 191, in _kill_process
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] proc = self._process
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]AttributeError: 'FFmpegAudio' object has no attribute 
'_process'
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]Ignoring exception in command :
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]Traceback (most recent call last):
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] File "/usr/local/lib/python3.10/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] await self(interaction, *args, **kwargs)
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] File "/main/cogs/music.py", line 153, in yt
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] player = await YTDLSource.from_url(url, loop=self.bot.loop)
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] File "/main/cogs/music.py", line 71, in from_url 
2023-01-28T23:16:19Z app[7d3b734a] yyz [info] return cls(nextcord.FFmpegAudio(filename, *ffmpeg_options), data=data)
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]TypeError: FFmpegAudio.__init__() takes 2 positional arguments but 3 were given
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]The above exception was the direct cause of the following exception:
2023-01-28T23:16:19Z app[7d3b734a] yyz [info]nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: FFmpegAudio.__init__() takes 2 positional arguments but 3 were given
</function></function>


Similar posts have been made but their issues were typos in changing 'option' : '-vn' to 'options' : '-vn'. I've combed through for any other errors but I can't find any. I was hoping to see I made a similar mistake, but this is the template I was following from the Nextcord developers and I had no luck :