MP4 / H264 Errors in Adobe Premiere Pro / Media Encoder / MainConcept

I’ve been editing together a few gameplay videos recently (eg DayZ Tread Lightly).I came across a rather perplexing error when trying to encode a long video. Basically, I have a few sequences of footage taken with FRAPS that together run to about 2 hours and 45 minutes. I created a project for these to run together as a reference for what a typical DayZ session might look like. I also produced a highlights version which is about 1 hour and 8 minutes long. After the latter, the oddness began.

The first uncut set of footage encoded without issues, coming at around 20GB at a high bitrate. The upload of this to YouTube failed after 40 hours, so I decided to re-encode at a slightly saner bitrate and put in a fancy title rather than the overlaid title cards. Before queuing that to encode, I finished off the highlights video, which has sections sped up (between ~800-1700%) to get rid of the boring stuff. Heres where the encoding problems began.

Encoding the highlights clip took much longer than expected, and it seemed to encode further than the 1hr 8min mark up to 2 hr 45 mins (the uncut length). Subsequently, the encoding of the sightly-modified uncut video produced a file that wouldn’t play. Trying various permutations of codec settings wouldnt produce playable files. None of VLC, ffmpeg or medinfo could identify the problem videos.

Producing short clips (eg a 2 minute sample) from either video worked fine, so I split the highlights video into 10-minute segments to see if there was a problem in a section of the timeline. All segments encoded normally, which was a surprise. What was a bigger surprise was that using Premiere to concatenate those clips failed with a similar problem!

At that stage I gave up on getting these videos to work in Premiere. Other videos, eg my Lets Play of FTL worked fine in the interim. Im now using a frameserver to serve videos to MeGUI to encode using x264. Details will hopefully follow if it works.

ScribeFire’s Arrow Keys Don’t Work

This post is composed within ScribeFire, the blogging extension thing for Frirefox (et al). And I can’t edit posts easily because using the arrow keys causes a blank javascript:; to fire. Bloody useless. Searching for solutions gets a lot of complaints (eg this chap), but not much at the root of the matter.

A workaround is to edit in plain mode. Solution to be posted if I find one.

Update: Turns out trying to post a video to a tumblr blog froze up ScribeFire real good. This doesn’t help with the original problem, it’s just more fuel for the (Scribe)Fire.

Update 2: Arrow keys work in rich text editor when I install ScribeFire as an addon for my Portable Firefox install (for Windows, arrow key troubles are under Linux). There are certainly a few issues raised on the posting for the last release, dated November 2011 (!)

Project Euler Problem 11

Just a hint, so you don’t go down the wrong path. You probably won’t, but if you don’t want any hints, stop reading this article!

PS If you don’t know what Project Euler is, I recommend having a look at their website, or just getting an idea from the problems themselves.

What is Project Euler?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

Now problem / puzzle 11:

In the 2020 grid below, four numbers along a diagonal line have been marked in red.

(snip)

The product of these numbers is 26 63 78 14 = 1788696.

What is the greatest product of four adjacent numbers in any direction (up, down, left, right, or diagonally) in the 2020 grid?

Just a hint for those of you who spent too long on this like me: it’s essentially a word search. One of these but with numbers.

You see, when I got the wrong answer a couple times I reread the question, and figure “adjacent” just meant anywhere beside each other – eg a square of four numbers, a t-shape. This is not the case! You don’t need to develop a path-finding bot that navigates 4 numbers, looking for the best options! Although, having done that, it’s actually quite fun! In python, at least, it’s quite concise and the code is pretty-looking.

Bonus points (or a packet of chocolate-coated raisins) to the first person who does implement such an algorithm. The answer I’m looking for is the highest product of the resulting 4 numbers, and leave it in the comments.

Bet I won’t get an answer!

Extract A Single Image From A Video Using FFMPEG

Update: Still using this 8 years later, but in the form of a quick script, which is useful if you are doing it more than once

Dead handy, this:

ffmpeg -ss 0.5 -i inputfile.mp4 -t 1 -s 480x300 -f image2 imagefile.jpg

