Adventures In Adding Large Video Files In WordPress
Adding video to WordPress seems easy, right?
Why am I writing this post? Because if you have followed this blog for a while, you know I like not only passing what I’ve learned along to up and coming web developers, but I use this as a reference sometimes. I recently completed a freelance project that involved moving very large video files into a new WordPress install, and I came across multiple problems that were hard to find answers to. Adding video looks like it would be easy, right? Just click that little Upload/Insert button, drag/drop the file onto the page, and BAM! Video file is in the media library. What could POSSIBLY go wrong? I’ll start with the background to the project, and go over how I solved the issue.
Transfer a WordPress blog please!
It all started with an email from my website asking if I could transfer his WP blog from wordpress.com, to a self hosted WP install. The site’s main feature was the video clips on the site. If I couldn’t get the video over, then it was a no go. After some chatting, the client asked if I could honestly tell him if wordpress.com’s guided transfer was something he should look at, since it was cheaper than what I was charging. I told him that I have no idea, as I don’t know anyone that had paid for that. Blah, blah, blah….I got the job, and started transferring his blog over.
It always seems easy in the beginning
As it turns out, getting the data out of a WP.com hosted site is pretty damn easy. Under tools, they have a nifty little Export option, that will download an xml file for you. At that point, everything was going well. Wow, got the file, now how do I get it into a self hosted WP site? Simple, install the WordPress Importer plugin. It easily imports the data file into the new install! You click import, and then use the WordPress option. That is about as far as I got without any problems, because there is a checkbox asking if you want to import all of the media files attached to the data. Why the hell wouldn’t I want to do that? This seemed like a dream come true! I would be done with this little project in a couple of hours! So I checked the box and clicked import…
And the shit hit the fan.
What do you mean memory limit?
I kid you not, five seconds into the import and I got an error saying “Fatal error: Allowed memory size of …”. What? Google then tells me it is because the memory limit in the host’s php.ini file is set at 64Megs, all I have to do is ask my host to increase it. Soooo, I get the host (hostgator by the way – and they do indeed rock) to increase my limit temporarily after I explain what I was trying to do. THANK YOU! So they tell me, try again, which I do. Unfortunately this produces the same error. They then increase it to 300 and something for me, import again, and same error. At which point he asks me how large the video files are.
I didn’t really look, which was my fault. I did now though, and to my astonishment, the first file it is trying to import is a massive 687 megs. HOLY @#$%! That is huge. After a while, I realize this isn’t going to work. Quick thinking on my part, I say “Jeremy, why don’t we try using the file manager and upload them through the host itself?” Quick, yes. Stupid? Yes. I should have skipped this step, but don’t worry, I quickly found out why that was not going to work. Unfortunately it made me assume something that wasn’t true. The host’s file manager has a 500Mg single file limit, but I didn’t find that out until I had tried uploading the file though, which took about ten minutes.
Let’s look at a different approach
This is where I called the client and told him, this is probably not the best way to do video. Let’s look at hosting them on YouTube? WordPress has a very easy way of getting video from YouTube into a post. Looking into at first brought a smile to my face. YouTube’s limit for a single file is one gig. Awesome, none of the video is larger than that. Oh, but wait…how long are these videos minutes wise? See, YouTube limits it to 15 minutes. Some of these videos are over twenty. No good there, and after a brief conversation the client concludes that he doesn’t want to cut the videos up. Fine. Back to the drawing board.
Determination wins the day
At that point, I was up for trying anything. Enter FileZilla, which I should have done right from the start. I uploaded the videos into WordPress’ uploads folder, fully expecting it to die when it hit the 500 mark. To my astonishment though, it went through. All the way. Why? No idea. The host’s file manager has a limit, but using ftp didn’t. I was happy though because now I got the video up on the server.
I then login to WordPress, go to the media library, and….nothing is there. Shiznit. More searching with Google, and I find that there is a plugin called Add From Server. This little thing takes files you uploaded onto the server, and places them into the library for you. That was what I needed. I puts a nice little button in the Media tab that says Add From Server, and a list of all the files shows up when you click it. You then check all the boxes of the files you want in the library, and it moves them over for you. I was then free to insert them into the post at will!
Why was this so hard to figure out? Because apparently not many people have uploaded files this large into WordPress. I found tons on uploading 4Meg files, but nothing in the 500+ range. Google didn’t help me there. Large video files like that are not the best way of handling things, but I had to figure out how to do it. Doing that again would only take me a couple of hours total, but because I had never done it, and most others haven’t either made the process a bitch.
Wondering how the client got his files up on WP.com? Easy…he paid for an extension called Video Press that allows you to upload large video files into WordPress. Hell if I could find the same kind of thing though for a self hosted version.
So, if you need to do something like this follow this guideline:
- Import the WP data file with the WordPress Importer plugin
- Don’t transfer the media if you have large files like what I talked about. Won’t happen.
- Install the Add From Server Plugin
- Use FileZilla, or other ftp software to upload the video
- Use the Add From Server button in the Media tab to import the video into the Media Library
- Insert the video into the post
NOTE: If you use FileZilla, make sure you have the most up-to-date version. I originally tried with an older one I had installed and it truncated the files by a few thousand bytes or so. The files were then unusable. Once I updated FileZilla to the current version, this stopped happening.