Git Product home page Git Product logo

mp4ff's Issues

feature request: lazy reading of mdat

Currently, the full mdat content is read into memory when decoding a File or an MdatBox.

A lazy mode which does not load the full mdat box into memory when parsing a file would be beneficial, especially for large files.

A possible way would be an option to just store offset and size for the MdatBox,
so that sample data can be read by using a ReadSeeker interface.

Bug in AVC PicTiming SEI parsing

The offset is not correctly interpreted. For example, the offset is returned as 24 (the length of the field) when it should be zero.

feature request: add mp4 decrypt cmd for cenc mp4

could reference this code https://github.com/truedread/pymp4decrypt/blob/master/src/decrypt.py
this code is not running well. but it shows the steps.

could use following command to generate a cenc dash file
input.mp4 include both aac audio and avc video
output.mpd is a single fragmented and encrypted dash mp4 .

ffmpeg -i input.mp4 -r 24 -g 50 output.mp4
MP4Box -crypt drm.xml output.mp4 -out output_enc.mp4
MP4Box -dash 5000 -url-template -bs-switching no -out output.mpd -rap output_enc.mp4

drm.xml












examples/decrypt-cenc: multiple keys

I came across a video with multiple keys:

IV:d805bba9ee360871c54f430e5de9486b key:784f6b59536e7078594f653959715a49 type:2
IV:2890e5c5feb02fb5ec3e6ea4e0758bc6 key:5062524e343151366950744d7a4b4e65 type:2
IV:dc7e67eb7d9b6474fc9914ddeddb9493 key:58526c32716a30586c6c7349466f3639 type:2
IV:a870d9a9b8abd4b8add8c7eec1ac7f8e key:703439466a586a757235576a5069754b type:2
IV:c889acba1c740bb6f28dca890c5980a2 key:4f3532724142445476307876686d7347 type:2

does this module or tool support multiple keys? I can provide video sample if need be.

Support sample_composition_time_offset

I'm currently working with the sintel video (https://durian.blender.org/download/), and I have transformed that to a fMP4 using bento4. Now I'm trying to read it out using mp4ff, but I cannot get the duration when diving into themoof headers.

I will find sample_composition_time_offset, but there is no way through the API to get this value (only .Dur is supported).

Any thoughts?

Screenshot 2021-07-25 at 22 12 58

Add example code for cenc and cbcs segment encryption

The Common Encryption specification (ISO/IEC 23001-7) defines how ISOBMFF
segments should be encrypted in a standardized way.
This is used in both DASH and HLS for all codecs including H.264, HEVC, AV1, AAC, AC-3 etc.

There are two main schemes being used cenc and cbcs with the latter using striped encryption
with CBC.

There is example code for decryption in this repo, but it would be great to have code for encryption as well.

For video, there is a complication in that it should be partially encrypted by leaving headers (nalu + slice headers) unencrypted. This means that the code must parse the video to find out how big these headers are. There is already code for for slice header parsing for AVC and HEVC in their respective directories.

Beyond the standard, the Bento4 library provides a good source for learning about this encryption.
A possible acceptance criterium is that the generated encrypted segments should be possible to decrypt with Bento4 mp4decrypt in addition to by the example code in decrypt-cenc.

fmp4 to progressive mp4 in memory convert

I have a fmp4 with a m3u8 index store in disk or aws s3

customer want to download it as progressive mp4 on web browser.

Is there any way to convert it in memory and send it back to download user.

consider , Discontinued transmission.

could you give an example ?

Information on times in the SampleComplete object

Hi,
could you provide some information on what the times in the SampleComplete object mean and what type of values they are(sec, msec,nsec..)?

	mp4.SampleComplete{
		Sample: mp4.Sample{
			Flags uint32
			Dur   uint32 <----
			Size  uint32
			Cto   int32   <----
		},
		DecodeTime:         uint64 <----
		PresentationTime: uint64 <----
		Data                      []byte
	}

Audio stream loudness box missing

The audio stream loudness box ludt should be provided according to Apple's [HLS Authoring Specification].

2.19. In fMP4 files, you SHOULD provide loudness information by way of a loudness box (’ludt’). When present, the loudness box takes precedence over any loudness information in the audio stream.

It would therefore be nice to have support for it in mp4ff.

It is defined in section 12.2.7 of ISO/IEC 14496-12.
The ludt box is a container box that contains thou and alou boxes defined in the same section of the specification. These two are in turn both based on LoudnessBaseBox.

