Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How is better to use ffmpeg with the ASP.NET Core, on Linux ?
26 mars, par user8245660I've got the project (ASP.NET Core, on Linux) where are the several tasks, which relate to the video converting and extracting frames from the video file.
I thought about the two possible options:
- using
ffmpeg
console utility - using
P/Invoke
with thelibavcodec
library and others, whichffmpeg
uses
The second option is miles harder and may be very impractical, because it reminds me developing the new wrapper/library, instead of using the ready products.
I've done googling, but there aren't well-done projects for the C#/ASP.NET Core on Linux platform. There are some good for C++ and Python, but NOT for the C# on Linux/.NET Core.
I decided to look at the first option, which I suppose would be more easier and practical. But, there are some weak places, which can produce many problems. We understand (I suppose), that using the 1st option, the end-developer shall use the process forking. So, there could be possible problems with the process idle and other possible issues...
I'm asking about your practice, because it's my first experience on Linux platform with the video converting/sampling using C#. I've used the Expression Encoder .NET library on Windows platform, but it's other story and it makes no sense, right now.
May be, there are other options, which I can't see right at the moment. I dislike the 1st option because of possible unhandled exceptions, because
ffmpeg
with such role becomes the black box for the ASP.NET Core backend. - using
-
Remove audio tracks with FFmpeg [closed]
25 mars, par David HildrethI have some ProRes MOV files that have good audio on the first two tracks and then tone on the last 14. I'd love to remove the last 14 tracks, but I can't seem to do it.
I've been trying variations on
ffmpeg -i input_video.mov -map 0 -map -0:a:2 -map -0:a:3 -c copy output_video.mov
but when I drag the resulting file into Premiere, the last 14 tracks are still included. How do I ditch those audio tracks?
-
Broken Pipe Error On Moviepy When Receiving a SIGINT OR SIGTERM
25 mars, par Pablo EstradaI'm trying to write a video with moviepy on a temp dir.
Here's a sample code:
video_file_name = '{}/{}'.format(tempfile.mkdtemp(), 'somefile.mp4') clip.write_videofile(video_file_name, audio = False, threads =4,logger = None)
This works perfectly fine. However In my app context I want to be able to catch SIGTERM or SIGINT signals and wait until this write finishes before actually killing the app.
I do it this way:
signal.signal(signal.SIGINT, self.exit_gracefully) signal.signal(signal.SIGTERM, self.exit_gracefully) def exit_gracefully(): # Some logic to wait for video processing to finish, for now we'll wait 1 hour to give enough time. time.sleep(3600)
The problem is that when I do this, moviepy raises an exception like this:
/lib/python3.7/site-packages/moviepy/video/io/ffmpeg_writer.py", line 136, in write_frame self.proc.stdin.write(img_array.tobytes()) BrokenPipeError: [Errno 32] Broken pipe During handling of the above exception, another exception occurred: File "", line 2, in write_videofile File "lib/python3.7/site-packages/moviepy/decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "", line 2, in write_videofile File "lib/python3.7/site-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) File "", line 2, in write_videofile File "lib/python3.7/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) File "lib/python3.7/site-packages/moviepy/video/VideoClip.py", line 307, in write_videofile logger=logger) File "lib/python3.7/site-packages/moviepy/video/io/ffmpeg_writer.py", line 228, in ffmpeg_write_video writer.write_frame(frame) File "lib/python3.7/site-packages/moviepy/video/io/ffmpeg_writer.py", line 180, in write_frame raise IOError(error) OSError: [Errno 32] Broken pipe MoviePy error: FFMPEG encountered the following error while writing file /tmp/tmpt0o8ae6e/1633997015.176414_re_saved.mp4: b''
Is there a way I can go around this error and allow my write file to finish? Another context is that this
write_videofile()
function is executed on a separate thread, I'm not sure if that's useful but it might help to give more insights.Any ideas on how I can solve this?
Thanks!
-
How to grab a single image from RTSP stream using FFMPEG
25 mars, par sealfabI have seen several other related questions but they all seem to be related to grabbing a still shot every X number of seconds. How can I grab 1 image when the command is run.
I was trying
ffmpeg -y -i rtsp://admin:admin@192.168.10.113:554/live -f image2 -updatefirst 1 do.jpg
-
Issue with Subtitles Not Embedding in Exported Video Using FFmpeg
25 mars, par Yash ChauhanI've been encountering an issue while attempting to embed subtitles into a video using FFmpeg. Despite following the process outlined below, the exported video does not include the subtitles:
export async function embedSubtitles(ffmpeg: FFmpeg, videoFile: File, srtContent: string) { await ffmpeg.writeFile('input.mp4', await fetchFile(videoFile)); await ffmpeg.writeFile('./subtitles.srt', srtContent); const ffmpeg_cmd = [ '-i', 'input.mp4', '-vf', 'subtitles=./subtitles.srt:force_style=\'FontSize=24,FontName=Arial\'', '-c:a', 'copy', 'output.mp4' ]; await ffmpeg.exec(ffmpeg_cmd); const data = await ffmpeg.readFile('output.mp4') as Uint8Array; const blob = new Blob([data], { type: 'video/mp4' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'output.mp4'; a.click(); return { url, output: 'output.mp4' }; }
I've reviewed this code extensively and cannot determine why the subtitles are not being embedded. I've ensured that srtContent is correctly formatted and that FFmpeg executes without errors. What changes or alternative methods can I use to properly embed subtitles into the exported video?