axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
1.94k stars 478 forks source link

mp4edit not working on segment #15

Open bcasinclair opened 9 years ago

bcasinclair commented 9 years ago

I am trying to use mp4edit on a single segment generated as part of a DASH live profile and it appears to be failing to process the m4f correctly.

For example the mp4dump of the seg-0.m4f is: [moof] size=8+488 [mfhd] size=12+4 sequence number = 1 [traf] size=8+464 [tfhd] size=12+8, flags=20020 track ID = 1 default sample flags = 1010000 [tfdt] size=12+8, version=1 base media decode time = 0 [trun] size=12+412, flags=305 sample count = 50 data offset = 504 first sample flags = 2000000 [mdat] size=8+118697

My attempt to use mp4edit (example only via remove): mp4edit --remove moof/traf[0]/tfhd seg-0.m4f edit.m4f ERROR: atom 'moof/traf[0]/tfhd' not found

Whereas the same command works when operating on a full mp4 with --remove moov/trak[0]/tkhd e.g. sample structure: [ftyp] size=8+28 major_brand = isom minor_version = 1 compatible_brand = isom compatible_brand = avc1 compatible_brand = mp42 compatible_brand = iso5 compatible_brand = iso6 [moov] size=8+800 [mvhd] size=12+96 timescale = 1000 duration = 65760 duration(ms) = 65760 [trak] size=8+555 [tkhd] size=12+80, flags=7 enabled = 1 id = 1 duration = 65760 width = 640.000000 height = 360.000000

I am using the latest pull from master

barbibulle commented 9 years ago

This is due to a current limitation of the way mp4edit works with fragmented MP4: you can only edit atoms/boxes that are outside of the movie fragments. This could be fixed, but it hasn't come up as a use case so far. Can you describe your use case?

bcasinclair commented 9 years ago

I want to re-write some sequence numbers in the mfhd within an m4f.

I think I have fixed it though by updating the remove and replace commands to include the true flag for auto_create.

Will test and send through the details

bcasinclair commented 9 years ago

With the editing atoms outside of the movie boxes (in this case moof) if you can give me some pointers I can have a look at trying to fix

barbibulle commented 9 years ago

I'll take a look at this shortly.

ravelab commented 7 years ago

I also would like to edit atoms outside of the movie boxes. Any update? thanks

barbibulle commented 7 years ago

I haven't been able to attend to this item yet. I'll try to schedule this soon.

mgny commented 6 years ago

I am decrypting a file using mp4decrypt. The decryption works fine but the pssh and uuid atoms are left in the clean file. I try to remove these atoms with mp4edit at a later step; but mp4edit can not remove uuid atoms. Will this change support editing uuid atoms? If not, is there alternative solution?

barbibulle commented 6 years ago

removing a pssh atom should work. Example: mp4edit --remove moov/pssh input.mp4 output.mp4

For uuid atoms, you can edit them out, but you can't specify the actual UUID bytes, so if you have more than one, you will need to refer to them by index. Example: mp4edit --remove moov/uuid input.mp4 output.mp4 or mp4edit --remove moov/uuid[1] input.mp4 output.mp4

On Thu, Sep 14, 2017 at 1:38 PM, mgny notifications@github.com wrote:

I am decrypting a file using mp4decrypt. The decryption works fine but the pssh and uuid atoms are left in the clean file. I try to remove these atoms with mp4edit at a later step; but mp4edit can not remove uuid atoms. Will this change support editing uuid atoms? If not, is there alternative solution?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/axiomatic-systems/Bento4/issues/15#issuecomment-329602064, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWJjaSNGcTOofAXEF3cIsysjhmGMdXbks5siY63gaJpZM4FQcuh .

mgny commented 6 years ago

I had already tried removing moov/pssh and worked fine. But the uuid atoms are in moof box therefore mp4edit can not remove them. (mp4edit --remove moof/uuid). However, with some code changes I was able to remove uuid (and pssh) within mp4decrypt. I can start a pull request if you agree with this approach.

aescarcha commented 6 years ago

Any update on this?

mrsuh commented 5 years ago

Any update on this?

satninfy commented 4 years ago

Is this feature ( adding atoms to and removing atoms from 'moof' ) not yet available ?

./mp4edit --remove moof/mfhd sample2.m4v sample_edit.m4v ERROR: atom 'moof/mfhd' not found

TakuSemba commented 4 years ago

any update on this?

barbibulle commented 4 years ago

I looked at this again and realized that it is quite a bit more complicated than I originally assumed. The problem is that when you edit atoms, some of the internal offsets may need to be recomputed. And the AP4_Processor class used by mp4edit to do its work just doesn't expose all the information that would be necessary for this to work on partial mp4 files (i.e fragments). I'm not giving up, but this isn't something I can get done in the next few weeks.

