Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Apply multiple text filters at once and burn into video for captioning without re-encoding, and fix error [ffmpeg-python wrapper]
13 mai, par BaldiIs there any way to burn text into a video without re-encoding? I ask this because the re-encoding process goes at around 0.1x speed on my device when writing to WEBM. Alternatively, if there is a faster way to render high quality video quickly while still re-encoding that would be great. I vaguely remember someone writing to a temporary file to solve this problem.
Also small error in program, code attatched
def processVideo(self): print("creating video") # File location management font_path = self.input_path / "CalSans-Regular.ttf" background_path = self.input_path / "new_video_background.webm" audio_path = self.sound_output_path video_ouput_path = self.parent_path / "new_result.webm" sound_input = ffmpeg.input(str(audio_path)) video_input = ffmpeg.input(str(background_path)) # Adding captions print(self.text_caption) previous_timepoint = 0 for caption, timepoint in zip(self.text_caption, self.timepoints, strict=False): # Text caption and timepooints are lists where the end of the words in text_caption correspond # to the timepoint with the same index in timepoint video_input = video_input.drawtext( text=caption, fontfile = font_path, x='w-text_w/2', y='h-text_h/2', escape_text=True, fontsize= 32, bordercolor = "black", borderw = 4, enable=f'between(t,{previous_timepoint},{timepoint["timeSeconds"]})' ) previous_timepoint = timepoint["timeSeconds"] # Combining sound and video and writing output command = ffmpeg.output(sound_input, video_input, str(video_ouput_path), codec='copy').overwrite_output().global_args('-shortest') print("args =", command) print(command.get_args()) command.run() print("done!")
File "c:\Desktop\Projects\video_project\main.py", line 239, in
post_list[0].processVideo() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "c:\Desktop\Projects\video_project\main.py", line 223, in processVideo command.run() ~~~~~~~~~~~^^ File "C:\Desktop\Projects\video_project\.venv\Lib\site-packages\ffmpeg\_run.py", line 313, in run process = run_async( stream_spec, ...<5 lines>... overwrite_output=overwrite_output, ) File "C:\Desktop\Projects\video_project\.venv\Lib\site-packages\ffmpeg\_run.py", line 284, in run_async return subprocess.Popen( ~~~~~~~~~~~~~~~~^ args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 1038, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pass_fds, cwd, env, ^^^^^^^^^^^^^^^^^^^ ...<5 lines>... gid, gids, uid, umask, ^^^^^^^^^^^^^^^^^^^^^^ start_new_session, process_group) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AppData\Local\Programs\Python\Python313\Lib\subprocess.py", line 1550, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ # no special security ^^^^^^^^^^^^^^^^^^^^^ ...<4 lines>... cwd, ^^^^ startupinfo) ^^^^^^^^^^^^ FileNotFoundError: [WinError 206] The filename or extension is too long -
How can I generate a video file directly from an FFmpeg filter with no actual input file ?
12 mai, par blahdiblahFFmpeg has a number of video generating filters, listed in the documentation as "video sources":
- cellauto
- color
- mptestsrc
- fei0r_src
- life
- nullsrc, rgbtestsrc, testsrc
Those are great for using with other filters like overlay, but is there any way that I can generate a movie consisting of just one of those video sources without any input video?
Something like:
ffmpeg -vf color=red" red_movie.mp4
Except that that errors out with
At least one input file must be specified
. -
Ffmpeg rtmp to hls conversion but how to solve network issue ?
11 mai, par Baka-Maru LamaI'm trying to convert hls stream from rtmp source and its' working fine but the problem is when rtmp server is down or network issue the ffmpeg hls conversion process gets stuck and never comes to work again even if rtmp server is back online.
I've tried
-reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 5
command - it says option is not recognized options by the way I'm using ffmpeg [v4.2.1].
I'm using following ffmpeg commands
ffmpeg -i rtmp://localhost/living/test ^ -max_muxing_queue_size 9999 ^ -async 1 -vf yadif -g 29.97 -r 23 ^ -b:v:0 3150k -c:v libx264 -filter:v:0 "scale=426:-1" -rc:v vbr_hq -pix_fmt yuv420p -profile:v main -level 4.1 -strict_gop 1 -rc-lookahead 32 -no-scenecut 1 -forced-idr 1 -b:a:0 128k -map 0:v -map 0:a:0 ^ -b:v:1 4200k -c:v libx264 -filter:v:1 "scale=640:-1" -rc:v vbr_hq -pix_fmt yuv420p -profile:v main -level 4.1 -strict_gop 1 -rc-lookahead 32 -no-scenecut 1 -forced-idr 1 -b:a:1 192k -map 0:v -map 0:a:0 ^ -b:v:2 5250k -c:v libx264 -filter:v:2 "scale=1280:-1" -rc:v vbr_hq -pix_fmt yuv420p -profile:v main -level 4.1 -strict_gop 1 -rc-lookahead 32 -no-scenecut 1 -forced-idr 1 -b:a:2 256k -map 0:v -map 0:a:0 ^ -c:a aac -ar 48000 ^ -f hls ^ -var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2" ^ -master_pl_name index.m3u8 ^ -t 30000 -hls_time 10 ^ -hls_init_time 4 -hls_list_size 0 ^ -master_pl_publish_rate 10 ^ -hls_flags delete_segments+discont_start+split_by_time "../live/test/vs%%v/manifest.m3u8" pause
-
Stream Recorder Using FFmpeg Fails on AWS Lambda
10 mai, par user30495567I am trying to stream audio from URLs and save them to a file in S3 using AWS Lambda with FFmpeg. Here is an example FFmpeg command I'm using:
ffmpeg -hide_banner -loglevel error -t 10 -i http://playerservices.streamtheworld.com/api/livestream-redirect/KTOOFMAAC_SC -ar 16000 -b:a 64k -ac 2 output.mp3
- The FFmpeg command is getting called in a python script using subprocess.Popen()
- The command works as expected on local, but does not work in an AWS Lambda python environment using a custom FFMPEG layer configured with these instructions.
- When run on Lambda, I get the following error: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/output.mp3'
Note: I've also tried a version where I use python requests to stream chunks and pipe them into ffmpeg. This works for some stream URLs, but for others, such as the streamtheworld URL above, it only saves ~5 seconds of audio from the stream or results in a Broken Pipe error.
-
Unexpected error : No such file or directory : 'ffprobe', while using pydub in Digital Ocean
10 mai, par CjmaretI have an app that processes audio files and converts them to 'wav' format. This works locally on my Mac, however in DigitalOcean, when recording audio, i get the below error, followed by a 500:
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Unexpected error: [Errno 2] No such file or directory: 'ffprobe'
I've tried including binary files in my code for
ffmpeg
andffprobe
but got the same error. ffmpeg and ffprobe binaries are in/bin
in the root of my project:from pydub import AudioSegment if platform.system() == "Darwin": # mac pass elif platform.system() == "Linux": # digitalocean) AudioSegment.converter = os.path.join("bin", "ffmpeg-linux") AudioSegment.ffprobe = os.path.join("bin", "ffprobe-linux") else: raise EnvironmentError( "Unsupported platform. Only macOS and Linux are supported.")