VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. Working out the kinks, so looking at everything for a clue on what is wrong, and this seems very odd after i merge, on a windows box using copy /b.

    At each merge point in the merged file, i have all of this header info, and it would seem that it would be on header block, and the rest all media data to play the file, so is the following normal, or is my merge messed up (i am a coder, but have no clue on media file workings, never really played in the area):

    Image
    [Attachment 58825 - Click to enlarge]


    this is at every point the next file comes in.

    I thought i was close to the bottom of the hill on this project, but guess not LOL.
    Quote Quote  
  2. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    "Copy /B" is a quick and VERY dirty way of merging, which I've warned against for years, due to the very real possibility of encountering issues such as you are now seeing. You've probably just lucked out until now.

    The problem with copy/b is that it retains all the interim headers and timings, which wouldn't exist if it was properly merged (it would/should only have the main header and have new consecutive timings). This can confuse players/editors.

    I suggest you use a different method, perhaps Avidemux or some other gop-level, non-re-encoding editor, or perhaps an ffmpeg merge (concat) script.

    Scott
    Quote Quote  
  3. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    Normal ? Yes. The /b treats each file as binary so grabs all the bytes whether they can be used or not.


    What is more critical is if the player ignores the header and just treats the data after that as part of the original.


    But AFAIK it will process that data as if it was prepared in accordance with the original header. So merging files from different encoding parameters is not going to work.


    Or to put all that in another way, if there is visual and/or audio disturbance at the point where you appreciate the merge has taken place a merge is not an appropriate tool and a re-encode is more appropriate.
    Quote Quote  
  4. Deceased
    Join Date
    Dec 2007
    Search PM
    Originally Posted by Cornucopia View Post
    "Copy /B" is a quick and VERY dirty way of merging, which I've warned against for years, due to the very real possibility of encountering issues such as you are now seeing. You've probably just lucked out until now.

    The problem with copy/b is that it retains all the interim headers and timings, which wouldn't exist if it was properly merged (it would/should only have the main header and have new consecutive timings). This can confuse players/editors.
    If OP is working with fMP4 (fragmented dash), especially if the source files are encrypted, then raw binary concatenation is the only type of "merging" that will work, assuming, of course, that OP wants to decrypt the merged file afterwards. As mentioned previously here.


    Originally Posted by Cornucopia View Post
    I suggest you use a different method, perhaps Avidemux or some other gop-level, non-re-encoding editor, or perhaps an ffmpeg merge (concat) script.
    That method will never work for fMP4, assuming, again, that successful decryption is desired.

    OP has posted several threads about this topic without any reference to the actual source url(s) and/or file(s) that are being used. Someone could probably walk him through the process if his post(s) started from the very beginning.
    Quote Quote  
  5. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    That's an assumption. I didn't get that anywhere from the OP, other than possibly "=stitchable".

    But that assumption is fragile, assuming 1. It's that format. 2. It's encrypted. 3. It's encrypted in that method, requiring that workflow.

    Assuming it is...
    For NON-encrypted material, my caveat and recommendations still hold true.

    "Encrypted", hmm??!!

    Scott
    Quote Quote  
  6. Lost my reply twice submitting to post >(.

    Anyhow, i do leave many things out, since i am not 100% sure where the lines are, and do not what the boot/ban, so been trying to stay on the safe side. Since i lost a nice reply, explaining the questions posted bu each person, i am juts going to try and answer all the questions in one long reply.

    First, yes this is still the same project, that someone referred to, when the shared the post with "fragments vs segments", i came the conclusion they are the same, since i cannot find anywhere where they are handled or formatted differently, so the "f" or "s" was just dealer's choice, with the project team, and has no real value. I do have many posts about the project i am working on, the MPD is completely new, i cannot find any examples of what i am seeing, or even a white paper on it, all of the info is there, it is just wrapped differently so had to work though the parsing, the best i could, but seems like i have that working.

    At first i thought the MPD was being updated on the fly, but it is just part of this new format. the MPD link is only valid for about 5min, if that, then, the file name changes, so you get one shot at getting the MPD downloaded, however, once you have the file, the links inside stay valid for about a week, then, you need to grab a new MPD to work with.

    if what i am posting is against the rules, please give me a fair warning, and just delete this section if needed.

    Code:
    <MPD mediaPresentationDuration="PT42M0.831999S" minBufferTime="PT4.096S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" type="static" xmlns="urn:mpeg:dash:schema:mpd:2011">
      <Period duration="PT12M15.103999S" id="c-0-000-180">
    
    ********FOR AUDIO
    
    <AdaptationSet audioSamplingRate="48000" contentType="audio" group="1" lang="en" mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
          <ContentProtection xmlns:cenc="urn:mpeg:cenc:2013" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="6289ed1d-0b51-474b-bbe1-ed14cf1b86ed">
    
    <SegmentTemplate duration="368640" initialization="https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/TK_init.mp4?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" media="TK_$Number%08d$.m4f?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" startNumber="0" timescale="90000"></SegmentTemplate>
    
    ***** END ADUIO
    
    ***** INIT SECTION
    
    <AdaptationSet contentType="video" id="1" maxFrameRate="30" maxHeight="540" maxWidth="960" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1">
          <ContentProtection xmlns:cenc="urn:mpeg:cenc:2013" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="5f4e1b45-807b-4cd3-af0f-f9bcf3e47628"></ContentProtection>
    
     <SegmentTemplate duration="368640" initialization="https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/$RepresentationID$_init.mp4?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" media="$RepresentationID$$Number%08d$.m4f?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" startNumber="0" timescale="90000"></SegmentTemplate>
    
    ****** END OF INIT
    
    ****** FRAGMENT SECTION
    
    <AdaptationSet contentType="video" id="2" maxFrameRate="30" maxHeight="1080" maxWidth="1920" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1">
          <ContentProtection xmlns:cenc="urn:mpeg:cenc:2013" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="3a48357b-1e69-4004-a859-475e6052b71c"></ContentProtection>
    <Representation bandwidth="3170041" codecs="avc1.64001f" frameRate="30" height="720" id="E" scanType="progressive" width="1280">
            <BaseURL>https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/</BaseURL>
            <SegmentTemplate duration="368640" initialization="https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/$RepresentationID$_init.mp4?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" media="$RepresentationID$$Number%08d$.m4f?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" startNumber="0" timescale="90000"></SegmentTemplate>
          </Representation>
    
    **** END OF FRAGMENT
    There are 4-5 "periods" with different ranges, and the range of each period comes from the ID, for example the above the has an "ID" of "c-0-000-180", so this handles the files of 0 - 180, this is like the "S" tags in the other MPD files i have seen. You will also see from above there are 3 KID, and they do match to the keys from the WV decryptor in Chrome, so I have 1 key just for the INIT file, 1 key for all the audio, INIT and fragments, then 1 key for the video fragments.

    My code flow is:

    Parse the MPD for the fragment count (get the last period node, split the ID to get the count), file URL, nothing more than that, so maybe i need more info?
    Replace the file varibales as needed, ($ReprentationID$ is the resolution A - lowest, F - highest, $Number$ is the fragment number, and padded to 8 in len, so it becomes like A00000000.mf4)

    Download part 1 - i download the init.mp4 files for both audio and video, and keep the video init to the side, since it has its own key.

    Download part 2 - loop through the fragments, merging the video fragments in one file, and keep it to side since this has a different key, Audio gets merged right into the audio init file, since that has one key. I have been using the "copy /b" for this, so could be the issue, but works for the audio, and seems like what i am getting on the inside of the merged file, from my 1st post here, this is normal, so i am going to assume there is some kind of flag, to let the player know where the media playback starts, and end to skip each playback info header.

    Decrypting with mp4decrypt, and this is where it all fails for the video.
    send the raw audio file, with the KID and Key, decrypts fine, i can play the audio file, so it is in the clear
    send the raw video init file with its KID and Key, this may me in the clear, it is hard to tell, unless i look at it better, since the raw is 1K, and output is 1K
    send the raw merged fragment source with its KID and Key, this is where is blows up, i send in a 57MB file, and get a 1K on the output, however, if i merge the init file, with the merged fragments, i get the proper output file size.

    I am more than happy to share more in a PM, since i know this reply is close to the line as it is.

    Thanks,

    Dave
    Quote Quote  
  7. one thought i had on this, and have not tried yet, since it came to me on the way to work, is do i need to merge the init file to each fragment? if i am reading the XML correctly for the file

    Code:
    <Representation bandwidth="3170041" codecs="avc1.64001f" frameRate="30" height="720" id="E" scanType="progressive" width="1280">
            <BaseURL>https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/</BaseURL>
            <SegmentTemplate duration="368640" initialization="https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/$RepresentationID$_init.mp4?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" media="$RepresentationID$$Number%08d$.m4f?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" startNumber="0" timescale="90000"></SegmentTemplate>
          </Representation>
    each fragment is referencing the init file, so i am now reading the above as, get the init, "attach it" to the video file. So the init+fragment is really one file, when playing.

    I just do not know enough about how media files work, have not done anything like this until now.
    Quote Quote  
  8. yes, you can try it

    for mpd i used to concat init and segments like this:
    (init + seg1) + (init + seg2) + (init + seg3) + ...


    just recently i found someone here said to concat init and segments like this:
    init + seg1 + seg2 + seg3 + ...


    so for the last mpd I downloaded, I tried both ways
    and somehow they both work and after processed by ffmpeg (either mux with audio or copy to a different container), they become the same file (same CRC-32)
    maybe ffmpeg can remove redundant headers


    but i think you didn't download the files correctly
    init and segments defined in the same SegmentTemplate tag:
    "initialization" and "media" and they have the same kid in your case
    Quote Quote  
  9. Code:
    <AdaptationSet contentType="video" id="2" maxFrameRate="30" maxHeight="1080" maxWidth="1920" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1">
          <ContentProtection xmlns:cenc="urn:mpeg:cenc:2013" schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="3a48357b-1e69-4004-a859-475e6052b71c"></ContentProtection>
    <Representation bandwidth="3170041" codecs="avc1.64001f" frameRate="30" height="720" id="E" scanType="progressive" width="1280">
            <BaseURL>https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/</BaseURL>
            <SegmentTemplate duration="368640" initialization="https://x-default-stgec.uplynk.com/ausw/slices/50e/e6cf0c55dac249f0a0f72e7c72e6f6cb/50e77f51a8f241baa0c0afa9a4185df4/$RepresentationID$_init.mp4?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" media="$RepresentationID$$Number%08d$.m4f?pbs=364227c83ab745a19bf72c8748bb8aa3&amp;drm=1&amp;cloud=aws&amp;si=0" startNumber="0" timescale="90000"></SegmentTemplate>
          </Representation>
    for this video you need to download:
    init: E_init.mp4
    segments: E00000000.m4f, E00000001.m4f, E00000002.m4f, ... , E00000618.m4f

    i tried and in total it's about 952mb

    concat them all together and decrypt with the key that's paired with kid 3a48357b1e694004a859475e6052b71c
    Last edited by tamagoyaki; 13th May 2021 at 04:22.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!