How to fragment?

I am using https://github.com/nareix/joy4 to consume RTMP FLV stream and transcode it into multiple small MP4 chunks that I want to serve as live stream to users over http. The thing is that HLS or DASH are essentially for downloading complete video files, not for streaming as such. In order to support proper streaming I need to produce fragmented mp4 files which is supported by the media source extension in web browsers. Non-fragmented MP4 files will simply fail to play.

So I am greatly interested in this library and I wonder how can I use it to either take existing mp4 "monolith" file and recode it into fragmented mp4 or or better yet ,take h264 packets fro the FLV demuxer and write fragmented files right away.

edit:
So I jsut started toying with this but I am stuck on an endless dependency tree. Is there a way out of this rabbit hole?

		vid, _ := mp4.CreateHdlr("video")
		aud, _ := mp4.CreateHdlr("audio")

		vmi := mp4.NewMinfBox()
		vmi.....
		vMed := mp4.NewMdiaBox()
		vMed.AddChild(vmi)
		vMed.AddChild(vid)

		aMed := mp4.NewMdiaBox()
		aMed.AddChild(aud)

		trackHeader := mp4.CreateTkhd()

		vTrack := mp4.NewTrakBox()
		aTrack := mp4.NewTrakBox()

		vTrack.AddChild(trackHeader)
		aTrack.AddChild(trackHeader)

		vTrack.AddChild(vMed)
		aTrack.AddChild(aMed)

		moov := mp4.NewMoovBox()
		moov.AddChild(vTrack)
		moov.AddChild(aTrack)

                file := mp4.NewFile()
		file.AddChildBox(mp4.CreateFtyp(), 0)
		file.AddChildBox(moov, 0)

and that is just the setup, i haven't wrote enything into it yet ...

decryptSegment: no senc box in traf

using this file (106 MB): http://0x0.st/Hwbc.mp4

I can decrypt like this:

> packager-win-x64 --enable_raw_key_decryption `
>> --keys key_id=21b82dc2ebb24d5aa9f8631f04726650:key=602a9289bfb9b1995b75ac63f123fc86 `
>> stream=video,in=enc.mp4,output=dec.mp4
[1121/225104:INFO:demuxer.cc(89)] Demuxer::Run() on file 'enc.mp4'.
[1121/225104:INFO:demuxer.cc(155)] Initialize Demuxer for file 'enc.mp4'.
[1121/225104:WARNING:track_run_iterator.cc(699)] Seeing non-zero composition offset 834167. An EditList is probably missing.
[1121/225104:WARNING:track_run_iterator.cc(703)] Adjusting timestamps by -834167. Please file a bug to https://github.com/google/shaka-packager/issues if you do not think it is right or if you are seeing any problems.

https://github.com/shaka-project/shaka-packager/releases

but these both fail:

mp4ff-decrypt -k 602a9289bfb9b1995b75ac63f123fc86 enc.mp4 dec.mp4

