Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to check when ffmpeg completes a task ?
25 mai 2018, par AndrewI'm just learning how to use ffmpeg a few hours ago to generate video thumbnails.
These are some results:
I'd used the same size (width - height) to Youtube's. Each image contains max 25 thumbnails (5x5) with the size 160x90.
Everything looks good until:
public async Task GetVideoThumbnailsAsync(string videoPath, string videoId) { byte thumbnailWidth = 160; byte thumbnailHeight = 90; string fps = "1/2"; videoPath = Path.Combine(_environment.WebRootPath, videoPath); string videoThumbnailsPath = Path.Combine(_environment.WebRootPath, $"assets/images/video_thumbnails/{videoId}"); string outputImagePath = Path.Combine(videoThumbnailsPath, "item_%d.jpg"); Directory.CreateDirectory(videoThumbnailsPath); using (var ffmpeg = new Process()) { ffmpeg.StartInfo.Arguments = $" -i {videoPath} -vf fps={fps} -s {thumbnailWidth}x{thumbnailHeight} {outputImagePath}"; ffmpeg.StartInfo.FileName = Path.Combine(_environment.ContentRootPath, "FFmpeg/ffmpeg.exe"); ffmpeg.Start(); } await Task.Delay(3000); await GenerateThumbnailsAsync(videoThumbnailsPath, videoId); }
I'm getting a trouble with the line:
await Task.Delay(3000);
When I learn the way to use ffmpeg, they didn't mention about it. After some hours failed, I notice that:
An mp4 video (1 min 31 sec - 1.93Mb) requires some delay time ~1000ms. And other, an mp4 video (1 min 49 sec - 7.25Mb) requires some delay time ~3000ms.
If I don't use
Task.Delay
and try to get all the files immediately, it would return 0 (there was no file in the directory).Plus, each file which has a difference length to the others requires a difference delay time. I don't know how to calculate it.
And my question is: How to check when the task has completed?
P/s: I don't mean to relate to javascript, but in js, there is something called
Promise
:var promise = new Promise(function (done) { var todo = function () { done(); }; todo(); }); promise.then(function () { console.log('DONE...'); });
I want to edit the code like that.
Thank you!
-
How to profile compression speed for a h264 encoder
25 mai 2018, par DeanI'm using nvenc to compress in h264 a video stream. I now have a kinda-working low latency implementation for game streaming purposes but I'm struggling to get reliable profiling results. I've been trying to stream a video (so everything is predetermined) via my encoder to the clients in controlled network conditions (e.g. locally). I tried to time average compression times per frame but they're highly volatile and the numbers I get aren't that meaningful.
How are low latency streaming encoders tested for performances?
-
FFmpeg error : Output file is empty, nothing was encoded
25 mai 2018, par Morteza MI am using the following command ffmpeg command and execute it in Python. It used to work for at least a month finely. However, its two days it stopped working and generates different errors. The most important one is "Output file is empty, nothing was encoded"
PS: I checked the connectivity to Camera and is healthy. I am able to see the Camera output on my screen using its software.
The Command:
ffmpeg -i rtsp://username:pass@ip_add:port/videoMain -b 1920k -f image2 -r fps -strftime 1 %Y-%m-%d_%H-%M-%S.jpg
PS: fps is taken from input. I mainly used 1 for that.
I would be gratfful if anyone can help with this. Thank you.
-
100% of gif does not convert to mp4 with moviepy
25 mai 2018, par ThePeskyWabbitwhen I execute the following code:
import requests import moviepy.editor as mp url = "https://i.imgur.com/VaTidQA.gif" with open('temp.gif', 'wb') as f: f.write(requests.get(url).content) clip = mp.VideoFileClip("temp.gif") print(clip.duration) clip.write_videofile("temp.mp4")
I experience loss of frames on the mp4 file. the mp4 will always start from the beginning but will seemingly arbitrarily cut off at some point.
Here is an example:
GIF: https://i.imgur.com/VaTidQA.gif
MP4: https://giphy.com/gifs/pesky-wabbit-5UqQOjkYLuWrvHzvsA
The gif is indeed downloaded in its entirety.
Upon testing, I found that if I change the last line to:
clip.set_duration(clip.duration + X).write_videofile("temp.mp4")
then it will indeed extend the MP4 and cut off less, but this needs to be a variable script as it will be used for many, many gifs. It is almost certainly due to the fact that moviepy is getting the wrong duration from the gif. Any suggestions on how I can remedy this?
update: I have determined that moviepy is obtaining the incorrect duration from the gif. when that duration is passed to the
write_videofile()
call, it only writes that shorter interval. I am looking into how it determines the gif duration. -
Stream H264 using live555 and FFmpeg
25 mai 2018, par sarbjitsinghI am trying to stream data encoded using FFMPEg using live555. I have a custom framesource that sends the data to sink but I am unable to figure out how to set SPS and PPS in the framer. I understand that
extradata
contains this information but I saw only SPS in that. Does extradata changes while encoding by FFMPeg? If yes how and when we need to update this information in live555 framer.Does anyone have a working sample using FFMpeg and live555 to stream H264