FFMPEG and drawtext

Several years ago I wrote a program that consolidates time-lapse pictures into a directory and calls FFMPEG to create a video.

I had been wanting the time-code from when each picture was taken printed on the screen while the video was playing but had not figured out how to get it done until this weekend.

Video TimeCode

Frame from video showing the DateTimeOriginal timecode embedded.

I’d gone down multiple paths in an attempt to get this result before finally getting the drawtext feature to work. My program manually pulled the metadata from the images before feeding them to ffmpg. I’d tried creating both text files and image files for overlaying. none of those got the result that I was looking for.

When I finally got everything working, it seems simple, but the underlying problem has to do with the amount of string escaping required to get the command to work.

Here’s an example command I was issuing to ffmpeg that got the result I was looking for.

ffmpeg.exe -hide_banner -r 30 -i Wim%05d.JPG -vf crop=in_w:3/4*in_h,drawtext=fontfile=C\\:/WINDOWS/Fonts/OCRAEXT.ttf:fontcolor=white:fontsize=160:y=main_h-text_h-50:x=main_w-text_w-50:text=WimsWorld,drawtext=fontfile=C\\:/WINDOWS/Fonts/OCRAEXT.ttf:fontcolor=white:fontsize=160:y=main_h-text_h-50:x=50:text=%{metadata\\:DateTimeOriginal} -s 3840x2160 -pix_fmt yuv420p -n Test-2160p30-cropped.mp4

If you look at the -vf option parameter, I’m cropping my input pictures to 3/4 their original height, then using the drawtext feature twice. First I write the static text to the bottom right of the frame, then I extract metadata from the source image and write it to the bottom left of the frame.

Because I’m calling this from a program, I had extra escaping of the \ character in my code. All of the escaping required a lot of trial and error to get things working. I’m using OCRAEXT as my font, but I could be using any fixed spacing font. because of the fact that the time is changing every frame, it’s important that the font not be proportional to make it easy to read.

DJI Phantom and Wind

This week I took my drone to video Initial Point in Idaho. It’s a rocky outcrop about 20 miles south of Boise that was chosen as the initial survey point for the Idaho Territory in 1867. It has a concrete platform installed at the top with a survey marker embedded. There’s a rocky trail that can be driven to the top if your vehicle has a high ground clearance. I chose to walk to the top.

DCIM100MEDIADJI_0177.JPG

Initial Point Idaho

My car was parked at the base, I climbed up about 130 feet to the top. The wind was occasionally gusting at the base. It was constant at the top, with much higher gusts.

I carried the drone in my backpack to the top, and launched it from the platform. I manually flew it around the point, but was feeling extremely nervous doing so. I only flew about 36 feet above the platform during the entire flight.

The concrete platform has a metal railing surrounding it, and I didn’t trust the drone to return safely to land without hitting the railing so I manually had it land nearby. As I was hovering the drone before landing, it was holding a fairly constant 20° lean because of the wind.

After hiking back to my car I still had plenty of battery for another flight. From near my car I launched the drone and flew vertically to about 200 feet, centered the drone over the survey marker, and used the point of interest feature to create a video circling the point.

I don’t believe that the wind was any less on my second flight than it was on my first flight. The fact that I was in the wind on the first flight had me feeling significantly more nervous while flying than when I was out of the wind on the second flight. Watching the video from the first and second flight doesn’t appear significantly different. I would have liked the point of interest video slightly more if I’d been on top of the point the entire time, but I was too nervous to do it all while I was sitting in the wind myself.

Samsung UD590 working with Gigabyte GEFORCE GTX 660

In a previous post I mentioned that I was having problems making my new Samsung 4k UHD monitor work at full resolution.

Gigabyte GEFORCE GTX 660

Gigabyte GEFORCE GTX 660

I ordered a new Gigabyte GEFORCE GTX 660 video card from newegg, removed the old video card, and now have three monitors plugged directly into this video card.

ScreenResolution

 

My center monitor is the new Samsung display running at 3840×2160 on the display port, and the left and right monitors are each HP Pavillion 22bw monitors running 1920×1080 using the DVI ports. The one strange thing is that Windows recognizes the dot pitch on the Samsung monitor and attempts to make things larger than I’d like. It is a configuration option to make text larger or smaller by following the link on the screen resolution dialog and I have moved the slider one notch smaller from the center.

Display

Media Center Content Protection Error

I’ve noticed that I sometimes get errors in windows media center reporting that programs could not be recorded. This generally happens when I’ve left media center running full screen on one of my monitors overnight…

MediaCenterErrorThe strange thing is that if the media center application is not running, or is running in a window, the recording of the programs seems to work properly. I only get these errors coming up when the application is full screen on one of my monitors.

 

Samsung UD590 Monitor

I bought a Samsung UD590 monitor from Amazon and it arrived Saturday May 3rd. It’s native resolution is 3840×2160, which is twice 1920×1080 in each direction. It came with a single HDMI cable and a display-port cable.

Samsung UD590

I bought this for it’s resolution and price. It sells for $699. It claims to be able to run at 60hz input at full resolution, where some of the other monitors in this price range only run 30hz. The box advertises 1ms fast response time, but I’m not certain how that translates.

My previous monitor setup has had an HP Pavilion 22bw as a center monitor, the same as a right monitor, and an old Samsung SyncMaster 205BW monitor in portrait mode as a left monitor.