The various options:

  • -vframes 1: limit to 1 frame extracted
  • -ss 0.5: point of movie to extract from (ie seek to 0.5 seconds; you can also use HH:MM:SS.ZZZZ sexagesimal format)
  • -s 480x300: frame size of image to output (image resized to fit dimensions)
  • -f image2: forces format

I use this to generate preview stills for jwplayer to use. Dead handy!

Edit: Thanks to DieBagger who pointed out it is much faster to place the seek argument before the input file, and Matthias his point about the seek time.

Ubuntu 9.10 Karmic Upgrade Problem Fixed (mountall/init)

(Jump to the bonus section on sorting a removed Gnome panel)

I finally got round to doing the Jaunty->Karmic upgrade on a troublesome machine. Well, re-doing. I made an abortive attempt to install it on this particular exhibit of electronic arthritis back before I left for Barcelona, which ended in me reinstalling 9.04.

Anyway, for one reason or another the upgrade failed or was interrupted and so I was left with a machine that would not boot. Well, it would do a good chunk of the boot process, but fail at an init item (init_bottom, I think). mountall was exiting with code 127, complaining:

process mountall (787) exited with code 127:
undefined symbol: udev_monitor_filter_add_match_subsystem_devtype
*

Quite a mouthful, in other words. Even booting into “recovery mode” didn’t give me a working console. Next step: try a liveCD. The same problem was reported by niroht of the ubutuforums here. However, his explanation is a bit brief, and misses out a couple gotchas.

So, you’ve got a problem with mountall, and you’ve also got a 9.10 liveCD. Here’s how to sort it:

  1. Boot from the livecd
  2. Call up a terminal (gnome-terminal or xterm).
  3. Chroot your usual install partition. GParted, under “Administration” can help you determine what this is. Mine was /dev/sda3. What I did was:
    • sudo su
    • mkdir /newroot
    • mount /newroot /dev/sda3
    • chroot /newroot <- chrooting my install parition
    • mount /proc <- important! not mounting /proc causes all sorts of problems.

    Now you’re chrooted and ready to continue. I have a separate /boot partition as well, but I updated this later to save faffing at this stage.

  4. Sort the botched upgrade! I ran first dpkg --configure -a, then to be sure, apt-get -f install. Finally, I ran apt-get dist-upgrade, which upgraded a *lot* of packages (~700 I think).

Now, if your /boot prtition resides on the same partition, you’re done here. If not, you have to mount it and copy the new kernel images and updated menu.lst. Strictly speaking, this should be possible to set up when doing the chroot above, but I couldn’t remember how to do it at the time. Make sure if you are merging the menu.lst that the contents are correct – check the UUIDs or partition references are correct!

Bonus! Restore the default gnome-panel if you accidentally delete

So once I was done with the fixed upgrade I booted, and got a slightly messed up top Gnome panel. Two volume icons, and no network icon. In my attempt to sort it, I clicked cack-handedly and removed the entire panel. Rather than repopulate it manually, I followed the advice of another ubuntuforums thread:

gconftool-2 --shutdown
rm -rf ~/.gconf/apps/panel
pkill gnome-panel

And that was the panel restored to default!

* (Previously listed as “undev_mknitor_filter_add_match_sebsystem_devtype”, as it appeared on the screen. Part of the electronic arthritis is (I think) in the graphics card, which causes all sorts of odd things to happen to the pre-boot text. Must photo it sometime.)

Installing Debian on QEMU

Since I decommissioned my home server in favour of an NSLU2 (a NAS), I’ve found myself without a Linux machine to much about with or develop on while on the go (well, whenever I can’t use my laptop). So instead I’ll be using a virtual machine by running QEMU from my USB drive. Since my old server ran Debian, and since I haven’t checked it out in a while other than using it’s offspring Ubuntu.

Note: I would recommend getting this set up running on a folder on your hard drive, then copying it to your USB drive if you intend to do that. It will probably be faster, and it will save you trouble if your disk image isn’t large enough.

To get a QEMU binary for Windows, you can download from here, although this is no longer outdated and uses the 0.9.0 release. Unzip it wherever.

Open up a command prompt. cd to the QEMU directory. Create two disk images by running:

qemu-img create -f qcow2 debian.img 1024M .

qemu-img create -f qcow2 home.img 1024M .

This creates two 1024Mb sized qcow images for you to work with – one for your system and applications, and one for your home directory(ies). Obviously you can change the name and size to suit. My USB drive is 4Gb – if you have something smaller like 2Gb, use 768M for debian.img and 512M for home.img. If you have a 1Gb drive, you could try smaller sizes, but you’d probably have more luck trying something like DSL (Damn Small Linux) or puppylinux. I originally tried this with a cumulative 512M for the root and swap partitions, and it wasn’t large enough.

Grab a Debian CD image. I would recommend one of the netinst images. I’m using the Lenny Beta 2 image (here, or the .torrent), but you can use a stable image, or one of the weekly / daily snapshots. Put the image in the same directory as QEMU.

Create a file debian.bat, with the command:

qemu.exe -net user,vlan=1 -net nic,model=rtl8139,vlan=1 -L . -m 128 -hda debian.img -hdb home.img -cdrom debian-LennyBeta2-i386-netinst.iso -boot d -soundhw all -localtime

You can change the -m option for more or less virtual RAM, you can leave out the model=rtl8139 to use the default ne2k driver (I just like Realteks, even virtual ones ;-)), and obviously change the -cdrom option if you use a different image. You can also use Kqemu, but I’m not going to go into that.

Additionally, you can use the command -M isapc (ISA network card), but for that you will have to remove the model=rtl8139; and before using the installer, press [TAB] and add noacpi nolacpi to the installer startup options, otherwise QEMU will crash.

Debian can then be installed as normal. I didn’t install anything that depends on X as I don’t want a graphical system, thought QEMU should handle it fine if you do. I used the partition manager to create a swap partition of about 128 megs. Mount your second ‘hard drive’ (home.img) under “/home”. if you don’t do this now you can do it later by editing /etc/fstab.

(My second disk image / hard drive is mounted as:

/dev/hdb1 	 /home   	 ext3   	 errors=remount-ro   	 0   	 1

)

Depending on the CPU of your host machine, whether or not you are using Kqemu, and the speed of your internet connection it will take anywhere from 10 minutes to two hours to install.

Once installed you can apt-get install build-essential, or apt-get install nethack, or apt-get install python, or whatever floats your boat. Or, if you’re like me, you can faff about trying to enlarge your partitions because they aren’t big enough.

Installing / Replacing Flash Plugin in Firefox Portable

I was recently playing a game called Spin the Black Circle, a gravity-based game where you manoevre a ball through a series of hazards by rotating the environment the ball is in. It’s kind of Crystal Maze-y, without Patrick O’Brien playing a harmonica at you. Anyway, I went to play it on my Firefox portable install, and the game got stuck in a neverending rapid loop on the menu. So I figure upgrading the flash plugin was the way to go – I’d been using the same one since an early FF 2 portable install.

The install procedure was fairly straightfoward:

  1. Get NPSWF32.dll and (optionally I think) flashplayer.xpt (I have these in a zip file)
  2. Extract to FirefoxPortable/App/firefox/plugins
  3. Delete any old NPSWF32.dll s
  4. Enjoy!

That fixed the looping in the menu of the game. For reference, I think my old version was either 7 or 8.

Firefox Beta 3

As a PortableApps Firefox user, I downloaded Beta 3 of Firefox 3. It’s pretty slick looking, and there’s a whole host of new features. I don’t like the lack of ‘go’ or ‘->’ at the end of the address bar which was useful for refreshing a page without re-POSTing, and the new location of thehome button will take some getting used to, but it looks pretty good so far!

Check it out and report back any issues to the developers.

Stretch Your Mind: Planarity

Planarity

“Arrange the vertices such that no edges overlap”

Planarity is a game that is simple in concept, but will have your visual processing areas tying themselves in knots. All you have to do is rearrange a bunch of vertices so that none overlap (creating a planar graph). It starts off simple but gets complex very quickly.

Edit: Duh. Forgot to include a link in the original post.

Wasn’t too many levels before I was hopelessly tangled…