mp4ff-decrypt -k 602a9289bfb9b1995b75ac63f123fc86 -init enc.mp4 `
enc.mp4 dec.mp4

result:

2023/11/21 22:48:36 decryptSegment: no senc box in traf

mp4ff-info error "stpp size mismatch in stsd: 62 - 64" in a webvtt fragmented mp4 input file

mp4ff-info and wvttlister error stpp size mismatch in stsd: 62 - 64 in a webvtt fragmented mp4 input file. File was created in MP4Box cmdline tool, using other dvbreaders look ok. File is really broken(mp4box bug) or mp4ff-info cannot handle this type of webvtt.mp4 files?

https://refapp.hbbtv.org/videos/dashtest/test4/temp/temp-sub_eng.mp4

c:\temp> mp4ff-info.exe temp-sub_eng.mp4
2023/03/16 11:39:46 decode box "moov": decode box trak: decode box mdia: decode box minf: decode box stbl: decode box stsd: child stpp size mismatch in stsd: 62 - 64

c:\temp\mp4ff-wvttlister.exe temp-sub_eng.mp4
2023/03/16 11:43:43 decode moov: decode box trak: decode box mdia: decode box minf: decode box stbl: decode box stsd: child stpp size mismatch in stsd: 62 - 64

emsg parsing/writing doesn't handle non-empty message_data

The emsg parser does not treat the remaining bytes as message_data, but ignores it. That makes the size wrongly reported in mp4ff-info.

I'd suggest to add MessageData as member in the EmsgBox struct and make sure that it can be both decoded and encodedt.

typo in hevc/sps.go

Hi, guys.
I'm new here, so forgive me for not following the issue form(if exists).

I've found a typo(I guess) and want to let you know.
And of course, want it to be fixed also.
The typo I found is this.

Best Regards,
Dongjin

GetSampleNrAtTime fails on VBR mp4 files with last keyframe with 0 duration

Having last keyframe with 0 duration:
[stts]
...
- entry[113]: sampleCount=1 sampleDelta=95024
- entry[114]: sampleCount=1 sampleDelta=0
[stss]
- syncSampleCount: 10
...
- syncSample[10]: sampleNumber=114
[stsz]
- sample[113] size=2238
- sample[114] size=80726

GetSampleNrAtTime fails with "no matching sample found for time" for the two last cops times.

Proposed solution is to change line
if sampleStartTime < accTime+uint64(b.SampleCount[i])*timeDelta {
to
if sampleStartTime <= accTime+uint64(b.SampleCount[i])*timeDelta {

feature request: SetType() on AudioSampleEntryBox

Good day!

Right now there is no way too set AudioSampleEntryBox.name on already created box. This is must have feature to implement CENC compliant encryptor on mp4ff. As simplest solution we can have a SetType() method as it's already implemented for VisualSampleEntryBox.

Incorrect (?) calculation of AVC slice header size

Good day!

I'm concerned about correctness of this part of code:

mp4ff/avc/slice.go

Lines 349 to 354 in 5026403

/* compute the size in bytes. Round up if not an integral number of bytes .*/
sh.Size = uint32(r.NrBytesRead())
if r.NrBitsReadInCurrentByte() > 0 {
sh.Size++
}

Let's say you read 15 bits, so pos will be 1 (as it's start with -1), but when you call NrBytesRead() it will increment this value by 1, so you get 2 and it's totally valid. Then you check if any bits read and increment it once again - size will be set to 3.

I tested this version of code:

	sh.Size = uint32(r.NrBytesRead())
	if r.NrBitsReadInCurrentByte() == 0 {
		sh.Size--
	}

It's work with Apple's SAMPLE-AES in Safari as it ignore Senc BytesOfClearData and make calculation on it's own.

It is possible to decrement value of SliceHeader.Size before using it but it's kinda misleading.

Add AV1 support

With Apple's announcement of AV1 support on iPhone 15 Pro, AV1 is now relevant for both DASH and HLS.

It would therefore be great to add support for the AV1 VisualSampleEntry box av01 and the av1C codec configuration box.

Version 1.2.0 of the specification for AV1 in ISOBMFF can be downloaded from https://github.com/AOMediaCodec/av1-isobmff/releases/tag/v1.2.0

An example file by Netflix is http://download.opencontent.netflix.com.s3.amazonaws.com/AV1/Sparks/Sparks-5994fps-AV1-10bit-1920x1080-2194kbps.mp4

Example mp4 to mp4f

Hello, I'm looking for an example to transform an existing mp4 to a fragmented mp4. Any ideas?

corrupt input (decrypt-cenc)

sample encrypted mp4: https://user-images.githubusercontent.com/25949138/173815484-d5968e8e-c683-4acc-b2ed-77caffc29ac1.mp4

decryption key: 42cf7ff3ef8ed3d91824f83e8b392880

Steps to reproduce:

  • wget "https://user-images.githubusercontent.com/25949138/173815484-d5968e8e-c683-4acc-b2ed-77caffc29ac1.mp4" -O enc.mp4
  • decrypt-cenc -k 42cf7ff3ef8ed3d91824f83e8b392880 -i enc.mp4 -o dec.mp4
  • ffprobe dec.mp4

ffprobe output

ffprobe version 5.0.1 Copyright (c) 2007-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
[h264 @ 0x11b604450] SEI type 147 size 1720 truncated at 64
[h264 @ 0x11b604450] SEI type 220 size 1112 truncated at 80
[h264 @ 0x11b604450] SEI type 229 size 488 truncated at 32
[h264 @ 0x11b604450] SEI type 147 size 1720 truncated at 63
[h264 @ 0x11b604450] SEI type 220 size 1112 truncated at 77
[h264 @ 0x11b604450] SEI type 229 size 488 truncated at 31
[h264 @ 0x11b604450] A non-intra slice in an IDR NAL unit.
[h264 @ 0x11b604450] decode_slice_header error
[h264 @ 0x11b604450] no frame!
[h264 @ 0x11b604450] SEI type 24 size 328 truncated at 72
[h264 @ 0x11b604450] non-existing PPS 2 referenced
[h264 @ 0x11b604450] SEI type 24 size 328 truncated at 71
[h264 @ 0x11b604450] non-existing PPS 2 referenced
[h264 @ 0x11b604450] decode_slice_header error
[h264 @ 0x11b604450] no frame!
[h264 @ 0x11b604450] SEI type 185 size 1784 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 1 referenced
[h264 @ 0x11b604450] SEI type 185 size 1784 truncated at 62
[h264 @ 0x11b604450] non-existing PPS 1 referenced
[h264 @ 0x11b604450] decode_slice_header error
[h264 @ 0x11b604450] no frame!
[h264 @ 0x11b604450] SEI type 248 size 112 truncated at 72
[h264 @ 0x11b604450] non-existing PPS 2 referenced
[h264 @ 0x11b604450] SEI type 248 size 112 truncated at 71
[h264 @ 0x11b604450] non-existing PPS 2 referenced
[h264 @ 0x11b604450] decode_slice_header error
[h264 @ 0x11b604450] no frame!
[h264 @ 0x11b604450] SEI type 207 size 416 truncated at 72
[h264 @ 0x11b604450] SEI type 207 size 416 truncated at 70
[h264 @ 0x11b604450] reference count overflow
[h264 @ 0x11b604450] decode_slice_header error
[h264 @ 0x11b604450] no frame!
[h264 @ 0x11b604450] SEI type 204 size 1528 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 3 referenced
[h264 @ 0x11b604450] SEI type 204 size 1528 truncated at 62
[h264 @ 0x11b604450] non-existing PPS 3 referenced
[h264 @ 0x11b604450] decode_slice_header error
[h264 @ 0x11b604450] no frame!
[h264 @ 0x11b604450] SEI type 60 size 840 truncated at 64
[h264 @ 0x11b604450] SEI type 60 size 840 truncated at 60
[h264 @ 0x11b604450] Missing reference picture, default is 6
[h264 @ 0x11b604450] co located POCs unavailable
[h264 @ 0x11b604450] top block unavailable for requested intra mode
[h264 @ 0x11b604450] error while decoding MB 18 0, bytestream 36841
[h264 @ 0x11b604450] concealing 8160 DC, 8160 AC, 8160 MV errors in B frame
[h264 @ 0x11b604450] number of reference frames (1+4) exceeds max (4; probably corrupt input), discarding one
[h264 @ 0x11b604450] SEI type 223 size 720 truncated at 64
[h264 @ 0x11b604450] SEI type 51 size 1664 truncated at 72
[h264 @ 0x11b604450] SEI type 139 size 472 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 2 referenced
[h264 @ 0x11b604450] SEI type 60 size 712 truncated at 72
[h264 @ 0x11b604450] SEI type 16 size 1400 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 5 referenced
[h264 @ 0x11b604450] SEI type 150 size 232 truncated at 40
[h264 @ 0x11b604450] illegal reordering_of_pic_nums_idc 5
[h264 @ 0x11b604450] SEI type 225 size 992 truncated at 72
[h264 @ 0x11b604450] non-existing PPS 6 referenced
[h264 @ 0x11b604450] SEI type 179 size 376 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 1 referenced
[h264 @ 0x11b604450] SEI type 161 size 1920 truncated at 72
[h264 @ 0x11b604450] SEI type 32 size 1576 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 6 referenced
[h264 @ 0x11b604450] SEI type 49 size 1208 truncated at 64
[h264 @ 0x11b604450] non-existing PPS 9 referenced
[h264 @ 0x11b604450] SEI type 0 size 1288 truncated at 72
[h264 @ 0x11b604450] SEI type 52 size 536 truncated at 64
[h264 @ 0x11b604450] SEI type 132 size 1880 truncated at 72
[h264 @ 0x11b604450] non-existing PPS 2 referenced
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dec.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1dash
    creation_time   : 2022-06-14T14:26:56.000000Z
  Duration: 00:00:04.00, start: 0.080000, bitrate: 2380 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2376 kb/s, 25 fps, 25 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2022-06-14T14:26:56.000000Z
      handler_name    : ETI ISO Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : Elemental H.264


with mp4decrypt

mp4decrypt --key 1:42cf7ff3ef8ed3d91824f83e8b392880 enc.mp4 dec.mp4

ffprobe version 5.0.1 Copyright (c) 2007-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dec.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1dash
    creation_time   : 2022-06-14T14:26:56.000000Z
  Duration: 00:00:04.08, start: 0.080000, bitrate: 2338 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2329 kb/s, 25 fps, 25 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2022-06-14T14:26:56.000000Z
      handler_name    : ETI ISO Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : Elemental H.264
    Side data:
      unknown side data type 24 (1085 bytes)

No sidx?

I have noticed there is no segment index "box" in the library. Is that on purpose?

support low latency hls (llhls) encrpytion

I am working on llhls with this open source project https://github.com/bluenviron/mediamtx
it works well, however missing llhls encrpytion feature.
I wonder how to do that in llhls .
llhls will generate normal segment.fmp4 and a smaller fragment.fmp4
shall we just encrypt segment.fmp4 fragment.fmp4 one by one ?
witch encryption method shall we use ?

    METHOD=SAMPLE-AES    = SAMPLE-AES-CTR   ?? ['SAMPLE-AES', 'SAMPLE-AES-CTR', 'SAMPLE-AES-CENC'];
    METHOD=AES-128       = AES-128-CBC

I see there is an example decrypted example https://github.com/Eyevinn/mp4ff/tree/master/examples/decrypt-cenc
could you provide an encrypt example ?

avc.IsIDRSample not working

Given test sample @ https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/prog_index.m3u8

$ curl -r 0-718 -o init.mp4 https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/main.mp4

$ curl -r 719-274200 -o segment.mp4 https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/v2/main.mp4

$ cat init.mp4 segment.mp4 > test.mp4

ffmpeg confirms NAL Unit 5 present:

$ ffmpeg -i test.mp4 -map v -codec copy -bsf:v trace_headers -f null -y /dev/null 2>&1 | grep -m1 -A4 'Slice Header'
[trace_headers @ 0x600003bf04b0] Slice Header
[trace_headers @ 0x600003bf04b0] 0           forbidden_zero_bit                                          0 = 0
[trace_headers @ 0x600003bf04b0] 1           nal_ref_idc                                                11 = 3
[trace_headers @ 0x600003bf04b0] 3           nal_unit_type                                           00101 = 5
[trace_headers @ 0x600003bf04b0] 8           first_mb_in_slice                                           1 = 0

and ffprobe confirms the same:

$ ffprobe -hide_banner -loglevel quiet test.mp4 -print_format json -select_streams v -show_frames | jq '.frames[0]' | egrep '(key|pict_type)'
  "key_frame": 1,
  "pict_type": "I",

but if i extract h264 data up til the first frame:

$ ffmpeg -i test.mp4 -map v -codec copy -frames:v 1 -f h264 -y frame.h264
$ ffmpeg -f h264 -i frame.h264 -c copy -bsf:v trace_headers -f null -y /dev/null 2>&1 | grep -A3 'Slice'
[trace_headers @ 0x600001d8c5a0] Slice Header
[trace_headers @ 0x600001d8c5a0] 0           forbidden_zero_bit                                          0 = 0
[trace_headers @ 0x600001d8c5a0] 1           nal_ref_idc                                                11 = 3
[trace_headers @ 0x600001d8c5a0] 3           nal_unit_type                                           00101 = 5

and feed into mp4ff:

$ cat test.go
package main

import (
        "fmt"
        "io/ioutil"

        "github.com/Eyevinn/mp4ff/avc"
)

func main() {
        data, _ := ioutil.ReadFile("frame.h264")
        fmt.Printf("%v\n", avc.IsIDRSample(data))
}

but the result is false:

$ go run test.go
false

File from Unified Streaming packager

I would like to use mp4ff-wvttlister to extract webvtt from mp4 packaged by Unified Streaming packager.
It fails

mp4ff-wvttlister test.mp4
Track 1, timescale = 1000
[vttC] size=14

  • config: "WEBVTT"
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4afe6a]

goroutine 1 [running]:
github.com/Eyevinn/mp4ff/mp4.(*TfdtBox).BaseMediaDecodeTime(...)
/home/ubuntu/go/pkg/mod/github.com/!eyevinn/[email protected]/mp4/tfdt.go:76
github.com/Eyevinn/mp4ff/mp4.(*Fragment).GetFullSamples(0xc00006a3e0?, 0xc000016120)
/home/ubuntu/go/pkg/mod/github.com/!eyevinn/[email protected]/mp4/fragment.go:130 +0x8a
main.parseFragmentedMp4(0xc000128000?, 0xe038?, 0xffffffffffffffff)
/home/ubuntu/go/pkg/mod/github.com/!eyevinn/[email protected]/cmd/mp4ff-wvttlister/main.go:170 +0x42c
main.main()
/home/ubuntu/go/pkg/mod/github.com/!eyevinn/[email protected]/cmd/mp4ff-wvttlister/main.go:67 +0x2db

test.mp4

Is it a bug or a bad file ?
test.zip

StssBox IsSyncSample method is not thread-safe

The StssBox method IsSyncSample is not thread-safe. I ran into a fatal error fatal error: concurrent map writes when two threads are working on the same *mp4.File instance and call stss method IsSyncSample at almost the same time.
https://github.com/edgeware/mp4ff/blob/9953ef128cd4d264a44a5f1c5d5759c259b17651/mp4/stss.go#L51-L61

An easy solution could be moving the for loop to where we decode the StssBox and avoid adding locks to StssBox, but this solution slows down the decode a bit.

Segment parsing bases on only styp box

Hi,

Now, mp4ff consider that a segment mus start with a styp box, but some content does not contain styp box in Dash On-Demand or ISM. This issue lead to a problem that a media file which should contain multiple segments contains just on segment with multiple fragments, and it doesn't seem right. In this case, we must base on sidx box for Dash On-Demand and tfra box for ISM to determine the segment boundaries.

bug: example/segment fmp4 can not be played in firefox

generate fmp4 with
./segmenter -lazy -m -d 30000 -i ./box.mp4 -o fmp4

manual edit a m3u8 file like this
#EXTM3U
#EXT-X-TARGETDURATION:30
#EXT-X-VERSION:6
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MAP:URI="fmp4_init.mp4"
#EXTINF:43,
fmp4_media_1.m4s
#EXTINF:30.000,
fmp4_media_2.m4s
#EXTINF:30.000,
fmp4_media_3.m4s
#EXT-X-ENDLIST

use video.js to play the m3u8
try this index.html
index.html.zip

Other browser play well
But Firefox report

image

use mp4box to convert the same progressive mp4
MP4Box -dash 30000 -profile live box.mp4 -out dash.mpd --dual
it play well in all browser.
the difference is

example/segment
image

mp4box
image

feature request: extend segment example to a vod example

in a vod system, it normally convert a normal mp4 to hls(ts or m4s) in memory and stream to player
can we extend the segment example to support hls m4s ? and make a new example ?

Step:

  1. generate a m3u8 file base on mp4
  2. player read m3u8 and send a xx.m4s request to vod
  3. vod read mp4 and convert the related xx.m4s in memory and send to player.

How to merge two different tracks in a single "file"?

I would like to have a practical example how to merge two tracks in a single file.

Context:

I have some DASH segments(audio/video init, audio/video segments) and I want to merge both to a single init/segment.

I have been trying for two days to do that but I feel that I lack more fmp4 internals knowledge. If someone can help me with some insight I would appreciate it!

Thanks.

segmenter example not working

Trying to run one of the examples segmenter, but it's not working.

aaaa@xxxx segmenter % go run main.go

command-line-arguments

./main.go:53:34: too many arguments in call to mp4.DecodeFile
./main.go:53:40: undefined: mp4.WithDecodeMode
./main.go:53:59: undefined: mp4.DecModeLazyMdat
./main.go:61:20: undefined: NewSegmenter
./main.go:65:34: undefined: getSegmentStartsFromVideo
./main.go:72:9: undefined: makeMultiTrackSegments
./main.go:75:10: undefined: makeSingleTrackSegmentsLazyWrite
./main.go:77:10: undefined: makeSingleTrackSegments

Bug: Matrix coefficients not set for video

All matrix coefficients in mvhd and tkhd boxes are set to zero, but should for video, they should
specify a unity matrix as described in Sections 8.2.2.2 and 8.3.2.2

template int(32)[9] matrix =
  { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 };

Doesn't seem cause any big problems but ffmpeg complains:

 Side data:
  displaymatrix: rotation of nan degrees

The strange-looking values are because the first 6 values are 16.16 fixed-point values and the last 3 are 2.30 fixed-point values. The actual values are therefore really a unity matrix with a diagonal of ones.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.