ASUS SabreToothMy machine is based on an Asus Sabretooth Z87 TUF motherboard. I’ve got an Intel® Core™ i7-4771 Processor running with 32GB ram. I’ve been running the center monitor from the embedded GPU using the HDMI output on the motherboard. I’ve got an old NVIDIA GeForce 8600GT based graphics card driving the left and right monitors via DVI ports. It is an ASUS EN8600 GT Silent card. I’m running windows 8.1.ASUS EN8600GT

I haven’t decided if I want to switch to just using this new monitor, or if I want to keep using the two HP monitors as left and right flanks. My initial test had me plugging the new monitor into the display port on the motherboard and having the HP monitors plugged in via DVI on the card.

When I booted the machine initially, I saw the EUFI screen from the motherboard correctly on the new monitor, the opening screens of windows booting on the new monitor, and then the monitor went blank and only the pretty backgrounds were visible on my monitors on the sides. Through a bunch of trial and error, I figured out that if I reduced the resolution on the Samsung in windows from 3840×2160 to 2560×1440 things worked without going blank. I went so far as to remove the NVIDIA card entirely to see if it was some sort of interaction, but that didn’t seem to help.

By total chance I found out that if I have a large amount of constant white space on the screen I can run the monitor at full resolution. If I’ve got an empty copy of Notepad filling the screen, then the screen runs fine at its native resolution. But if I load an app that throws any level of color complexity on the screen, it shows the image, then goes all black, and blinks the image up approximately one second out of ten.

I don’t understand if this problem is related to the monitor, or related to the motherboard output, or possibly even the cable. I’m using the cable that came with the monitor, so I’ve been discounting that. I’m assuming the problem has to do with the bandwidth of driving 3840×2160 at 32 bit color.

I don’t mind going out and buying a new display card to drive the monitor, but I’m not a gamer so don’t want to spend money for a top of the line gaming card when all that I want to do is drive high resolution and have a reasonable refresh rate for displaying video. Ideally a video card would be able to drive three monitors. I expect I’d drive the big monitor via display-port, and the secondary monitors via a display-port to DVI cable.

Any suggestions as to what exactly my problem is are useful.

GoPro Battery BacPac

I purchased a GoPro Battery BacPack recently because I realized that I’d rather have extended shooting than have two seperate batteries that needed to be charged. I had already purchased a second standard battery for the GoPro, but I didn’t have a way to charge it when it was not in the camera, so found it less useful than I was hoping.

The fact that I am most often using my GoPro in harsh conditions means that I’d rather not open the case any more frequently than I need to. When I’m skiing, if I go into the lodge to change the battery, the very first thing I notice is that the cold GoPro case is suddenly steamed over by the indoor humidity. 

When I’ve been doing my stop motion photography at a picture every two seconds, generally the standard battery lasts just under two hours. My first test with the BacPac attached started at 8:47am and the last picture was at 12:40, so it looks like It gets me to just under 4 hours total.

It created 6999 files in that time frame. I’ve not figured out if the GoPro uses any less battery when taking sequential still photos vs when it’s taking movies. 

Saturday’s race on Different Drummer wasn’t fully captured in the time allotted because we went out early and did some practice work flying the spinnaker.

Hopefully I’ll get around to writing more about what comes with the BacPac in the next couple of days. I was mostly interested in sharing the extension of the recording time.

Time Lapse Videos using FFMPEG

I’ve been creating time lapse videos using FFMPEG from the output of a GoPro camera since the beginning of summer. I have always been interested in the output but not had easy methods of creating them until recently.

I like the result best when I have the GoPro set to take one image every 5 seconds, and then I have FFMPEG create a default MP4 file at 25 frames per second. The standard GoPro battery seems to record just about two hours worth of full resolution images in my Hero 3+ Black, which works out to just about a minute of video.

My first video using this method was of the sunset over Elliott Bay taken through the window of the elevator waiting room where I live, on the 13th floor.

I’ve written a program that copies the default GoPro image file names to a sequence that starts with image number 0000 so that FFMPEG will recognize a starting sequence with the default globbing method.

An example command line I use to start FFMPEG is:

ffmpeg -i \\MyServer\Pictures\GoPro\Sunset2\Wim%04d.JPG \\MyServer\Pictures\GoPro\Sunset2\Sunset2.mp4

That command line will actually create a video that has a resolution of 4000×3000, which is the resolution I’m taking the individual pictures. I could have specified to FFMPEG to reshape the output, or trim it.

The second video I created using this method was of a sunrise in essentially the same location.

https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images has good examples of some of the options.

The most recent video was created after I purchased a suction cup mount for my GoPro. I went to the 17th floor and read a book during the hour before sunset.

Several things are apparent in this process.

  • I need a black out curtain surrounding the camera to block reflections when the light is directed at the camera. The camera has been positioned flush against the surface of the glass, but the thickness of the glass creates reflections inside the glass itself.
  • videos with weather are much more interesting than just the movement of the sun itself.
  • I have been turning on the WiFi in the camera to make sure I’ve positioned the camera correctly. I need to try turning off the WiFi to see how it affects the battery rundown length.
  • I need to change the picture frequency to a longer or short time-span to see if the battery life is affected at all.