DASH 미디어 생성 다음 명령을 실행한다.
1 2 3 4 ffmpeg -i f:\test-videos\bigbuckbunny.mp4 -c copy \ -media_seg_name "bigbuckbunny$RepresentationID$-$Number %05d$.$ext$" \ above-init_seg_name "bigbuckbunny$RepresentationID$.$ext$" \ -f dash bigbuckbunny.mpd
bigbuckbunny.mp4 영상을 remuxing 을 통해서 DASH 서비스를 위한 bigbuckbunny.mpd 및 관련 segment 영상을 만든다.
segment 영상은 최초의 것(init_seg_name)과 나머지 것(media_seg_name)으로 분류되어 생성된다. ffmpeg 에서 디폴트로 최초 세그먼트 영상은,
init-stream$RepresentationID$.$ext$,
나머지 세그먼트 영상은,
chunk-stream$RepresentationID$-$Number%05d$.$ext$
으로 설정되어 있다.
-media_seg_name 옵션과 -init_seg_name 옵션을 이용해서 이름을 변경할 수 있다.
생성된 mpd 설정 파일의 예
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?xml version="1.0" encoding="utf-8" ?> ... <Period id ="0" start ="PT1M0.0S" > <AdaptationSet id ="0" contentType ="video" startWithSAP ="1" segmentAlignment ="true" bitstreamSwitching ="true" frameRate ="24/1" maxWidth ="1280" maxHeight ="720" par ="16:9" lang ="und" > <Representation id ="0" mimeType ="video/mp4" codecs ="avc1.64001f" bandwidth ="1991287" width ="1280" height ="720" scanType ="unknown" sar ="1:1" > <SegmentTemplate timescale ="12288" initialization ="bigbuckbunny$RepresentationID$.m4s" media ="bigbuckbunny$RepresentationID$-$Number%05d$.m4s" startNumber ="1" > <SegmentTimeline > <S t ="0" d ="2974720" /> <S d ="2971136" /> <S d ="1383424" /> </SegmentTimeline > </SegmentTemplate > </Representation > </AdaptationSet > <AdaptationSet id ="1" contentType ="audio" startWithSAP ="1" segmentAlignment ="true" bitstreamSwitching ="true" lang ="und" > <Representation id ="1" mimeType ="audio/mp4" codecs ="mp4a.40.2" bandwidth ="125587" audioSamplingRate ="44100" > <AudioChannelConfiguration schemeIdUri ="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value ="2" /> <SegmentTemplate timescale ="44100" initialization ="bigbuckbunny$RepresentationID$.m4s" media ="bigbuckbunny$RepresentationID$-$Number%05d$.m4s" startNumber ="1" > <SegmentTimeline > <S t ="0" d ="10584064" r ="1" /> <S d ="5136384" /> </SegmentTimeline > </SegmentTemplate > </Representation > </AdaptationSet > </Period > ...
multiple period 를 설정하기 위해서는 Period 태그를 유심히 봐야 한다.
start="PT1M0.0S" 로 속성값을 지정했는데, 영상이 시작되는 시간을 의미한다. P 다음에는 날짜 정보가 오는데, 불필요해서 생략한 것 같다. T 다음에는 시간 정보가 오는데 1H2M3.4S 와 같이 표기한다. H는 시간, M은 분, S는 초를 의미한다.
SegmentTimeline 태그 내에는 각 세그먼트에 대한 재생 기간 정보를 가지고 있다. SegmentTemplate 태그의 timescale 속성 기반으로 시간 정보가 만들어지는 것 같다. 영상은 확실히 기간/timescale 값으로 초단위 값을 구할 수 있다. 음성에 대해서는 그렇지 않는 것으로 봐서, 스테레오 신호와 연관이 있는 것이 아닌가 예상된다.
multiple period 의 구성 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?xml version="1.0" encoding="utf-8" ?> ... <Period id ="0" start ="PT0.0S" > <AdaptationSet id ="0" contentType ="video" startWithSAP ="1" segmentAlignment ="true" bitstreamSwitching ="true" frameRate ="24000/1001" maxWidth ="1920" maxHeight ="1080" par ="16:9" lang ="und" > <Representation id ="0" mimeType ="video/mp4" codecs ="avc1.640028" bandwidth ="1664304" width ="1920" height ="1080" scanType ="unknown" sar ="1:1" > <SegmentTemplate timescale ="24000" initialization ="sunrise$RepresentationID$.m4s" media ="sunrise$RepresentationID$-$Number%05d$.m4s" startNumber ="1" > <SegmentTimeline > <S t ="0" d ="5632627" /> </SegmentTimeline > </SegmentTemplate > </Representation > </AdaptationSet > </Period > <Period id ="1" start ="PT3M54.6S" > <AdaptationSet id ="0" contentType ="video" startWithSAP ="1" segmentAlignment ="true" bitstreamSwitching ="true" frameRate ="24/1" maxWidth ="1280" maxHeight ="720" par ="16:9" lang ="und" > <Representation id ="0" mimeType ="video/mp4" codecs ="avc1.64001f" bandwidth ="1991287" width ="1280" height ="720" scanType ="unknown" sar ="1:1" > <SegmentTemplate timescale ="12288" initialization ="bigbuckbunny$RepresentationID$.m4s" media ="bigbuckbunny$RepresentationID$-$Number%05d$.m4s" startNumber ="1" > <SegmentTimeline > <S t ="0" d ="2974720" /> <S d ="2971136" /> <S d ="1383424" /> </SegmentTimeline > </SegmentTemplate > </Representation > </AdaptationSet > </Period > ...
Period를 추가해서 여러 개의 영상을 연달아 재생하도록 할 수 있다. 이 때 추가한 Period 의 start 속성값이 중요하게 되는데, 이전 영상들의 총 재생기간을 추가해서 작성해주면 된다. SegmentTimeline 의 t 값은 건드릴 필요없다.