in Hacker School

Hacker School Day 10 – syslog, youtube-dl, webm

I spent Friday mostly working more on the youtube-gif-go project. I added logging after seeing that one of my test video URLs wasn’t converting and I couldn’t see why. My primary method of watching things before that was running redis-cli with the “MONITOR” command, along with some print statements in the various workers.

From this method I determined that the video chopper was failing. Its primary purpose is to take the downloaded video file and use mplayer to turn each frame into a PNG file. I had written down a todo for adding logging and this seemed like the perfect opportunity. Looking back, I should have just run the mplayer command by hand — the short of it was, youtube-dl had downloaded the video in .webm format, and mplayer didn’t know what to do with it.

Instead of that, I spent a long time debating between doing “local” logging or using syslog. I read some great articles on the pros and cons and asked around for input. I decided on syslog, and spent time being annoyed with the syslog package in Go. From what I understood, I could either have the logger returned by the NewLogger call, and have a fixed priority, or I could get a writer, with convenience functions to set the priority for me, but no variadic arguments (printf style). I ended up picking the writer with some ugly log statements for including variables. I’d love to be shown if there’s a better way.

I wanted these messages to only go to a specific file with youtube-gif-go messages. Then I twiddled /etc/rsyslog.conf to add the following lines:

# log youtube-gif-go in one place
:syslogtag, contains, “youtube-gif-go” /var/log/youtube-gif-go.log
& ~

The ‘ampersand tilde’ was important, since it’s extending the rule (&) and telling rsyslog to drop the message after sending it to /var/log/youtube-gif-go.log (~).

After all this I discovered that mplayer wasn’t able to decode the webm format. I checked avconv’s format list with avconv -formats, and sure enough:

  E webm            WebM file format

There was only an ‘E’, for avconv’s ability to encode in that format (the presence of a ‘D’ would have been what I needed). VP9 wasn’t in my codec list either. I modified the call to youtube-dl to prefer MP4 and FLV for now.

On the upside, I can post a URL to my endpoint and get a gif! Onto more exciting things!

Write a Comment

Comment