Handbrake can convert MTS files for Mac
So a while back we purchased a JVC Everio HD camcorder. I'll skip the commentary on whether or not that is a good idea. For me, the relevant issue is: how am I supposed to copy the MTS (AVCHD H.264) encoded files to my mac and get them in a format that I can import into iMovie and edit.
Here are a few things I discovered on my journey the last few months:
- VLC can play MTS files. I wasn't able to get the stream converter to export them properly to mov files though. Perhaps there is some setting I missed somewhere, but the formats I tried either had messed up audio or Quicktime couldn't open them.
- ffmpeg is probably a good option. I couldn't get it to work though. I had the same problems with it that I had with VLC. I couldn't seem to pick correct encodings to get the audio/video to stay in sync.
- iMovie can import video directly from the camera. If you plug the camera in and import the movies directly into iMovie, that works but you end up with mov files that are larger on your hard drive. Also, if you copy the camera drive in it's entirety to a dmg image, and then mount the dmg file, iMovie can pretend like that is a camera too, and still import the files. I didn't want this though since I didn't want to make dmg files every time I want to import and I didn't want to store mov files.
- Handbrake does the job nicely. You can queue up a bunch of files and choose a format to convert them too. I found converting to the preset Apple TV settings works pretty well for importing into iMovie.
Hope this helps someone. Skip all those ffmpeg front-end rip off programs that want to charge you money. They are GPL violating programs whose owners are attempting to make a quick buck off something you can (and should be able to) do for free.
git logk
Do you like gitk? I find it almost invaluable in merging, branching, looking at old revisions, diffs, etc. I find it annoying that git log is hard to glean the same information. I searched a round a bit and found that git log is quite configurable as to what it outputs. Here is a simple alias that outputs the log with some of the data you'd find by viewing gitk.
git config alias.logk 'log --graph --pretty=format:"%h %ae: %s" --decorate --abbrev-commit'
You can add --global so you don't have to make a logk alias for every repository.
You can also read the man page for "git log" and change the format to suite your liking.
Dual Master Git Repositories
One of the nice things about git, is the ability to work in a distributed manor. Instead of having to have a central repository for your source code, you can create a copy of your repository and do work, while sharing the changes, on any number of machines. Often, when a few developers share code, they still use git with a central repository. There isn't anything wrong with this, but sometimes, I find myself wanting to set something like this when I only want to share code between a couple computers where I am the only developer. In this case, I don't need 3 copies of the code. I want to be able to push or pull changes between each of the machines without having to push to a 3rd repository.
So, you might try the following steps:
# on the 1st machine > git init . > # make some code changes > git add ... > git commit
# 2nd machine > git clone <1st machine ref> > # make some changes > git commit > git push # here is the problem
When you push from the 2nd machine to the 1st, the HEAD on the 1st machine is updated. The problem is that your working copy is NOT updated. To fix this, there are two solutions.
Mediocre, recover from doing the push solution:
# warning, the following will destroy any local changes you had made. > git reset --hard HEAD
If you had made changes on the 1st machine and forgot to commit them, you'd need to stash them, check out to a branch, or whatever.
Better way, avoid the reset all together
# on the 2nd machine > git push origin master:refs/heads/tmp_branch_name
# on the 1st machine > git merge tmp_branch_name > git branch -d tmp_branch_name
Another solution would be to add a remote on the 1st machine that points to the 2nd machine. Then each machine can just pull from the other rather than doing any pushes at all.
Have fun.
Upgrading Gentoo 2007.0 to 10.0
So I left all these servers running gentoo a couple years ago. Now, after all this time (and uptime!), I want to install something.
Error:
emerge -av portage These are the packages that would be merged, in order: Calculating dependencies | !!! All ebuilds that could satisfy ">=dev-lang/python-2.5" have been masked. !!! One of the following masked packages is required to complete your request: - dev-lang/python-2.5.4-r3 (masked by: required EAPI -1, supported EAPI 0) - dev-lang/python-2.6.2-r1 (masked by: required EAPI -2, supported EAPI 0) - dev-lang/python-2.6.2-r2 (masked by: required EAPI -2, supported EAPI 0) - dev-lang/python-2.6.4 (masked by: required EAPI -2, supported EAPI 0) - dev-lang/python-3.1.1-r1 (masked by: required EAPI -2, supported EAPI 0) - dev-lang/python-2.6.3 (masked by: required EAPI -2, supported EAPI 0) For more information, see MASKED PACKAGES section in the emerge man page or refer to the Gentoo Handbook. (dependency required by "sys-apps/portage-2.1.6.13" [ebuild])
Hm. Yeah, I'm way out of date.
Solution: I found other sites that talked about forcing a python/portage install but I that sounded a little harsh. Instead, I found a snapshot of portage-2008.0 and replaced my /usr/portage with the contents of that.
cd /usr rm -rf portage # or mv portage xxx wget http://gentoo.mirrors.tds.net/gentoo/releases/snapshots/2008.0/portage-2008.0.tar.bz2 tar -xjpf portage-2008.0.tar.bz2 cd /etc/ rm make.profile ln -s /usr/portage/profiles/default/linux/x86/2008.0 make.profile emerge -av portage
That took me to portage-2.1.4.4.
From there, I can now go back to current 10.0 portage and emerge -av portage to get up to the current portage state.
Yeah, I really didn't want to do a re-install.
Cleaning up extracted package contents
I hate it when I download a source archive, uncompress it, and find that instead of creating a package directory, with the contents of the archive, the archive was created with a bunch of files at the root directory. Suppose I have a downloads directory with lots of archives. After I uncompress this new archive, I now have a bunch of archive files and a bunch of project specific files all in the same directory. Yuck.
> cd downloads > tar -xzf latestdownload.tar.gz > # yuck, stupid package contents in my downloads directory.
Yeah, Yeah, I know I could have listed the package contents (tar -tzf ..) and found that I needed to create a directory first but I'm lazy. So the mess is there. Now to clean it up:
> tar -tzf latestdownload.tar.gz | xargs rm -rf
There. Files gone. You can do the same thing with unzip -t for zip archives.
The Python install system needs an overhaul
Perhaps this is more of a rant than a useful blog post. I do plan on posting something useful though, so bear with me. First, a little background.
I've been working on installing a website based on Django for the last while. As part of the process, I wanted to bring in all the dependencies of my project with a setup.py file so I can easily move the site around to different development machines or server environments as needed. I wanted to make sure I didn't install different versions on a different machine, so I've provided a packages directory and install the file with the dependencies locked at specific versions and the packages directory noted. Easy install then just uses the package I place in the packages directory and every place I install this website, I get the same setup.
My setup.py snippets
setup ( # ... install_requires=[ 'Django=1.1', 'MySQL-Python==1.2.3c1', # etc ], dependency_links = [ 'packages' ], # ... )
So far so good. I should point out that some have suggested pip as a replacement to easy_install. For my rant portion of this post, both pip and easy_install don't offer any help. If I'm wrong about pip, somebody please point out the proper way to do this..
My problem begins when I find a package with no setup.py file. The package I'm attempting to use is the forum module from Sphene Community Tools. As I download and go through their documentation, I find that they pretty much expect you to just add the sphene package to your python path. That doesn't fit with my installable website model though so I want to add a simple setup.py file and install it with the rest of my packages.
Issues:
- Package Data
Turbogears contributers worked on a find_package_data function that can recursively add your package data. The fact that this isn't included yet in the distutils api is quite annoying. I copied the file from another project [1]. I also added '.svn' to the ignore directory list since I was building from the svn view.
- Extra Data
Just as annoying as the package data problem is the static data. I originally thought I could just include the static directory in data files like this:
data_files=[ ('static', findall('static') ]
That just puts every file recursively found in the static directory all in one static directory for the install. Instead, I modified the result returned by the find_package_data function to use the data_files format. Here is my completed setup.py file:
import os from setuptools import setup, find_packages from finddata import find_package_data packages=find_packages('sphenecoll') package_data=find_package_data('sphenecoll') static = find_package_data('static','sphene') # not in correct format static_dict={} # dir -> files for path in static['sphene']: dir, file = os.path.split(path) dir = os.path.join('static', dir ) files = static_dict.setdefault( dir, [] ) files.append(os.path.join('static',path)) setup( name='sphene', version='0.6dev', packages=packages, package_data=package_data, package_dir={'sphene':'sphenecoll/sphene'}, scripts=['dist/scripts/make-messages.py', 'dist/scripts/compile-all-sph-messages.py' ], data_files=static_dict.items() )
If someone else is interested, you can put finddata.py and this setup.py in the sphene/communitytools directory and build your own egg. Not really the point of this post, but perhaps someone will find it useful. Actually, the Sphene tools should be installable I think. The expectation to just put the directory in your PYTHONPATH isn't very flexible.
- Install from source
Both easy_install and pip didn't actually copy any of the package data or data files into the installed site-packages. I had to use setuptools bdist_egg and then installing the egg caused the files to be copied correctly.
- No uninstall
This one isn't really an issue with this install in particular, but it is always annoying.
Maybe one of these days some Python developer will come up with a good solution to the install mess. I'm too busy working on the projects I've got to get done aside form the occasional sidetrack that installing Python modules causes.
1: I copied paste.util.finddata http://trac.pythonpaste.org/pythonpaste/browser/Paste/trunk/paste/util/finddata.py