Author |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Sun 11 Jan '15 12:47 Post subject: |
|
|
jimski wrote: | How do you guys manage ffmpeg conversions on windows.
Do you use a job queue or a different method?
If you don't use a job queue then how do you deal with the cases when an ffmpeg video conversion fails for some reason. How do you track those cases and how do you restart them. Also how do you deal with cases when ffmpeg process hangs. How do you track it and shut it down.
Also post your experiences if you do use a job queue on windows.
On Linux all this is much simpler because running a job queue and getting the process IDs and tracking/shutting down processes is well implemented by the Linux OS and by php POSIX and other functions which are not available on windows. Also there are many open source projects related to this subject. On windows this is a major pain in the rear suspension. |
I run multiple conversion servers all executing a PHP cronjob process via cmd/bat script here is my code.
Code: | title FFMPEG Keep running 2
:loop
@echo off
tasklist /nh /fi "imagename eq ffmpeg.exe" | find /i "ffmpeg.exe" >nul && (
echo FFMPEG is running >NUL
) || (
echo FFMPEG is not running >NUL
C:\Users\root\Desktop\php-5.5.13-nts-Win32-VC11-x64\php.exe -f "C:\server\websites\public_www\administrator\components\com_hwdmediashare\cli.php" process
)
timeout /t 60 /NOBREAK >NUL
goto loop
pause>nul |
Even thought you dont realy need to check if ffmpeg is already running i put the code in as a fail safe incase ffmpeg crashes or freezes etc and every 60 seconds it will start converting newly uploaded media.
The second part is you get the information on your upload via "ffmpeg -i" in command line this will output the information of a file using the information you can use preg_match etc to get the duration of the file the file size and convert it into the correct scales bitrates etc.
To save me the work of all this and since i am a Joomla user i just use this extension www.hwdmediashare.co.uk and with process logs are in your mysql database as successfull and if a upload is corrupt it gets marked as failed because ffmpeg could not create a output file. You do need allot of servers to keep up with the amount of uploads but once you get into the swing of things it goes very fast. (Also i will add i do not use FTP) Why use FTP when on windows you get network sharing what is faster and can take more connections uses less memory and cpu. Just set your storage paths to your shared hard drive location.
Also i will add my build of the HWDMediaShare extension is custom for my needs and since i do all tasks across a virtual rack (ethernet) via sharing windows hard drives. But it saved me a hell of allot of work building something from scratch.
Last edited by C0nw0nk on Sun 11 Jan '15 13:49; edited 1 time in total |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Sun 11 Jan '15 13:44 Post subject: |
|
|
C0nw0nk wrote: |
...The second part is you get the information on your upload via "ffmpeg -i" in command line this will output the information of a file using the information you can use preg_match etc to get the duration of the file the file size and convert it into the correct scales bitrates etc. |
I was using a similar method but I have had several problems:
1. If a batch starts an ffmpeg processing of a video file called newvid.avi and the processing takes a very long time and if another cron job starts new batch process before the current video converting job is finished then I'm converting the same file twice. I could write it to a log and check if the file was already sent for processing but then I'm really implementing a primitive queue using a log file.
2. tasklist /nh /fi "imagename eq ffmpeg.exe" | find /i "ffmpeg.exe" >nul && ( echo FFMPEG is running >NUL
If an ffmpeg process is running then this code only tells me that the ffmpeg.exe is running but I don't know what video files are being processed by this process.
3. If a conversion fails then I end up with a defective video output file which needs to be deleted or overwritten but without a log or a queue I have no way of knowing which files failed.
On linux I use a processing queue and I have the process ID of each ffmpeg perocess and a file name of the video file associated with this ffmpeg process. Then I can track which file was converted, when and how long it took and if it failed or is still running and then I can take appropriate steps based on this data.
C0nw0nk wrote: |
You do need allot of servers to keep up with the amount of uploads but once you get into the swing of things it goes very fast. (Also i will add i do not use FTP) Why use FTP when on windows you get network sharing what is faster and can take more connections uses less memory and cpu. Just set your storage paths to your shared hard drive location. |
I'm currently running a load balancer which sends the upload requests to two upload servers and those servers handle the uploads and then they also run ffmpeg to convert the uploads and the finished converted video files are written to a separate remote network storage server.
Last edited by jimski on Sun 11 Jan '15 13:54; edited 1 time in total |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Sun 11 Jan '15 13:54 Post subject: |
|
|
My log and process que is in the extension www.hwdmediashare.co.uk what just uses preg_match and writes outputs to the database.
Also if you want to know what process ID / video is currently converting a good way to know is to uses windows syslog and have php echo the currently converting media id name etc to there so you know.
You know if a conversion has failed via the fact you should mark number of attempts at converting a media item and +1 it each time it tries if it is looping you know you have a problem also using preg_match and retriving the ffmpeg output you know if a conversion has failed because ffmpeg will tell you.
How good is your knowledge on ffmpeg ? Perhaps you should understand the command line because your next hurdle will be making video outputs HTML5 friendly and it is not a walk in the park.
You need to make sure your mp4 outputs are compatible with all devices you also need to move metadata from the end of the file to the start another major problem is you can only use the aac audio encoded in mp4's because if you use mp3 or others IOS users do not have audio and can only watch the video with no audio then you have the issue of not every OS is compatible with MP4 files so you need to generate Both MP4 and Webm and FLV for those who do not use HTML5 and are still in the stone age of Flash.
Even using the settings youtube sets will cause issues you need to be custom. https://support.google.com/youtube/answer/1722171
Once you know ffmpeg's outputs you can just put preg_match in your php code to know if the output will fail or was a success if it fails you can tell php to delete or what ever you want it to do.
Last edited by C0nw0nk on Sun 11 Jan '15 14:02; edited 1 time in total |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Sun 11 Jan '15 14:01 Post subject: |
|
|
C0nw0nk wrote: | Also if you want to know what process ID / video is currently converting a good way to know is to uses windows syslog and have php echo the currently converting media id name etc to there so you know. |
Thanks C0nw0nk, I will try syslog. I already started writing a queue for windows and I will probably use Redis as a store for the queue. There is an nice queue for Linux called "Resque" but of course it won't run on windows.
Last edited by jimski on Sun 11 Jan '15 14:12; edited 2 times in total |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Sun 11 Jan '15 14:06 Post subject: |
|
|
You have a massive task ahead of you my advice would be just buy or get a exsisting extension that already does all this work for you and you can customise it to your needs like i do.
here is a few i am aware of that you will proborly love and make your life easy aswell as save time and money.
http://www.hwdmediashare.co.uk
http://www.adultvideoscript.com
http://clip-bucket.com/
Clip bucket is the only free one there i used to use it but i prefer hwdmediashare since it suits my joomla needs it allows image, music, video, and regular file uploads so hwdmediashare was perfect for me since it did everything compared to the others.
I also use process lasso to restrict cpu on windows via assigning ffmpeg to specific cpu affinities. I leave 1-2 CPU cores free and assign maybe php or nginx to them and give ffmpeg the rest.
It depends on what your needs are i needed a CMS/Blog/Forum/Media component so i went with Joomla and HWDMediaShare it depends on what you want to create.
I will also add i dont know how good the others are on windows or with multiple conversion servers via network sharing i customised Hwdmediashare to do this task for me.
Last edited by C0nw0nk on Sun 11 Jan '15 14:19; edited 1 time in total |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Sun 11 Jan '15 14:12 Post subject: |
|
|
C0nw0nk wrote: |
How good is your knowledge on ffmpeg ? Perhaps you should understand the command line because your next hurdle will be making video outputs HTML5 friendly and it is not a walk in the park. |
I will need help with conversion commands. I would describe my knowledge of ffmpeg as intermediate.
Recently, I found this project but haven't had time to analyze it. If I use it I will re-write the database section to make it work with Redis.
https://github.com/fordnox/php-queue-manager |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Sun 11 Jan '15 14:26 Post subject: |
|
|
If you do encounter errors with your custom build and dont understand ask at http://superuser.com/ although i recon they will tell you what i told you that you should use a exsisting component and customise it since the job might be to big for you and take you to long.
Here is a part of my command line
Code: | -strict experimental -pix_fmt yuv420p -profile:v baseline -level 3.0 -acodec aac -ar 44100 -ac 2 -ab 128k |
You need to set the pix_fmt to prevent a failed ffmpeg output with certain videos profile baseline and level makes your video output compatible with dumb media players and pretty much compatible with all playback devices acodec or audio codec has to be aac because if you use libmp3lame or others libfak etc IOS users wont hear audio and set your bit rates and audio rate sensibly.
And also use Code: | -movflags +faststart | to move meta data from the end of the mp4 file to the start so it is HTML5 ready. It used to be you had to use QT-FASTSTART but ffmpeg now comes with it built in so just add that to your command line and you do not need faststart to fix the files metadata.
Also if you are not generating H264 Mp4 files and are making FLV for flash you need to look into using either FLVTOOL2 or Yamdi i recommend Yamdi it is faster and maintained.
There are windows builds somewhere of Yamdi and FLVTOOL2 Aswell as QT-FASTSTART if you realy want them i dont know where to be honnest since i dont need or use them. I only generate MP4/Webm and i use ffmpeg to fix meta data.
Read through this lot.
https://trac.ffmpeg.org/wiki/Encode/H.264
https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio#Containerformats
https://trac.ffmpeg.org/wiki/StreamingGuide
https://trac.ffmpeg.org/wiki/Encode/YouTube
https://trac.ffmpeg.org/wiki/Encode/VP8
https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/
https://www.virag.si/2012/01/webm-web-video-encoding-tutorial-with-ffmpeg-0-9/
https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping
http://sonnati.wordpress.com/2011/08/19/ffmpeg-%E2%80%93-the-swiss-army-knife-of-internet-streaming-%E2%80%93-part-iii/
https://support.google.com/youtube/answer/1722171
Also i dont use apache anymore because of concurrent connection limits and because it is a threaded server it eats away at CPU and memory i now use Nginx (NG4WIN's builds) and PHP (Jan-E's builds) I dont use third party PHP Extensions other than Wincache god i love that extension If your setup is stable all else will follow. And FFMPEG is not dumb somtimes you get stupid programs that don't seem to recognize Network sharing or shared hard drives luckly ffmpeg is not one Nginx i had a slight issue with it not knowing how to get data from Z:/ drive but i fixed it.
Also another major peace of advice that is highly irelevant but i had allot of headache with this on windows is you need to increase the Windows paging file it is default at 4gb and if you have 32gb of ram you wont be using all of your machines potential and i had PHP crashes due to memory issues and ffmpeg seemed a little slow i increased the paging file limit on Windows and all those problems went away.
With 32gb of ram and Wincache i can run upto 500-600 PHP process at once with my Paging file set to system managed instead of the default 4gb (You can run more but you have to decrease memory_limit in your php.ini from the default). As you can imagine with nginx having a concurrent connection limit of upto a million you can process allot of traffic like this. And dont use the open_file_cache in nginx your server will most likely lock up and not let you connect and be very laggy because open_file_cache eats away at ram and with paging file being system managed nginx will end up using all of it not leaving room for remote desktop or anything else.
Last edited by C0nw0nk on Tue 13 Jan '15 20:50; edited 1 time in total |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Sun 11 Jan '15 15:10 Post subject: |
|
|
C0nw0nk wrote: |
Here is a part of my command line
Code: | -strict experimental -pix_fmt yuv420p -profile:v baseline -level 3.0 -acodec aac -ar 44100 -ac 2 -ab 128k |
And also use Code: | -movflags +faststart | to move meta data from the end of the mp4 file to the start so it is HTML5 ready. |
Thanks C0nw0nk, this is very helpful I had no idea about moving metadata.
As far as syslog is concerned are you using any third party software such as WinSyslog or similar? |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Sun 11 Jan '15 15:20 Post subject: |
|
|
No i use no third party software i use just what windows gives us in the first place.
In your PHP.INI set it to be syslog.
Then in windows via search bar type "Event Viewer" or via run command "eventvwr"
Click the Windows Logs tab and all PHP errors outputs debugging you set etc will be on the "Application tab"
The event viewer tab has a max limit of 20mb or something unless you change it so it saves you having to purge a error log using the syslog since the syslog overwrites old logs and keeps it purged for you.
I don't know if Nginx uses syslog or not i dont think it does would be a fantastic feature for Nginx on Windows to write its outputs to the Event Viewer like PHP does.
I hope you also check on the exsisting extensions i mentioned in this post if you try using clip bucket what is free i am sure it will get you started.
https://www.apachelounge.com/viewtopic.php?p=29556#29556 |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Mon 12 Jan '15 12:23 Post subject: |
|
|
After playing with syslog I come to conclusion that I need to implement a job queue. Log parsing is just a substitute for a job queues and is not a robust solution for task processing.
And until PCNTL extension or equivalent is implemented on windows all job controls will be nothing else but a bunch of hacks. |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Mon 12 Jan '15 13:53 Post subject: |
|
|
jimski wrote: | After playing with syslog I come to conclusion that I need to implement a job queue. Log parsing is just a substitute for a job queues and is not a robust solution for task processing.
And until PCNTL extension or equivalent is implemented on windows all job controls will be nothing else but a bunch of hacks. |
I never said to use the event viewer for a job que your original question was how to see what media item id was currently converting so just write the currently converting ID into the error or system log aka event viewer.
Before you go any further just download a exsisting component look at how they do it and you will understand so much so quickly rather than trying to do this in such a complicated manner. I have given you the links not much more i can tell you if you dont wish to look at the tools and code i already provided you with there will be no helping you.
My job que is writen in PHP and already exsisting as a part of the HWDMediaShare extension but you can download clipbucket what also already has one and they all work with both windows and linux.
You dont need any hacks to windows or third party extensions thats like downloading drupal and joomla and because one does not do what you want it to do you think mixing their files into eachother will make it function (droomla).
Download look at clipbucket since it is free the other two are paid but clipbucket is free and has a job que works on windows it will help you out allot and you will see how much time you have been wasting with the method your currently using. (No hacks needed) https://www.apachelounge.com/viewtopic.php?p=29556#29556
Direct download (Clipbucket) : http://sourceforge.net/projects/clipbucket/files/?source=navbar
https://downloads.sourceforge.net/project/clipbucket/ClipBucket%20v2/clipbucket-2.6-r738-security-fixed.zip
Also if you realy want a custom build component/extension and do not have the skills to do it yourself you can hire and pay a few hundred dollars/pounds what ever your currency is for them to do build you it on your servers or OS.
https://www.elance.com/category/web-development
When i need work done that is to much of complex task i post it at www.joomlancers.com but thats because i only use Joomla but it solves the problem.
You server setups and configs will always be down to you but you are asking PHP related questions what means you need a PHP developer. |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Mon 12 Jan '15 15:46 Post subject: |
|
|
C0nw0nk wrote: | I never said to use the event viewer for a job que your original question was how to see what media item id was currently converting so just write the currently converting ID into the error or system log aka event viewer. |
Hey C0nw0nk, I appreciate your help. My comment was not a criticism of your suggestion but just a frustration with windows. You have obviously put a lot of thought into your application.
C0nw0nk wrote: | You dont need any hacks to windows or third party extensions thats like downloading drupal and joomla... |
Using syslog does not give me the ffmpeg process ID but a php-cgi.exe process ID, unless I'm missing something?
Also comparing to Linux using syslog to get a process ID is already a hack in itself. On Linux I can accomplish what I need in just a simple step.
http://stackoverflow.com/questions/16612838/php-exec-or-shell-exec-not-returning-process-id-pid-on-windows-wamp
I found a solution which involves using PSTools but this is another app in the middle and another hack.
http://stackoverflow.com/questions/3679663/how-to-get-pid-from-php-function-exec-in-windows
As far as links that you recommended I will definitely explore them along with the open source queue projects.
The first glance at the code of ClipBucket tells me that they are using simple exec() and they don't process videos using a queue. This may be OK for a small or medium multimedia site but it will not scale very well.
A well implemented job queue will allow me to process videos at specified time intervals or specific times of a day when the server load is low and will also allow me to assign video tasks to specific servers based on a server load and thus it will scale great. |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Mon 12 Jan '15 19:54 Post subject: |
|
|
Well my method works with no core hacks i have no clue on what way you are trying to do things in your app it is as simple as this.
$id This would be the id of the media item you are currently converting or grabbed with your script or cronjob to start your conversion in the first place.
Code: |
error_log(($id,TRUE)); |
Just tell php to log the current ID that you just grabbed for conversion or file name or what ever it is you do in your php script to the system log or your error log. I have no idea why you are choosing to do things in such a complicated manner and you want to compare a windows multimedia setup to linux ?
For me it is flawless and i use the exec function but i run everything via cronjobs not by letting php automaticly start converting the file as soon as it is uploaded to the site that is a bad idea because lets say you have 100 uploads from different users at once you then have 100 ffmpeg processes running all at once you need to limit things to be in a que but to run one at a time so it has to be done via a cronjob.
I cant show you mysetup for a few obvious reasons but i can only try and guide you like i said i used to use clipbucket i only use HWDMediaShare now clipbucket was just a code example so you can see command lines of ffmpeg and see how they get their processes to run etc. Clipbucket might even have a cronjob process if you look that allows you to disable automatic conversions and let the server process media as it sees fit.
You need to be top of your game if you want to get into multimedia industry you will encounter allot of unique issues and I/O usage will affect you realy badly you need decent hardware for this and Windows is only suitable for you if you know how to get it to function for high traffic applications. Currently i host about 1/4 of petabyte of data (porn) and i my bandwidth output is far more than your average site.
Read this.
http://www.extremetech.com/computing/123929-just-how-big-are-porn-sites
There is only one big porn site on windows in competition with one of my sites owned by the pornhub network. (spankwire built on IIS with ASP.NET) Mine is Built on Windows Nginx with PHP Thanks to Jan-E and ng4win for that.
You need allot of bandwidth virtual networks and a few load balancers you should try building your application to work first before you try jumping in deep once you get your application to function then start worrying about multiple processes and job ques and using virtual racks networks shared hard drives etc.
Use what already exsists and build upon it perfect it use it as examples to make your site have some kind of foundation. Right now your trying to build a house on water you will sink everytime without knowing what or how you are going to achieve the task at hand.
Build your app or use a exsisting app then try going advance you are trying to build a job que to process media without a functioning application that can accept uploads or convert a single process on its own it seems.
Also the biggest thing about windows is you need to do a RAID 6 Setup if you want to support more than 2TB of data Windows has a max hard drive size of 2TB so with a Raid 6 setup you can mount create and format a virtual disk drive that can be as big as you like with a RAID 6 setup Z drive and with your C drive that would be your OS it would be Raid 1 setup mirroring eachother. With my Raid 6 setups i can have as much disk space on windows as i wish and when 6TB hard drives and SSD's Larger than 1TB getting cheaper and cheaper it makes storage such a easy task.
http://support.microsoft.com/kb/2581408 |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Tue 13 Jan '15 8:07 Post subject: |
|
|
C0nw0nk wrote: |
I never said to use the event viewer for a job que your original question was how to see what media item id was currently converting so just write the currently converting ID into the error or system log aka event viewer. |
This is not what I asked. My original question was:
..how do you deal with cases when ffmpeg process hangs. How do you track it and shut it down.
The "media item id" is not the ffmpeg PID.
C0nw0nk wrote: |
error_log(($id,TRUE));
|
This doesn't tell me what is the PID of the ffmpeg process that is currently converting the file, unless you fetched that PID beforehand. And as I explained getting that PID on windows is a major hassle. Using cron command line batch for video conversion doesn't solve the problem of tracking and killing hanged ffmpeg processes.
C0nw0nk wrote: |
Use what already exsists and build upon it perfect it use it as examples to make your site have some kind of foundation. Right now your trying to build a house on water you will sink everytime without knowing what or how you are going to achieve the task at hand.
Build your app or use a exsisting app then try going advance you are trying to build a job que to process media without a functioning application that can accept uploads or convert a single process on its own it seems. |
I'm not building on water but on the experiences I have gained from operating a dating website with 120,000 users. And although that site is not doing video conversions, I have learned many lessons about using the so called "existing solutions" (often written in India or Pakistan such as ClipBucket) without thinking them through. My experience tells me that doing any batch conversions without a job queue is not the best approach for scalability and performance. Keep in mind that what you are doing by using cron jobs and database to track the video conversions is really a substitute for a job processing queue.
PS. Obamace website was written using Indian contractors .
http://swampland.time.com/2013/10/24/traffic-didnt-crash-the-obamacare-site-alone-bad-coding-did-too/
Last edited by jimski on Tue 13 Jan '15 10:29; edited 12 times in total |
|
Back to top |
|
Jan-E
Joined: 09 Mar 2012 Posts: 1266 Location: Amsterdam, NL, EU
|
Posted: Tue 13 Jan '15 9:36 Post subject: |
|
|
With a little intelligence you can know if an instance of ffmpeg is hanging. You can use Sysinternal's PsList to find out how long ffmpeg is running ('Elapsed Time'). Depending on the length of your videos any ffmpeg that is running longer than, say, one hour is stuck.
http://technet.microsoft.com/en-us/sysinternals/bb896682
Just run 'pslist ffmpeg'. You don't even need the detailed view.
If you know the name of the source file, 'handle' will tell you which pid has that file open.
http://technet.microsoft.com/en-us/sysinternals/bb896655 |
|
Back to top |
|
jimski

Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Tue 13 Jan '15 9:51 Post subject: |
|
|
Thanks Jan-E, this is just the silver bullet for ffmpeg vampire that I needed. |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Tue 13 Jan '15 13:57 Post subject: |
|
|
You dont even need that using preg_match from php ffmpeg outputs all its data to a console if you have launched it via php's exec, You can know if ffmpeg has stopped responding via the fact that it stops outputting data to the console i have never encounterd this though i have encounterd corrupt uploads that have caused some strange behavior but never ffmpeg crashes.
Do you know how to read outputs of external programs with PHP you should look into it. If it stops outputting data then you know it is frozen most likely i have never had this issue and i accept uploads of 2gb in size some videos even 10hours long that take more than 8hours to convert just for a single video.
If you are logging your outputs to mysql you need to increase a few mysql timeout values since mysql will close a connection after 8 hours causing problems and mysql also has a max packet size. You cant run on default values of configs everything needs changing up. Increase your PHP execution times too it may help and if your using Nginx set a limit to download speeds of files.
Like i said mysetup is a non dependant on third party app's as possible so non dependant all i need is to install ffmpeg imagick php and nginx and the site can run on any machine.
I think with that program you will end up having to read the outputs of that program with PHP instead of FFMPEG so why not just read ffmpeg's outputs first and see if it stops on a certain frame for longer than a certain period of time. Are you using the latest version of ffmpeg ? |
|
Back to top |
|
Jan-E
Joined: 09 Mar 2012 Posts: 1266 Location: Amsterdam, NL, EU
|
Posted: Tue 13 Jan '15 14:36 Post subject: |
|
|
C0nw0nk wrote: | You dont even need that using preg_match from php ffmpeg outputs all its data to a console if you have launched it via php's exec, You can know if ffmpeg has stopped responding via the fact that it stops outputting data to the console i have never encounterd this though i have encounterd corrupt uploads that have caused some strange behavior but never ffmpeg crashes. |
You are right that FFmpeg never crashes. I have never heared about that in over 30.000 conversions of 1-2 hour videos. My setup is a little bit different, because my users transcode the video (to about 400*300) before uploading it to our servers. If it happened frequently I surely would have known it.
However, suppose that your PHP program does not receive any console output anymore, how would you kill ffmpeg? What happens at the moment that PHP reaches the execution time-out? How high is your time-out anyway? |
|
Back to top |
|
C0nw0nk
Joined: 07 Oct 2013 Posts: 241 Location: United Kingdom, London
|
Posted: Tue 13 Jan '15 15:15 Post subject: |
|
|
My PHP Timeouts are actualy default because when you run PHP via cronjobs (cli) like i do the timeout value automaticly becomes 0 or -1 meaning it will only close the php process once the conversion is complete etc. (So when ffmpeg closes or stops running.)
http://php.net/manual/en/info.configuration.php#ini.max-execution-time
I only convert data via the cli.
As of mysql i did have to go overkill in this area because mysql closes connections after 8hours. And with 10hour long videos and more they can take a few days in some HD especialy WebM qualities to convert.
(Mysql timeout of current connection raised from default 8 hour to 2 days.)
Code: | wait_timeout=172800
interactive_timeout=172800
max_allowed_packet=100M |
Max allowed packet for mysql because i log all my ffmpeg outputs to my mysql server depending how large or how many frames the video has to it means you end up needing a bigger max packet than the default or you will get mysql connection errors and even though your video will convert it may effect your script writting or changing data in your mysql tables.
I will also add i use InnoDB because i find MyISAM to be unstable and unreliable when writing data very fast or it changes quickly MyISAM tables tend to crash or corrupt themselves.
Currently i just use preg_match to see what ffmpeg is actualy upto aslong as it is still outputting some form of data every lets say 60mins you know it is still converting.
If you like Jan-E i will share a avi upload i recieved to my servers that was corrupt as of the contents of the file i dont know what they are this file does not open in VLC or any media player i have not had time to test it but this file did cause my ffmpeg to crash what was so unique.
So here was my fix.
At the start of every video conversion i always use "-i" to get the information output of the file ffmpeg is about to convert. Now the maximum number of attempts on a file is 5. Also every time the cli.php runs it is limited to convert a maximum of 50 media items or 50 videos then close.
So getting the -i output marks the attempt number as 1. (If it was not for this the conversion process would be looping since the video was crashing ffmpeg.)
when my cli.php process sees that ffmpeg is closed it assumes that the process is complete so it goes onto the next process but with this upload if it was not for me marking information outputs as a single attempt my servers would be stuck in a infinite loop trying to convert the same media item.
I dont know what the contents of this file is since i have not botherd looking into it a warning in advance is on my servers they do process adult material so there is a high prossibility it could be porn.
http://demo.ovh.eu/en/3169956bdaa9d57e39e22e4c9161011f/ |
|
Back to top |
|
Jan-E
Joined: 09 Mar 2012 Posts: 1266 Location: Amsterdam, NL, EU
|
Posted: Tue 13 Jan '15 15:47 Post subject: |
|
|
C0nw0nk wrote: | I dont know what the contents of this file is since i have not botherd looking into it a warning in advance is on my servers they do process adult material so there is a high prossibility it could be porn.
http://demo.ovh.eu/en/3169956bdaa9d57e39e22e4c9161011f/ |
It plays more or less in my GOM player. Very low qaulity. Seems like XVID(GVC) video and MP3 audio.
*** DIRECTSHOW FILTER LIST ***
1. Default DirectSound Device
2. VMR9 - Renderless mode
3. Gretech Audio
4. Gretech Video
5. MP3 Decoder DMO
6. Gretech Avi Source
*** VIDEO INFO ***
Input Type : XVID(GVC)
Input Size : 768 x 576
Output Type : YV12
Output Size : 768 x 576
FrameRate(Frame/sec) : 0.00 (25.00)
*** AUDIO INFO ***
SampleRate(Sample/sec) : 44100
BitRate(Bit/sample) : 16
Channels : 2
KBitRate(KBit/sec) : 320 |
|
Back to top |
|