Can ffmpeg write comskip info into the video file?

I hacked something together quickly to do exactly this, and it seems to work fine (except I can’t find an easy way to skip to next chapter on Apple TV client),

#!/bin/sh

DIR=`mktemp -d`

/usr/local/bin/comskip -n --output=$DIR -v1 --zpchapter "$1"  

INPUTFILE=$DIR/*.chp
CHAPTERS=$DIR/chapters.txt
TEMPMKV=$DIR/merged.mkv

echo $INPUTFILE
if [ -s $INPUTFILE ]
then
	cat $INPUTFILE | perl /home/media/scripts/convert_chapters.pl > $CHAPTERS
	if [ -s $CHAPTERS ]
	then
		mkvmerge --chapters $CHAPTERS -o $TEMPMKV "$1"
		mv $TEMPMKV "$1"
	fi
fi

rm -rf $DIR

and then I have the convert_chapters.pl script looking something like this

#!/usr/bin/perl

use POSIX qw{strftime};

my $chapterno = 1;

while (<>) {
	my @words = split /^AddChapterBySecond\(([0-9]+),(.*)\)$/;
	if ($words[2] eq "Show Segment") { 
		printf "CHAPTER%02d=%s.000

“, $chapterno, strftime(”%H:%M:%S", gmtime($words[1]));
printf "CHAPTER%02dNAME=Commercial %d
", $chapterno, $chapterno;
$chapterno++;
}
}

it will basically create a chapter mark for the END of each detected commercial block.