1
1
mirror of https://github.com/wader/fq.git synced 2024-11-27 06:04:47 +03:00
fq/dev/editlist.jq

50 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-06-08 03:29:51 +03:00
#!/usr/bin/env fq -d mp4 -f
# TODO: esds, make fancy printer? shared?
# TODO: handle -1 media_time
# TODO: fragmented mp4
# root
# moov
# mvhd (movie header)
# trak (track)
# mdia
# mdhd (media header)
# hdlr (handler?)
# minf
# stbl
# stsd (sample description)
# elst (edit list)
( first(.boxes[] | select(.type == "moov")?)
| first(.boxes[] | select(.type == "mvhd")?) as $mvhd
| {
duration: $mvhd.duration,
time_scale: $mvhd.time_scale,
duration_s: ($mvhd.duration / $mvhd.time_scale),
tracks:
[ .boxes[]
| select(.type == "trak")
| first(.. | select(.type == "mdhd")?) as $mdhd
| first(.. | select(.type == "hdlr")?) as $hdlr
| first(.. | select(.type == "stsd")?) as $stsd
| first(.. | select(.type == "elst")?) as $elst
| {
component_type: $hdlr.component_subtype,
data_format: $stsd.sample_descriptions[0].data_format,
media_scale: $mdhd.time_scale,
edit_list:
[ $elst.table[]
| {
time_scale: $mdhd.time_scale,
track_duration: .track_duration,
media_time: .media_time,
track_duration_s: (.track_duration / $mvhd.time_scale),
media_time_s: (.media_time / $mdhd.time_scale)
}
]
}
]
}
)