Lossless AVCHD Editing in Linux

Warning: the method outlined here still has bugs.

AVCHD video should be directly burned to 3xDVD, BD5, BD9 and Blu-ray disks without reencoding to obtain the best picture quality. A program like kino that can cut and paste AVCHD clips together without reencoding would allow simple editing and provide for a lossless workflow for authoring AVCHD content in Linux. This kind of workflow is also known as smart rendering.

Although the multi-threaded version of ffmpeg can smoothly play back AVCHD content on Linux, it would probably take more than a week of time for a professional programmer to use ffmpeg-mt to create a program like kino for lossless authoring of AVCHD source. To avoid cost and delay, I wrote a small program that converts kino xml files into a sequence of equivalent tsMuxeR meta files. This allows me to do cut and paste editing using DV proxy files in kino and then perform the same cut and paste operations with tsMuxeR on the original AVCHD source.

This workflow will yield results that are identical to having a program like kino which works directly with AVCHD clips. However, there are still bugs and the final AVCHD file is more of a mess than anything else in my tests. It appears the problem lies with how tsMuxeR cuts the video clips.

Needed Software

This method relies on the Linux open source software and the closed source free software

Installing k264mux

Download the source k264mux.tgz, compile and install it with
$ tar zxf k264mux.tgz
$ cd k264mux
$ make
# su
# cp k264mux /usr/local/bin
# exit
The help for k264mux is as follows
k264mux -- convert kino xml file to tsmuxer meta files
Version 1 August 2009 by Eric Olson GNU License.

Usage k264mux [options] filename.xml
where options are
        -p ext   Extension of the proxy files (dv)
        -s ext   Extension of the source files (m2ts)
        -h       Display this message.
Use -s mts for AVCHD files that were directly copied from the camcorder.

Editing with Kino

Create DV proxy files for each of your m2ts source files with
$ ffmpeg -i s001.m2ts -r 30000/1001 -acodec pcm_s16le \
    -vcodec dvvideo -interlace 0 -pix_fmt yuv411p -deinterlace \
    -s 720x480 -f dv -y s001.dv
Load the proxy files into kino. Cut them, paste then and delete parts of them until you are done editing. Save the kino project xml file. Do not use any transitions or filters. For transitions and filters refer to Editing AVCHD with Cinelerra.

Rendering with tsMuxeR

The program k264mux assumes that each proxy file YYYY.dv corresponds to an AVCHD source file YYYY.m2ts. The command
$ k264mux -sm2ts final.xml
will convert the final.xml to a sequence of meta files and run tsMuxeR on each of them. The output video final.ts is obtained by performing the same cut and paste operations on the original AVCHD source as specified by the xml file.

Further Notes

This is not a well tested workflow and there are still bugs.
Last Updated: Sun Mar 27 22:10:23 PDT 2011