Repository navigation
Samples
Yoshihiro Yamazaki edited this page Nov 27, 2026
·
1 revision
sample/ にあるスクリプトです。composer で入れた場合は vendor/yoya/io_heif/sample/ にあります。
ファイルを書き出すものは、結果を標準出力に書くのでリダイレクトして使います。
例の input.hevc は 利用方 の冒頭の ffmpeg で作ったものです。
| スクリプト | 使い方 | 内容 |
|---|---|---|
heiffromhevc.php |
-f <hevc> |
HEVC → HEIC (fromHEVC() と build()) |
heiftohevc.php |
-f <heic> [-i <itemID>] [-r <role>] [-u <urn>] |
何も指定しないと item の一覧。-i か -r で選んだ item を HEVC で出す |
heifdump.php |
-f <heic> [-t] [-h] [-r] [-d] |
box の木のダンプ |
heiftree.php |
-f <heic> |
property と item の一覧 |
heifitems.php |
-f <heic> [-i <itemID>] [-t] [-h] [-r] [-d] |
item に関わる box のダンプ |
heifprops.php |
-f <heic> [-t] [-h] [-r] [-d] |
ipco の property のダンプ |
heifrebuild.php |
-f <heic> |
parse して、そのまま build する |
heifdelbox.php |
-f <heic> -t <type>[,<type>...] [-d] |
指定した type の box を消して build する |
heifaddiccp.php |
-f <heic> -p <icc> [-d] |
ICC プロファイルを足して build する |
heifdump 以下の 7 本は、IO_ISOBMFF の isobmff*.php のクラス名を替えたものです。オプションと出力の見方は IO_ISOBMFF のサンプル一覧 を見てください。
% php sample/heiffromhevc.php -f input.hevc > output.heic
% php sample/heiftree.php -f output.heic
Props:
[1]: ispe width:64 height:64
[2]: pasp
[3]: hvcC profile:1(Main profile) level:30 chroma:1(YUV420)
compatibility:0x60000000 constraint:0x900000000000 bitdepth,8:8
naltype:32 (len:24) 40 01 0C 01 FF FF 01 60 00 00 03 00 90 00 00 03 ...
naltype:33 (len:41) 42 01 01 01 60 00 00 03 00 90 00 00 03 00 00 03 ...
naltype:34 (len:7) 44 01 C1 72 B4 22 40
Items:
[1]: pitm type:hvc1 ref:0 offset:32 length:805
(mdat:0x20,0x325) 00 00 03 21 28 01 AF 13 80 8B C7 73 F1 95 DC BF ...
[1?]ispe:64,64 [2?]pasp [3]hvcC:1,30,1
Warning:
hvcC の行の下には、VPS (32)・SPS (33)・PPS (34) の NAL ユニットの長さと先頭 16 バイトが出ます。
% php sample/heiftohevc.php -f output.heic
ItemID:1 infe:hvc1 pitm
% php sample/heiftohevc.php -f output.heic -r master > output.hevc
% php sample/heiftohevc.php -f output.heic -i 1 > output.hevc
- 一覧は item ごとに、infe の種類と役割 (
pitm,thmb:<元の item>,auxl:<元の item>など) を出します。補助画像なら auxC の種類も出します。 -
-rはmaster(primary,pitm)、thumbnail(thmb)、aux(auxl,auxiliary。-u <urn>で auxC の種類を指定) です。 - 例外が起きると、メッセージとスタックトレースを標準出力に出して終了コード 1 で終わります。
-rで出力をリダイレクトしているときは、それがファイルに入るので注意してください。
% php sample/heifdump.php -f output.heic -t
type:ftyp
type:mdat
type:meta version:0 flags:0
type:hdlr version:0 flags:0
type:pitm version:0 flags:0
type:iloc version:0 flags:0
type:iinf version:0 flags:0
type:infe version:2 flags:0
type:iprp
type:ipco
type:ispe version:0 flags:0
type:pasp
type:hvcC version:1
type:ipma version:0 flags:0
% php sample/heifprops.php -f output.heic -t
ispe index:1
pasp index:2
hvcC index:3
% php sample/heifaddiccp.php -f output.heic -p sRGB.icc > output-icc.heic
% php sample/heifprops.php -f output-icc.heic -t
ispe index:1
pasp index:2
hvcC index:3
colr index:4 prof
heifrebuild.php で作り直した output.heic は、元と同じバイト列になります。