3分割されている動画の連結

mp4動画の連結はmp4boxを使う
http://sada5.sakura.ne.jp/files/index.php?folder=TVA0Qm94


C:\bin\MP4Box_0.5.1-DEV-rev4280+44M-g0f0e3eb\win64>mp4box -add in1.mp4 -cat in2.mp4 -cat in3.mp4 -new out.mp4
[Win32] system failure for tmpfile(): 00000005
IsoMedia import in1.mp4 - track ID 1 - Video (size 320 x 240)
IsoMedia import in1.mp4 - track ID 2 - Audio (SR 22050 - 2 channels)
[Win32] system failure for tmpfile(): 00000005
Appending file in2.mp4
[Win32] system failure for tmpfile(): 00000005
Appending file in3.mp4
WARNING: Concatenating track ID 1 with different SPS - result file might be broken
Saving out.mp4: 0.500 secs Interleaving

ファイル名に日本語が入っているとエラーが出る


[Win32] system failure for tmpfile(): 00000005
Unknown input file type
Unknown input file type

コメントファイルの連結は以下のrubyスクリプトを使う。

ファイル1のXMLをxml1
ファイル2のXMLをxml2
ファイル3のXMLをxml3
ファイル1の時間を mm1:ss1
ファイル2の時間を mm2:ss2
とすると、


ruby xmlconn.rb xml1 xml2 xml3 mm1:ss1 mm2:ss2 > out.xml
と実行する。


#!ruby
require 'rexml/document'
include REXML
$max=900 # 各ファイル先頭の900個を抽出
$doc = nil
def xmlopen(path, offset)
if $doc == nil then
$doc = REXML::Document.new File.open(path)
else
c=1
doc2 = REXML::Document.new File.open(path)
doc2.elements.each("packet/chat") { |elem|
STDERR.print " #{c}\r"
c = c + 1
v = elem.attributes["vpos"].to_i
v += offset * 100
elem.attributes["vpos"] = v.to_s

$doc.root.insert_after("//packet/chat[last()]", elem)

if c > $max then
break
end
}
STDERR.print "\n"
end
end

if ARGV[3] =~ /(\d+):(\d+)/
tim1=$1.to_i * 60 + $2.to_i
else
tim1=ARGV[3].to_i
end
if ARGV[4] =~ /(\d+):(\d+)/
tim2=$1.to_i * 60 + $2.to_i
else
tim2=ARGV[3].to_i
end

xmlopen(ARGV[0], 0)
xmlopen(ARGV[1], tim1)
xmlopen(ARGV[2], tim1+tim2)
$doc.write