Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Randomly extract video frames from multiple files [closed]
5 juillet, par PatraoPedroI have a folder with hundreds of video files (*.avi), each one with more or less an hour long. What I would like to achieve is a piece of code that could go through each one of those videos and randomly select two or three frames from each file and then stitch it back together or alternatively save the frames in a folder as jpegs.
Initially I thought I could do this using R but quickly I've realised that I would need something else possibly working together with R.
Is it possible to call FFMPEG from R to do the task above?
-
Moviepy write_videofile works the second time but not the first ?
5 juillet, par Andrew BestI'm concatenating a list of video objects together then writing them with write_videofile, weirdly enough the first time I write the file, it plays fine for the first halfish then the first few frames of each clip in the file afterwards plays before freezing. But here's the odd part, If I write the exact same video object right after the first video writes, it writes just fine and plays perfectly.
Here's my code
from moviepy.editor import VideoFileClip, concatenate_videoclips clipslist = [] clips = ['https://clips-media-assets2.twitch.tv/AT-cm%7C787619651.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787628097.mp4', 'https://clips-media-assets2.twitch.tv/2222789345-offset-20860.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787624765.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787539697.mp4', 'https://clips-media-assets2.twitch.tv/39235981488-offset-3348.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788412970.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787682495.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787962593.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787627256.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787573008.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788543065.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787593688.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788079881.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788707738.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788021727.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787595029.mp4', 'https://clips-media-assets2.twitch.tv/39233367648-offset-9536.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788517651.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C788087743.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787497542.mp4', 'https://clips-media-assets2.twitch.tv/39233367648-offset-9154.mp4', 'https://clips-media-assets2.twitch.tv/7109626012888880881-offset-4818.mp4', 'https://clips-media-assets2.twitch.tv/72389234-offset-760.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787774924.mp4', 'https://clips-media-assets2.twitch.tv/AT-cm%7C787565708.mp4'] for clip in clips: dlclip = VideoFileClip(clip, target_resolution=(1080, 1920)) # Download clip clipslist.append(dlclip) videofile = concatenate_videoclips(clipslist) videofile.write_videofile("final1.mp4") # Broken after the first halfish videofile.write_videofile("final2.mp4") # Works entirely fine. videofile.close
Any ideas? Any suggestions appreciated.
- Sometimes when the video is small enough it seems to write the first time just fine too.
- It seems there is no set point where it breaks, each time I write it for the first time it typically breaks at a different spot.
- I've tried waiting for the thread to exit and sleeping after the concatenation and that doesn't seem to fix the issue.
-
FFmpeg adds its own metadata - encoder : Lavf58.20.100
5 juillet, par NarūnasKI've tried to apply the following advice on the
flac
files:for x in *.flac; do ffmpeg -i "$x" -map 0:a -codec:a copy -map_metadata -1 clean_"$x"; done
But it seems, that
ffmpeg
though removes mostmetadata
, it also adds its own fingerprint.Why does it add this tag? What is the best way to get rid of it?
-
How to remove ffmpeg metadata "software lavf55.7.100"
5 juillet, par JoeedomiI'm using ffmpeg to extract audio from video files, then process the audio and cut it into smaller clip. But when i use ffmpeg to do the extraction, it adds a metadata "software lavf55.7.100" into my audio file, which screws my indexing of cutting. How can i get rid of this?
In attached picture, in the middle "Metadata: ISFT : Lavf55.7.100"
The string that i'm using is:ffmpeg -i steve.mp4 -map_metadata -1 steve14.wav
-
ffmpeg try to open output file but fail [closed]
5 juillet, par Lyhourt TeIn my Windows 11, I use this code to use ffmpeg to convert video from one type to another type. The code is simple, it just loops and finds the target file extension and runs ffmpeg to convert the video This code used to work just fine, but now it's not working anymore. I think it maybe because of the Windows 11 security update.
import os import subprocess def convert_ts_to_mp4(folder_path): # Ensure the folder exists if not os.path.isdir(folder_path): print(f"Folder '{folder_path}' does not exist.") return # Loop through files in the folder for filename in os.listdir(folder_path): if filename.endswith(".ts"): # Check if the file is a .ts file print("read file:", filename) ts_file = os.path.join(folder_path, filename) mp4_file = os.path.join(folder_path, filename.replace(".ts", ".mp4")) print("ts file:", ts_file) print("mp4 file:", mp4_file) # Run ffmpeg command command = ["ffmpeg", "-i", ts_file, mp4_file] subprocess.run(command, check=True) print(f"Converted: {filename} -> {os.path.basename(mp4_file)}") if __name__ == "__main__": folder_path = os.path.dirname(os.path.abspath(__file__)) # Change this to your actual folder path convert_ts_to_mp4(folder_path)
The error:
Input #0, mpegts, from 'C:\Users\chhor\Downloads\Video\script\python-script-for-automation\1.ts': Duration: 00:44:25.20, start: 1.440000, bitrate: 3095 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x872 [SAR 959:960 DAR 959:436], 25 fps, 25 tbr, 90k tbn, start 1.480000 Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 130 kb/s, start 1.440000 [out#0/mp4 @ 0000014f60d66d80] Error opening output C:\Users\chhor\Downloads\Video\script\python-script-for-automation\new.mp4: No such file or directory Error opening output file C:\Users\chhor\Downloads\Video\script\python-script-for-automation\new.mp4. Error opening output files: No such file or directory Traceback (most recent call last): File "C:\Users\chhor\Downloads\Video\script\python-script-for-automation\ts.py", line 27, in
convert_ts_to_mp4(folder_path) File "C:\Users\chhor\Downloads\Video\script\python-script-for-automation\ts.py", line 22, in convert_ts_to_mp4 subprocess.run(command, check=True) File "C:\ProgramData\anaconda3\Lib\subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ffmpeg', '-i', 'C:\\Users\\chhor\\Downloads\\Video\\script\\python-script-for-automation\\1.ts', 'C:\\Users\\chhor\\Downloads\\Video\\script\\python-script-for-automation\\new.mp4']' returned non-zero exit status 4294967294.