Why is ffmpeg processing time so slow?
up vote
0
down vote
favorite
I am using ffmpeg to convert and compress videos. When I upload my video file it takes a long time to process. The video can be 1.2mb or even 5.8mb or even 10mb and its still slow, I am just there staring at the screen waiting for 20 minutes or even more. What can I do to speed up the process? If you need me to provide you with my code here it is
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters) {
$filters->resize(new FFMpegCoordinateDimension(640, 480));
})
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
Thanks in advance
laravel
add a comment |
up vote
0
down vote
favorite
I am using ffmpeg to convert and compress videos. When I upload my video file it takes a long time to process. The video can be 1.2mb or even 5.8mb or even 10mb and its still slow, I am just there staring at the screen waiting for 20 minutes or even more. What can I do to speed up the process? If you need me to provide you with my code here it is
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters) {
$filters->resize(new FFMpegCoordinateDimension(640, 480));
})
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
Thanks in advance
laravel
How long should it take? How fast is your system?
– James McLeod
Nov 11 at 4:43
@James thank you for responding, Do you see when you go on you tube to upload a video how fast the processing is? That is what I want. I shouldn't be staring at the screen for so long waiting for my video to upload. On top that the video file is not even big
– JayJay123
Nov 11 at 4:47
YouTube doesn't process video files in the same request as the upload.
– duskwuff
Nov 11 at 6:04
Yeah, YouTube most likely purely handles the upload on the initial request, then in the background processes it with a job queue. laravel.com/docs/5.7/queues
– Derek Pollard
Nov 11 at 6:44
@DerekPollard okay I understand now.
– JayJay123
Nov 11 at 20:56
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using ffmpeg to convert and compress videos. When I upload my video file it takes a long time to process. The video can be 1.2mb or even 5.8mb or even 10mb and its still slow, I am just there staring at the screen waiting for 20 minutes or even more. What can I do to speed up the process? If you need me to provide you with my code here it is
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters) {
$filters->resize(new FFMpegCoordinateDimension(640, 480));
})
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
Thanks in advance
laravel
I am using ffmpeg to convert and compress videos. When I upload my video file it takes a long time to process. The video can be 1.2mb or even 5.8mb or even 10mb and its still slow, I am just there staring at the screen waiting for 20 minutes or even more. What can I do to speed up the process? If you need me to provide you with my code here it is
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters) {
$filters->resize(new FFMpegCoordinateDimension(640, 480));
})
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
Thanks in advance
laravel
laravel
asked Nov 11 at 4:42
JayJay123
277
277
How long should it take? How fast is your system?
– James McLeod
Nov 11 at 4:43
@James thank you for responding, Do you see when you go on you tube to upload a video how fast the processing is? That is what I want. I shouldn't be staring at the screen for so long waiting for my video to upload. On top that the video file is not even big
– JayJay123
Nov 11 at 4:47
YouTube doesn't process video files in the same request as the upload.
– duskwuff
Nov 11 at 6:04
Yeah, YouTube most likely purely handles the upload on the initial request, then in the background processes it with a job queue. laravel.com/docs/5.7/queues
– Derek Pollard
Nov 11 at 6:44
@DerekPollard okay I understand now.
– JayJay123
Nov 11 at 20:56
add a comment |
How long should it take? How fast is your system?
– James McLeod
Nov 11 at 4:43
@James thank you for responding, Do you see when you go on you tube to upload a video how fast the processing is? That is what I want. I shouldn't be staring at the screen for so long waiting for my video to upload. On top that the video file is not even big
– JayJay123
Nov 11 at 4:47
YouTube doesn't process video files in the same request as the upload.
– duskwuff
Nov 11 at 6:04
Yeah, YouTube most likely purely handles the upload on the initial request, then in the background processes it with a job queue. laravel.com/docs/5.7/queues
– Derek Pollard
Nov 11 at 6:44
@DerekPollard okay I understand now.
– JayJay123
Nov 11 at 20:56
How long should it take? How fast is your system?
– James McLeod
Nov 11 at 4:43
How long should it take? How fast is your system?
– James McLeod
Nov 11 at 4:43
@James thank you for responding, Do you see when you go on you tube to upload a video how fast the processing is? That is what I want. I shouldn't be staring at the screen for so long waiting for my video to upload. On top that the video file is not even big
– JayJay123
Nov 11 at 4:47
@James thank you for responding, Do you see when you go on you tube to upload a video how fast the processing is? That is what I want. I shouldn't be staring at the screen for so long waiting for my video to upload. On top that the video file is not even big
– JayJay123
Nov 11 at 4:47
YouTube doesn't process video files in the same request as the upload.
– duskwuff
Nov 11 at 6:04
YouTube doesn't process video files in the same request as the upload.
– duskwuff
Nov 11 at 6:04
Yeah, YouTube most likely purely handles the upload on the initial request, then in the background processes it with a job queue. laravel.com/docs/5.7/queues
– Derek Pollard
Nov 11 at 6:44
Yeah, YouTube most likely purely handles the upload on the initial request, then in the background processes it with a job queue. laravel.com/docs/5.7/queues
– Derek Pollard
Nov 11 at 6:44
@DerekPollard okay I understand now.
– JayJay123
Nov 11 at 20:56
@DerekPollard okay I understand now.
– JayJay123
Nov 11 at 20:56
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Processing videos is slow, and the only reliable way to actually speed it up is to throw more resources at it, which usually isn't worth it. YouTube is fast at least in part because they have Google's resources, which the likes of you and I usually don't.
However, you can speed up the user's perception of speed by moving the video processing to a message queue (which YouTube almost certainly uses too). That way the request will finish quickly, and you can process the queue in the background. Then, when it's finished you can notify the user in an appropriate fashion, whether that's an email or a notification via Websockets. As Derek Pollard mentioned, Laravel has its own queue implementation and you should refer to the documentation for that.
Another option might be to hand off video processing to a dedicated microservice, in which case that microservice would need to notify your application once processing is done. Or there are third party services that will do the same thing, if your budget allows for them. Regardless, this type of task is best done asynchronously rather than leaving the user waiting for 20 minutes or so.
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Processing videos is slow, and the only reliable way to actually speed it up is to throw more resources at it, which usually isn't worth it. YouTube is fast at least in part because they have Google's resources, which the likes of you and I usually don't.
However, you can speed up the user's perception of speed by moving the video processing to a message queue (which YouTube almost certainly uses too). That way the request will finish quickly, and you can process the queue in the background. Then, when it's finished you can notify the user in an appropriate fashion, whether that's an email or a notification via Websockets. As Derek Pollard mentioned, Laravel has its own queue implementation and you should refer to the documentation for that.
Another option might be to hand off video processing to a dedicated microservice, in which case that microservice would need to notify your application once processing is done. Or there are third party services that will do the same thing, if your budget allows for them. Regardless, this type of task is best done asynchronously rather than leaving the user waiting for 20 minutes or so.
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
add a comment |
up vote
3
down vote
accepted
Processing videos is slow, and the only reliable way to actually speed it up is to throw more resources at it, which usually isn't worth it. YouTube is fast at least in part because they have Google's resources, which the likes of you and I usually don't.
However, you can speed up the user's perception of speed by moving the video processing to a message queue (which YouTube almost certainly uses too). That way the request will finish quickly, and you can process the queue in the background. Then, when it's finished you can notify the user in an appropriate fashion, whether that's an email or a notification via Websockets. As Derek Pollard mentioned, Laravel has its own queue implementation and you should refer to the documentation for that.
Another option might be to hand off video processing to a dedicated microservice, in which case that microservice would need to notify your application once processing is done. Or there are third party services that will do the same thing, if your budget allows for them. Regardless, this type of task is best done asynchronously rather than leaving the user waiting for 20 minutes or so.
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Processing videos is slow, and the only reliable way to actually speed it up is to throw more resources at it, which usually isn't worth it. YouTube is fast at least in part because they have Google's resources, which the likes of you and I usually don't.
However, you can speed up the user's perception of speed by moving the video processing to a message queue (which YouTube almost certainly uses too). That way the request will finish quickly, and you can process the queue in the background. Then, when it's finished you can notify the user in an appropriate fashion, whether that's an email or a notification via Websockets. As Derek Pollard mentioned, Laravel has its own queue implementation and you should refer to the documentation for that.
Another option might be to hand off video processing to a dedicated microservice, in which case that microservice would need to notify your application once processing is done. Or there are third party services that will do the same thing, if your budget allows for them. Regardless, this type of task is best done asynchronously rather than leaving the user waiting for 20 minutes or so.
Processing videos is slow, and the only reliable way to actually speed it up is to throw more resources at it, which usually isn't worth it. YouTube is fast at least in part because they have Google's resources, which the likes of you and I usually don't.
However, you can speed up the user's perception of speed by moving the video processing to a message queue (which YouTube almost certainly uses too). That way the request will finish quickly, and you can process the queue in the background. Then, when it's finished you can notify the user in an appropriate fashion, whether that's an email or a notification via Websockets. As Derek Pollard mentioned, Laravel has its own queue implementation and you should refer to the documentation for that.
Another option might be to hand off video processing to a dedicated microservice, in which case that microservice would need to notify your application once processing is done. Or there are third party services that will do the same thing, if your budget allows for them. Regardless, this type of task is best done asynchronously rather than leaving the user waiting for 20 minutes or so.
edited Nov 11 at 10:00
answered Nov 11 at 8:59
Matthew Daly
5,94122759
5,94122759
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
add a comment |
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245912%2fwhy-is-ffmpeg-processing-time-so-slow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How long should it take? How fast is your system?
– James McLeod
Nov 11 at 4:43
@James thank you for responding, Do you see when you go on you tube to upload a video how fast the processing is? That is what I want. I shouldn't be staring at the screen for so long waiting for my video to upload. On top that the video file is not even big
– JayJay123
Nov 11 at 4:47
YouTube doesn't process video files in the same request as the upload.
– duskwuff
Nov 11 at 6:04
Yeah, YouTube most likely purely handles the upload on the initial request, then in the background processes it with a job queue. laravel.com/docs/5.7/queues
– Derek Pollard
Nov 11 at 6:44
@DerekPollard okay I understand now.
– JayJay123
Nov 11 at 20:56