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










share|improve this question






















  • 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















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










share|improve this question






















  • 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













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










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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.






share|improve this answer























  • Daily Okay I will try doing that. Thank you!
    – JayJay123
    Nov 11 at 16:27











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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.






share|improve this answer























  • Daily Okay I will try doing that. Thank you!
    – JayJay123
    Nov 11 at 16:27















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.






share|improve this answer























  • Daily Okay I will try doing that. Thank you!
    – JayJay123
    Nov 11 at 16:27













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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 10:00

























answered Nov 11 at 8:59









Matthew Daly

5,95622759




5,95622759












  • 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




Daily Okay I will try doing that. Thank you!
– JayJay123
Nov 11 at 16:27


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?