Video codec .MOV file failing in firefox and chrome when not MP4 encoded

If you can execute a script after a video upload, you can use that one-liner above, but you have to output to a temp file, delete the original, then rename/move the temp to the original location. In php, you can execute shell commands like:

exec("timeout -s SIGKILL 60 ffmpeg -y -i " .  $originalVideoPath  . " -c:v libx264 -strict -2 -movflags +faststart -loglevel quiet -threads 2 " . $tempName . " > /dev/null 2>&1");

I copied and pasted this from a production app I have. So I also make use of ā€œtimeout -s SIGKILL 60ā€ in the event it takes more than 60 seconds to process a video, it just kills the processing so it doesnā€™t run forever. If someone uploads a literal 4k movie, that will happen. The ā€œ-movflags +faststartā€ generates a preview thumbnail for the video if it doesnā€™t exist. You may have seen videos that are black frames with no preview, this fixes that. the -threads 2 limits amount of compute power to use, you donā€™t want 100% and then > /dev/null 2>&1 sends output to the trash instead of printing it.

And then after that runs, you can move, rename and delete the two videos accordingly using filexists() to see if a temp video was made.

Hope this helps, there may be drawbacks that prevent you from going this route.

4 Likes

I guess thatā€™ll give me some reading to do

1 Like

I have an iPhoneā€¦it does what it wants. :person_shrugging:t4:

2 Likes

The amount of money you paid for that damn thing it should code the video on whatever codex you want! But appleā€¦ It only took 6 months owning the 4S when they first came out to help me realize that I hate apple, and their products. Like the iPad is the only thing I would ever buy, and only for artwork. They have great programs for those with artistic intent, but you can find that in most things these daysā€¦

Sorry, I just hate apple! I remember itunes trying to charge me to update an appā€¦ I sold the I phone the next day

2 Likes

Agreed took me about 5min I realized I donā€™t want iphone