gpac / gpac

GPAC Ultramedia OSS for Video Streaming & Next-Gen Multimedia Transcoding, Packaging & Delivery
https://gpac.io
GNU Lesser General Public License v2.1
2.72k stars 530 forks source link

Timing issue in EBU-TT-D subtitles when declared in a span #192

Closed SoleneChiche closed 9 years ago

SoleneChiche commented 9 years ago

Hello,

I am having troubles when I dash an EBU-TT-D document which declares timings not from p but from span:

<?xml version="1.0" encoding="UTF-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:tts="http://www.w3.org/ns/ttml#styling" ttp:timeBase="media" xml:lang="en" ttp:cellResolution="50 30">
    <head>
        <styling>       
            <style xml:id="paragraphStyle" tts:textAlign="center" tts:color="#FFFFFF" tts:backgroundColor="#000000" tts:fontSize="130%" tts:fontFamily="monospace"/>
            <style xml:id="blueBackground" tts:backgroundColor="#0000FF"/>          
        </styling>
        <layout>
            <region xml:id="timing" tts:origin="5% 75%" tts:extent="90% 15%" tts:displayAlign="center" style="blueBackground"/>
        </layout>
    </head>
    <body>
        <div>
            <p xml:id="subtitle1" region="timing" style="paragraphStyle"><span begin="00:00:04.000" end="00:00:12.000">Hello World, how are you doing? (span begin: 4.000, span end: 12.000)</span></p>
        </div>
    </body>
</tt>

At receival, I'll only get a sample with cts/dts 0 and duration 8000, instead of having the cst/dts 4000. Any idea why?

Thanks

rbouqueau commented 9 years ago

Yes, I can reproduce. The first sample start timestamp is always 0 in MP4. I'll let you know here.

@cconcolato :

                                if (!nb_samples) {
                                    s->DTS = 0; /*in MP4 we must start at T=0*/
                                } else {
                                    s->DTS = ts_begin;
                                }
SoleneChiche commented 9 years ago

By the way, I thought it was only for span, but it is also the case for a p.

rbouqueau commented 9 years ago

I fixed an issue when the first sample begin time is not zero. Now, with your example, we'll have a sample duration of 12 seconds (4s of void + 8s of content). Is it consistent with your expectations?

SoleneChiche commented 9 years ago

It should be consistent yes. Thanks

SoleneChiche commented 9 years ago

@rbouqueau Is it available in the latest nighty build for Mac 64 bit? version 0.5.2-DEV-rev534-g2cc7d80-master This is the latest version that I'm using and I'm not sure if it does contain the patch. Thanks

rbouqueau commented 9 years ago

Yes it contains the patch. To check the sample timings, I use 'MP4Box -diso file.mp4'. To check the content with EBU-TTD, I open the MP4 file directly in a text editor :)

Let me know if you have questions.

SoleneChiche commented 9 years ago

I don't know if it's me, but I still get a cts/dts of 0...:

Here is my mp4:

ftypisomisom+moovlmvhd—€◊—€◊X¿@∑trak\tkhd—€◊—€◊¿@Smdia mdhd—€◊—€◊Ë@UƒShdlrsubt*xml:ext=ttml@GPAC0.5.2-DEV-rev534-g2cc7d80-masterÿminfsthd$dinfdrefurl †stbl<stsd,stpphttp://www.w3.org/ns/ttmlstts@stscstsz6stcoG>mdat<tt xmlns="http://www.w3.org/ns/ttml" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:tts="http://www.w3.org/ns/ttml#styling" ttp:timeBase="media" xml:lang="en" ttp:cellResolution="50 30" >
    <head >
        <styling >      
            <style xml:id="paragraphStyle" tts:textAlign="center" tts:color="#FFFFFF" tts:backgroundColor="#000000" tts:fontSize="130%" tts:fontFamily="monospace" />
            <style xml:id="blueBackground" tts:backgroundColor="#0000FF" />         
        </styling>
        <layout >
            <region style="blueBackground" tts:origin="5% 75%" tts:extent="90% 15%" tts:displayAlign="center" xml:id="timing" />
        </layout>
    </head>
    <body >
        <div ><p style="paragraphStyle" region="timing" begin="00:00:04.000" end="00:00:12.000" xml:id="subtitle1" >Hello World, how are you doing? (p begin: 4.000, p end: 12.000)</p></div>
    </body>
</tt>JfreeIsoMedia File Produced with GPAC 0.5.2-DEV-rev534-g2cc7d80-master

But my sample info at receival:

cts: 0
dts: 0
duration: 8000
offset: 104
size: 822

And my test_info.mp4:

<?xml version="1.0" encoding="UTF-8"?>
<!--MP4Box dump trace-->
<IsoMediaFile Name="test45.mp4">
<FileTypeBox MajorBrand="isom" MinorVersion="1">
<BoxInfo Size="20" Type="ftyp"/>
<BrandEntry AlternateBrand="isom"/>
</FileTypeBox>
<MovieBox>
<BoxInfo Size="555" Type="moov"/>
<MovieHeaderBox CreationTime="3520845592" ModificationTime="3520845592" TimeScale="600" Duration="4800" NextTrackID="2">
<BoxInfo Size="108" Type="mvhd"/>
<FullBoxInfo Version="0" Flags="0x0"/>
</MovieHeaderBox>
<TrackBox>
<BoxInfo Size="439" Type="trak"/>
<TrackHeaderBox CreationTime="3520845592" ModificationTime="3520845592" TrackID="1" Duration="4800">
<BoxInfo Size="92" Type="tkhd"/>
<FullBoxInfo Version="0" Flags="0x1"/>
</TrackHeaderBox>
<MediaBox>
<BoxInfo Size="339" Type="mdia"/>
<MediaHeaderBox CreationTime="3520845592" ModificationTime="3520845592" TimeScale="1000" Duration="8000" LanguageCode="und">
<BoxInfo Size="32" Type="mdhd"/>
<FullBoxInfo Version="0" Flags="0x0"/>
</MediaHeaderBox>
<HandlerBox Type="subt" Name="*xml:ext=ttml@GPAC0.5.2-DEV-rev534-g2cc7d80-master" reserved1="0" reserved2="data:application/octet-string,000000000000000000000000">
<BoxInfo Size="83" Type="hdlr"/>
<FullBoxInfo Version="0" Flags="0x0"/>
</HandlerBox>
<MediaInformationBox>
<BoxInfo Size="216" Type="minf"/>
<MPEGMediaHeaderBox>
<BoxInfo Size="12" Type="sthd"/>
<FullBoxInfo Version="0" Flags="0x0"/>
</MPEGMediaHeaderBox>
<DataInformationBox><BoxInfo Size="36" Type="dinf"/>
<DataReferenceBox>
<BoxInfo Size="28" Type="dref"/>
<FullBoxInfo Version="0" Flags="0x0"/>
<URLDataEntryBox>
<!--Data is contained in the movie file-->
<BoxInfo Size="12" Type="url "/>
<FullBoxInfo Version="0" Flags="0x1"/>
</URLDataEntryBox>
</DataReferenceBox>
</DataInformationBox>
<SampleTableBox>
<BoxInfo Size="160" Type="stbl"/>
<SampleDescriptionBox>
<BoxInfo Size="60" Type="stsd"/>
<FullBoxInfo Version="0" Flags="0x0"/>
<XMLSubtitleSampleEntryBox namespace="http://www.w3.org/ns/ttml" >
<BoxInfo Size="44" Type="stpp"/>
</XMLSubtitleSampleEntryBox>
</SampleDescriptionBox>
<TimeToSampleBox EntryCount="1">
<BoxInfo Size="24" Type="stts"/>
<FullBoxInfo Version="0" Flags="0x0"/>
<TimeToSampleEntry SampleDelta="8000" SampleCount="1"/>
<!-- counted 1 samples in STTS entries -->
</TimeToSampleBox>
<SampleToChunkBox EntryCount="1">
<BoxInfo Size="28" Type="stsc"/>
<FullBoxInfo Version="0" Flags="0x0"/>
<SampleToChunkEntry FirstChunk="1" SamplesPerChunk="1" SampleDescriptionIndex="1"/>
<!-- counted 1 samples in STSC entries (could be less than sample count) -->
</SampleToChunkBox>
<SampleSizeBox SampleCount="1" ConstantSampleSize="822">
<BoxInfo Size="20" Type="stsz"/>
<FullBoxInfo Version="0" Flags="0x0"/>
</SampleSizeBox>
<ChunkOffsetBox EntryCount="1">
<BoxInfo Size="20" Type="stco"/>
<FullBoxInfo Version="0" Flags="0x0"/>
<ChunkEntry offset="583"/>
</ChunkOffsetBox>
</SampleTableBox>
</MediaInformationBox>
</MediaBox>
</TrackBox>
</MovieBox>
<MediaDataBox dataSize="822">
<BoxInfo Size="830" Type="mdat"/>
</MediaDataBox>
<FreeSpaceBox size="66">
<BoxInfo Size="74" Type="free"/>
</FreeSpaceBox>
</IsoMediaFile>
SoleneChiche commented 9 years ago

Just to confirm. It is now working great.

Thanks for the fix.

rbouqueau commented 9 years ago

@SoleneBuet FYI I did it: http://gpac.io/2015/07/29/gpac-build-mp4box-only-all-platforms/ Feedbacks welcome :)

SoleneChiche commented 9 years ago

Easy as peasy! Just "(‘port’ or ‘homebrew’ of ‘fink’)" does not make sense to me... And the question is: in what situation would you have to clean your build? A small precision in this paragraph could be useful. Otherwise, it is great!

rbouqueau commented 9 years ago

Thanks, your feedback is now part of the article :)