Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
ffplay aevalscr concat not transitioning smoothly
8 février, par mr.freezeGiven this ffplay command, I am expecting that the sine wave goes from 440hz to 454.4hz over 10 seconds then continue playing at 454.4hz for another 10 seconds. Instead, the transition is at different frequencies making it not smooth. What am I doing wrong?
ffplay -f lavfi -i " aevalsrc='sin(2*PI*t*(440 + (14.4*t/10)))':s=44100:d=10[wave1]; aevalsrc='sin(2*PI*t*454.4)':s=44100:d=10[wave2]; [wave1]afade=t=in:st=0:d=5[wave1]; [wave2]afade=t=out:st=5:d=5[wave2]; [wave1][wave2] concat=n=2:v=0:a=1"
-
How to Remove a Specific Segment from an Audio File Using Timestamps in C# ? [closed]
8 février, par Hilal KhanI am working on a C# project where I need to remove a specific segment from an audio file (e.g., WAV, MP3) based on start and end timestamps, while keeping the rest of the audio intact.
For example, given a 20-minute audio file, I want to remove the section from 17:00 to 19:00 and be left with a new audio file containing only 0:00-17:00 and 19:00-20:00 (i.e., keeping the parts before and after the cut).
I have used NAudio and FFmpeg to trim a file by cutting from the start or end, but I only get my desired snippet as a separate file which is not what I am looking for as I want it to be removed from the audio itself
Heres what I have so far:
static void RemoveSegment(string inputPath, string outputPath, double startTime, double endTime) { using (var reader = new Mp3FileReader(inputPath)) { var writer = new FileStream(outputPath, FileMode.Create, FileAccess.Write); int bytesPerMillisecond = reader.WaveFormat.AverageBytesPerSecond / 1000; long startPosition = (long)(startTime * 1000) * bytesPerMillisecond; long endPosition = (long)(endTime * 1000) * bytesPerMillisecond; byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = reader.Read(buffer, 0, buffer.Length)) > 0) { if (reader.Position < startPosition || reader.Position > endPosition) { writer.Write(buffer, 0, bytesRead); } } writer.Close(); } Console.WriteLine("Segment removed successfully!"); }
-
How do I combine videos with ffmpeg with delay ?
8 février, par Isaiah BarrierI have 44 videos that are all encoded the same and have the same dimensions, and they all have audio. I want to combine all of them with a 0.5 second pause between them in ffmpeg. How do I do that? The command I used that combines them without delay is
ffmpeg -f concat -safe 0 -i fl.txt -c copy -map 0 output.mp4
-
why does ffmpeg export black video ?
8 février, par Sling Ringi give ffmpeg a simple task which is the following
ffmpeg -i test.avi -c:v rawvideo -pix_fmt yuv420p out.yuv
i try to play the video but it gives a black screen, even in a .yuv player. ffmpeg supposedly "running"
Is there some human error that i am doing?
Signed Slingring
-
Python Discord Music Bot : Playing next song while current song is playing
8 février, par DeltracI've been working on a Discord bot and got it working 90% of the time. On some occasions, the bot will be playing a song and it will stop playing and just move to the next song. My assumption is that it's because of how I am handling my
play
command and theplay_next
command as well.I've tried to re-arrange the code, change functionality, etc. without success.
Here are the two commands:
@client.command(name="p") async def play(ctx, *, search_query: str): global bot_disconnect try: # Only start a song if the user trying to play a song is in a voice channel if ctx.author.voice: voice_channel = ctx.author.voice.channel voice_client = await voice_channel.connect() # Find who played the song and have the bot enter that channel voice_clients[voice_client.guild.id] = voice_client else: await ctx.channel.send("Get in a voice channel") return except Exception as e: print(e) try: if is_youtube_url(search_query): loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++) data = await loop.run_in_executor(None, lambda: ytdl.extract_info(search_query, download = False)) video_url = data["webpage_url"] # Save the youtube video URL to variable song_url = data["url"] # Save the extracted URL to a variable title = data["title"] else: url = f"ytsearch:{search_query}" loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++) data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download = False)) entry = data['entries'][0] video_url = entry["webpage_url"] # Save the youtube video URL to variable song_url = entry["url"] # Save the extracted URL to a variable title = entry["title"] if ctx.guild.id in voice_clients and voice_clients[ctx.guild.id].is_playing(): await queue(ctx, search_query = video_url, title = title) else: player = discord.FFmpegOpusAudio(song_url, **ffmpeg_options) # THIS IS WHAT PLAYS THE ACTUAL SONG!!!!!! await ctx.channel.send(f"Now Playing: {video_url} \n[DOWNLOAD LINK HERE]({song_url})") # Send the video URL to discord channel and include a download link as well bot_disconnect = False voice_clients[ctx.guild.id].play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), client.loop)) except Exception as e: print(e) async def play_next(ctx): if len(queues) != 0 and queues.get(ctx.guild.id): search_query = queues[ctx.guild.id].pop(0)[0] # Pull the URL from the next index loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++) print(f"{search_query}") data = await loop.run_in_executor(None, lambda: ytdl.extract_info(search_query, download = False)) player = discord.FFmpegOpusAudio(data["url"], **ffmpeg_options) voice_client = voice_clients[ctx.guild.id] voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), client.loop)) await ctx.channel.send(f"Now Playing: {data['webpage_url']} \n[DOWNLOAD LINK HERE]({data['url']})") # Send the video URL to discord channel and include a download link as well else: await ctx.send("No songs in queue")
I can also link the full code, if required.