忘備録

年をとると忘れやすくなる。過去、これからのことを書き綴る。

着うたフル奮闘記(#11)

2006-02-19 03:07:43 | Weblog
KMF作成あたり、一番肝心の3G2(HE-AAC)から始める。
HE-AACにエンコードするツールとして、WINAMP,HELIX,AACENC,Xenon2Pro等が
あるが、Xenon2Proのトライアル版は有効期限があるため単独での使用に留め
WINAMP,HELIX,AACENCを使ってみる。使用するにあたって基本的には各DLLを
直接コールするのがベターだが使用方法の解らない(公開されていない)為、
WINAMPの[enc_aacplus.dll]を直接利用、HELIXのproducer.exeをfrontend、
AACENCのaacenc32.exeをfrontendとしてプログラムから呼ぶことにした。
基本的にWAV->AAC->3G2変換になるのだが、MP3->WAV変換、WAVのsamplerate、
bitrateが44100,48000でなければ変換も考慮し作成するとする。
1:WINAMP[enc_aacplus.dll]
WAV->AACのDLLだが明示的に与えたsamplerate、bitrateで変換をしてくれる
優れものである。
使用方法としては一般的にLoadLibraryし、使用するfunctionをGetProcAddress
で得て使用するだけである。
WAV(channel=1or2,sampleRate=32000,44100or48000,bitsPerSample=16)->AAC
2:HELIX[producer.exe]、AACENC[aacenc32.exe]
frontendとしての使用であるからパラメータをセットし、CreateProcessを呼ぶ
だけであるが、producerは*.m4a、aacenc32は*.aacをoutputする。
只、aacenc32での変換ではsamplerate、bitrateまで変換してくれないので事前に
変換する必要がある。
producer.exe
WAV(channel=1or2,sampleRate=32000,44100or48000,bitsPerSample=16)->m4a
aacenc32.exe
WAV(channel=1or2,sampleRate=32000,44100or48000,bitsPerSample=16)->
sampleRate=32000or48000ならば44100に変換->AAC->と一工程増える。
後はenc_aacplus、aacenc32はAACから3g2に変換、これも至って簡単で、
ct-libisomedia.dllで汎用的なMP4が作られる。
ここまで出来れば後は着うたフルとしてモデファイするだけである。

着うたフル奮闘記(#10)

2006-02-18 11:33:37 | Weblog
最近忙しく(?)書く暇がなく今日に至る。
今まで着うたフル等のデータについて書き綴ってきたが、
今回からは着うたフルを作るにあたり、手動で作成は結構
手間隙がかかる、そこで色んなソフトを駆使して作ることに
なるが、中々既存のソフトに都合よく出来るものがない!
既存で使えるものは使い(HE-AACエンコウダー等)ない物は
作っていくとの考えで。
既存のソフトで作成した3G2ファイルは着うたフルとはならない。
そこでバイナリエデターで各アトムを比較し着うたフルに必要な
アトム等を探し出す作業は結構大変である。
そこで第一弾としてアトムブラウザーなるものを作ることで
着うたフルに必要なアトム等を探し出す作業が簡略か出来る。
そのソフトが表示されているものである。
必要なかたがおられれば hatikazuki_1948@mail.goo.ne.jp
に連絡頂ければ差し上げますが、適当に作ってますので動作、
不具合等についてはご容赦ください。
次回はAAC,MP3,WAV等->AAC->3G2->kmfのプログラムについて


着うたフル奮闘記(#9)

2006-01-13 13:14:22 | Weblog
昨日何歳??かの誕生日あー年は取りたくない!!若いころなら寒くてもゴルフに釣り、夜は飲み会と誕生日一週間はイベントが続いたもんだが、年を取ると寒さがこたえ、どうしても暖かいとこしか行きたくなくなる(パチンコ、酒)。

前回の続き

stsz -> sample (block byte) size box
[000000] 00 00 3B 1C 73 74 73 7A 00 00 00 00 00 00 00 00
[000010] 00 00 0E C2 00 00 01 11 00 00 01 5D 00 00 01 B5
以下省略
$00-03 size 0x00003B1C(15132)
$04-07 name 0x7374737A(stsz)
$08 version 0x00(0)
$09-0B flags 0x00000080)
$0C-0F block byte size for all 0x00000000(0) different sizes = 0
$10-13 number of block sizes 0x00000EC2(3778)
$14-17 block byte sizes 0x00000111(273) 以後3777block続く
全ブロック総バイト=mdatサイズとなる。

stsc -> sample/framing to chunk/block box
[000000] 00 00 00 28 73 74 73 63 00 00 00 00 00 00 00 02
[000010] 00 00 00 01 00 00 00 15 00 00 00 01 00 00 00 B4
[000020] 00 00 00 13 00 00 00 01
$00-03 size 0x00000028(40)
$04-07 name 0x73747363(stsc)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F number of blocks 0x00000002(2)
$10-13 frames per block(first/next block) 0x00000001(1)
$14-17 frames per block(# of frames) 0x00000015(21)
$18-1B samples description id 0x00000001(1)
以後12バイトごと、number of blocks分続く
同一framesが続く場合、次に違うframesがくるまで省略できるので
第一フレーム0x15(21)で第二フレーム0x13(19)のfirst/next blockが0xB4(180)なので第一フレーム0x15(21)が179続いていることになる。

stco -> chunk/block offset box
[000000] 00 00 02 E0 73 74 63 6F 00 00 00 00 00 00 00 B4
[000010] 00 00 43 80 以後省略
$00-03 size 0x000002E0(736)
$04-07 name 0x7374636F(stco)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F number of offsets 0x000000B4(180)
$10-13 block offsets 0x00004380 以後4バイトごと、number of offsets分続く
block offsetsはmdatの絶対アドレスを指している為、mdat以前のアトムを編集した場合(増減)はblock offsetsの値を修正する必要がある。

stss -> optional sync sample (key/intra frame) box
[000000] 00 00 02 E0 73 74 73 73 00 00 00 00 00 00 00 B4
{000010] 00 00 00 01 00 00 00 16 以後省略
$00-03 size 0x000002E0(736)
$04-07 name 0x73747373(stss)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F number of key frames 0x000000B4(180)
$10-13 key/intra frame location 0x00000001
$14-17 key/intra frame location 0x00000016 以後省略
key/intra frame location は先ほどstscの# of framesの値を参照にし、第一キーよりの加算値となる。
本来このアトムはなくても聴くには支障がないが、着うた切り出しに必要となるもので、全ての携帯をチェックしたわけではないが付加されてない場合は切り出しが不能となる携帯もある。

今回までのアトムが実装された3G2ファイルであれば着登録(メール着)が可能である。
断片化(QTPRO)の場合はmoovアトム内に規定のアトムが実装されていない為(上記アトム外)に起こりうる問題であり規定のアトムを実装するこにより回避できる。

着うたフル奮闘記(#8)

2006-01-11 15:13:42 | Weblog
前回に続き、、

stbl -> sample (framing info) table box
[000000] 00 00 41 8E 73 74 62 6C
$00-03 size 0x0000418E(16782)
$04-07 name 0x7374626C(stbl)

stts -> time to sample (frame timing) box
[000000] 00 00 00 18 73 74 74 73 00 00 00 00 00 00 00 01
[000010] 00 00 0E C2 00 00 04 00
$00-03 sise 0x00000018(24)
$04-07 name 0x73747473(stts)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F number of times 0x00000001(1)
$10-13 framing rate count 0x00000EC2(3778)
$14-17 duration 0x00000400(1024)

stsd -> sample (frame encoding) description box
[000000] 00 00 00 6A 73 74 73 64 00 00 00 00 00 00 00 01
[000010] 00 00 00 5A 6D 70 34 61 00 00 00 00 00 00 00 01
[000020] 00 00 00 00 00 00 00 00 00 02 00 10 00 00 00 00
[000030] 56 22 00 00 00 00 00 36 65 73 64 73 00 00 00 00
[000040] 03 80 80 80 25 00 00 00 04 80 80 80 17 40 15 00
[000050] 06 00 00 00 BB 80 00 00 BB 80 05 80 80 80 05 13
[000060] 90 56 E5 A0 06 80 80 80 01 02
$00-03 size 0x0000006A(106)
$04-07 name 0x73747364(stsd)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F number of descriptions 0x00000001 default = 1
$10-13 description size 0x0000005A(90)
$14-17 description name 0x6D703461(mp4a)
$18-1D reserved 0x000000000000
$1E-1F data reference index 0x0001
$20-21 QUICKTIME audio encoding version 0x00(0) default = 0
$22-23 QUICKTIME audio encoding revision level 0x00(0) default = 0
$24-27 QUICKTIME audio encoding vendor 0x00000000("")
$28-29 audio channels 0x00002(2) mono = 1 stereo = 2
$2A-2B audio sample size 0x0010(16) 8 or 16
$2C-2D QUICKTIME audio compression id 0x0000(0) default = 0
$2E-2F QUICKTIME audio packet size 0x0000(0)
$30-33 audio sample rate 0x56220000(22050.0)
$34-37 ES Descriptor size 0x00000036(54)
$38-3B ES Descriptor name 0x65736473(esds) vers. 2 ES Descriptor box
$3C version 0x00(0)
$3D-3F flags 0x000000(0)
$40 ES descriptor type tag 0x03(3)
$41-43 start or end type 0x808080 start = 0x80 end = 0xFE
$44 descriptor type length 0x25(37)
$45-46 ES ID 0x0000(0)
$47 stream priority 0x00 defaults = 16 0 - 31
$48 ES descriptor type tag 0x04(4)
$49-4B start or end type 0x808080 start = 0x80 end = 0xFE
$4C descriptor type length 0x17(23)
$4D object type ID 0x40(64) MPEG-4 video = 32 audio = 64
$4E stream type or flags 0x15 bit展開後
00010101 左から
6bit 000101 0x05(5) audio = 5 visual = 4
1bit 0 0x00(0) upstream flag
1bit 1 0x01(1) reserved flag set to 1
$4F-51 buffer size 0x000600(1536)
$52-55 maximum bit rate 0x0000BB80(48000)
$56-59 average bit rate 0x0000BB80(48000)
maximum bit rate,average bit rate はbitrate偽装に使われてる箇所
$5A ES descriptor type tag 0x05(5)
$5B-5D start or end type 0x808080 start = 0x80 end = 0xFE
$5E descriptor type length 0x05(5)
$5F-63 header start codes 0x139056E5A0 bit展開後
0001001110010000010101101110010110100000 左から
AudioObjectType = 5bit 00010 0x02(2) = LC = 2 HE = 5
SamplingRateIndex = 4bit 0111 0x07(7) = 22050
channels = 4bit 0010 0x02(2) mono = 1 stereo = 2
reserved = 3bit 000 0x00
syncExtensionType = 11bit 010 1011 0111 0x2B7 = SBR Stuff
extensionAudioObjectType = 5bit 00101 0x05(5) = HE
sbrPresentFlag = 1bit 1 0x01 TRUE = SBR
extensionSamplingRateIndex = 4bit 0x04(4) = 44100
alignBits = 3bit 000 1bit毎に意味があるが、ま、いいか
$64 ES descriptor type tag 0x06(6)
$65-67 start or end type 0x808080 start = 0x80 end = 0xFE
$68 descriptor type length 0x01(1)
$69 SL value 0x02(2)

注意しなければいけないのは、$4D object type ID、$4E stream type or flags、$52- maximum bit rate、$56- average bit rate、$5F- header start codes がくい違っていると不正なデータとしてはじかれる可能性がある。

着うたフル奮闘記(#7)

2006-01-09 23:30:36 | Weblog
土曜日PET検査受けた。二回目だが、前処理がCT検査より長い!!問診後静脈に放射性ブドウ糖??を入れられ約一時間安静後、台に寝かされ約20分ゴトゴトと全身撮影される、うーん長い!!CT検査なら長くて15秒ま、寝てればいいのだけど!!
結果は五日後なんにもなければ、、なるようにしかならないのが世の中やし(笑)

前回の続き

trak -> trak(element) box
[000000] 00 00 42 7B 74 72 61 6B
$00-03 size 0x0000427B(17019)
$04-07 name 0x7472616B(trak)

tkhd -> trak header box
[000000] 00 00 00 5C 74 6B 68 64 00 00 00 07 BF E0 CB FF
[000010] BF E0 CB FF 00 00 00 01 00 00 00 00 00 01 9B 35
[000020] 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00
[000030] 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[000040] 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[000050] 40 00 00 00 00 00 00 00 00 00 00 00
$00-03 size 0x0000005C(92)
$04-07 name 0x746B6864()tkhd
$08 version 0x00(0)
$09-0B flags 0x000007(7)
TrackEnabled = 1 TrackInMovie = 2 TrackInPreview = 4 TrackInPoster = 8
$0C-0F creation time 0xBFE0CBFF(Wed Jan 04 00:49:03 2006)
$10-03 modification time 0x0xBFE0CBFF(Wed Jan 04 00:49:03 2006)
$14-17 trak ID 0x00000001(1) first track = 1
$18-1B reserved 0x00000000
$1C-1F duration 0x00019B35(105269)
$20-27 reserved 0x0000000000000000
$28-29 video layer 0x0000(0) middle = 0
$2A-2B alternate 0x0000(0) none = 0
$2C-2D audio volume 0x0100 mute = 0x0001 ; 100% = 1.0 ; QUICKTIME 200% max = 2.0
$2E-2F reserved 0x0000
$30-53 matrix value A,B,U,C,D,V,Xy,W
$54-57 width 0x00000000(0)
$58-5B height 0x00000000(0)

mdia -> media (stream) box
[000000] 00 00 42 17 6D 64 69 61
$00-03 size 0x00004217(16919)
$04-07 name 0x6D646961(mdia)

mdhd -> media (stream) header box
[000000] 00 00 00 20 6D 64 68 64 00 00 00 00 BF E0 CB FF
[000010] BF E0 CB FF 00 00 56 22 00 3B 08 00 55 C4 00 00
$00-03 size 0x00000020(32)
$04-07 name 0x6D646864(mdhd)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F creation time 0xBFE0CBFF(Wed Jan 04 00:49:03 2006)
$10-13 modification time 0x0xBFE0CBFF(Wed Jan 04 00:49:03 2006)
$14-17 time scale 0x00005622(22050)
$18-1B duration 0x003B0800(3868672) 再生時間 = duration / time scale
$1C-1D anguage 0x55C4 (B:0101010111000100)
左から
0 -> 0x0 -> ISO language padding = 0
101010111000100 -> 0x55C4 -> ISO 639-2 language code
$1E-1F quality 0x0000 normal = 0

hdlr -> handler reference box
[000000] 00 00 00 25 68 64 6C 72 00 00 00 00 00 00 00 00
[000010] 73 6F 75 6E 00 00 00 00 00 00 00 00 00 00 00 00
[000020] 73 6F 75 6E 00
$00-03 size 0x00000025(37)
$04-07 name 0x68646C72(hdlr)
$08 version 0x00
$09-0B flags 0x000000
$0C-0F component type 0x00000000("")
$10-13 component subtype 0x736F756E("soun")
$14-17 component manufacturer 0x00000000("")
$18-1B component flags 0x00000000(0) none = 0
$1C-1F component flags mask 0x00000000(0) none = 0
$20-23 component name 0x0x736F756E00("soun")

minf -> media (stream) information box
[000000] 00 00 41 CA 6D 69 6E 66
$00-03 size 0x000041CA(16842)
$04-07 name 0x6D696E66(minf)

smhd -> sound media (stream) info header box
[000000] 00 00 00 10 73 6D 68 64 00 00 00 00 00 00 00 00
$00-03 size 0x00000010(16)
$04-07 name 0x736D6864(smhd)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0D audio balance 0x0000(0.0) normal = 0.0
$0E-0F reserved 0x0000

dinf -> data (locator) information box
[000000] 00 00 00 24 64 69 6E 66
$00-03 size 0x00000024(36)
$04-07 name 0x64696E66(dinf)

dref -> data reference box
[000000] 00 00 00 1C 64 72 65 66 00 00 00 00 00 00 00 01
[000010] 00 00 00 0C 75 72 6C 20 00 00 00 01
$00-03 size 0x0000001C(28)
$04-07 name 0x34726566(dref)
$08 version 0x00(0)
$09-0B flags 0x000000(0)
$0C-0F number of references 0x00000001(1) minimum = 1
$10-13 size 0x0000001C(12)
$14-17 type 0x75726C20("urn ")
#18 version 0x00(0)
$19-1B flags 0x000001 external data = 0x000000 internal data = 0x000001

ま、ここらのアトムはこんなのがあるんだ位で毒にも薬もならないようなもんで、あればいいと頭の片隅に、、、、次回はstblについて、ここが難解でMPプレイヤーでは考えなくても再生できるが、携帯となると駄々をこねるところである(笑)