Random-Code-Guy commented 1 year ago

mp4edit --remove moov/pssh input.mp4 output.mp4

Hi i tried doing this on a file i decrypted and it did not seem to work when done via vlc i still see errors such as this

mp4 warning: unknown box type pssh (incompletely loaded) mp4 debug: dumping root Box "root" mp4 debug: | + ftyp size 28 offset 0 mp4 debug: | + moov size 1629 offset 28 mp4 debug: | | + mvhd size 120 offset 36 mp4 debug: | | + trak size 603 offset 156 mp4 debug: | | | + tkhd size 104 offset 164 mp4 debug: | | | + mdia size 491 offset 268 mp4 debug: | | | | + mdhd size 44 offset 276 mp4 debug: | | | | + hdlr size 33 offset 320 mp4 debug: | | | | + minf size 406 offset 353 mp4 debug: | | | | | + vmhd size 20 offset 361 mp4 debug: | | | | | + dinf size 36 offset 381 mp4 debug: | | | | | | + dref size 28 offset 389 mp4 debug: | | | | | | | + url size 12 offset 405 mp4 debug: | | | | | + stbl size 342 offset 417 mp4 debug: | | | | | | + stsd size 266 offset 425 mp4 debug: | | | | | | | + encv size 250 offset 441 mp4 debug: | | | | | | | | + avcC size 64 offset 527 (????) mp4 debug: | | | | | | | | + btrt size 20 offset 591 mp4 debug: | | | | | | | | + sinf size 80 offset 611 mp4 debug: | | | | | | | | | + frma size 12 offset 619 mp4 debug: | | | | | | | | | + schm size 20 offset 631 (????) mp4 debug: | | | | | | | | | + schi size 40 offset 651 mp4 debug: | | | | | | | | | | + tenc size 32 offset 659 (????) mp4 debug: | | | | | | + stts size 16 offset 691 mp4 debug: | | | | | | + stsc size 16 offset 707 mp4 debug: | | | | | | + stsz size 20 offset 723 mp4 debug: | | | | | | + stco size 16 offset 743 mp4 debug: | | + mvex size 40 offset 759 mp4 debug: | | | + trex size 32 offset 767 mp4 debug: | | + pssh size 798 offset 799 (????) mp4 debug: | | + pssh size 60 offset 1597 (????) mp4 debug: | + ftyp size 28 offset 1657 mp4 debug: | + moov size 751 offset 1685 mp4 debug: | | + mvhd size 120 offset 1693 mp4 debug: | | + trak size 523 offset 1813 mp4 debug: | | | + tkhd size 104 offset 1821 mp4 debug: | | | + mdia size 411 offset 1925 mp4 debug: | | | | + mdhd size 44 offset 1933 mp4 debug: | | | | + hdlr size 33 offset 1977 mp4 debug: | | | | + minf size 326 offset 2010 mp4 debug: | | | | | + vmhd size 20 offset 2018 mp4 debug: | | | | | + dinf size 36 offset 2038 mp4 debug: | | | | | | + dref size 28 offset 2046 mp4 debug: | | | | | | | + url size 12 offset 2062 mp4 debug: | | | | | + stbl size 262 offset 2074 mp4 debug: | | | | | | + stsd size 186 offset 2082 mp4 debug: | | | | | | | + avc1 size 170 offset 2098 mp4 debug: | | | | | | | | + avcC size 64 offset 2184 mp4 debug: | | | | | | | | + btrt size 20 offset 2248 mp4 debug: | | | | | | + stts size 16 offset 2268 mp4 debug: | | | | | | + stsc size 16 offset 2284 mp4 debug: | | | | | | + stsz size 20 offset 2300 mp4 debug: | | | | | | + stco size 16 offset 2320 mp4 debug: | | + mvex size 40 offset 2336 mp4 debug: | | | + trex size 32 offset 2344 mp4 debug: | | + pssh size 60 offset 2376 (????) mp4 debug: | + styp size 20 offset 2436 mp4 debug: | + sidx size 52 offset 2456 mp4 debug: unrecognized major media specification (iso5).

there still seems to be three pssh options i am trying this under ubuntu with 1 segment of a fragmented dash manifest

it should be noted that i decrypted the segment using mp4decrypt todo this i had to combine the init segment with the media segment as using the mp4 decrypt option --fragment-info and setting it to the location of the init segment does not seem to work and the file is not decrypted

stevemayhew commented 5 months ago

This seems simple enough to fix? Perhaps I'm naive, but perhaps mp4edit should use a variant Ap4Processor that does not deal with fragment modification at all, don't strip the moof, sidx, mdat from the top level.

Otherwise, thinks like modifying the PSSH are impossible, e.g.:

mp4edit --remove moof/pssh[0] video-001.mp4 x.mp4