Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize output files for hls+dash #2769

Closed
MarianoFacundoArch opened this issue Feb 29, 2024 · 13 comments
Closed

Organize output files for hls+dash #2769

MarianoFacundoArch opened this issue Feb 29, 2024 · 13 comments

Comments

@MarianoFacundoArch
Copy link

Is there any way to organize better the output files for an hls+dash packing?
The output by default is a little bit messy:
image

Wouldn't it better to have a folder per track, and inside each folder the m3u8 of that track, and the main index.m3u8 and index.mpd in the root folder?

@jeanlf
Copy link
Member

jeanlf commented Mar 1, 2024

You need to use the segment template for that, e.g. -o dash.mpd:template=$Type$/$Number$ - note however that by default variant playlists are stored in same directory as master playlist.

I did a few updates on master to handle this use case: templates are now relative to variant playlist for HLS, and you can use templating in playlist names:

gpac -i av.mp4:#HLSPL=$Type$/index.m3u8 -o dash/live.m3u8:template=$Number$

will generate audio/index.m3u8, audio/init.mp4, audio/1.m4s ... and same for video

@jeanlf jeanlf closed this as completed Mar 1, 2024
@MarianoFacundoArch
Copy link
Author

And what if there are more than one audio or video track?

@MarianoFacundoArch
Copy link
Author

I mean, it is not working for me in that case. I have several audio and video tracks, somewhere like the organization that bento4 does is what I'd like to achieve: a folder per track and inside each folder the corresponding index.m3u8 in the case of HLS.
My command, right now, without adding the new options as it was not working for me in the last release, looks like this:

-i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/video_h264_720_vcrf_23.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d49c34f2dad.xml:FID=SRC1::#HLSKey=skd://65e68e3e3e5691442e9f5d49c34f2dad",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/video_h264_480_vb_1500k.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d4a73aa11b0.xml:FID=SRC2::#HLSKey=skd://65e68e3e3e5691442e9f5d4a73aa11b0",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/video_h264_360_vb_1M.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d4bb47139e6.xml:FID=SRC3::#HLSKey=skd://65e68e3e3e5691442e9f5d4bb47139e6",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/video_h264_240_vb_500k.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d4c0d0133dd.xml:FID=SRC4::#HLSKey=skd://65e68e3e3e5691442e9f5d4c0d0133dd",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/video_h264_1080_vcrf_21.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d4d2c2e0667.xml:FID=SRC5::#HLSKey=skd://65e68e3e3e5691442e9f5d4d2c2e0667",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/audio_aac_ab_64k_asr_44100_ac_1.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d4ea61df80a.xml:FID=SRC6::#HLSKey=skd://65e68e3e3e5691442e9f5d4ea61df80a",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -i /tmp/65e617c3f9d1154356eabd4c/temp/transcoded/audio_aac_ab_128k_asr_44100_ac_2.mp4 @ cecrypt:cfile=/tmp/65e617c3f9d1154356eabd4c/temp/drm/drmSpecs/65e68e3e3e5691442e9f5d4f1f1824d7.xml:FID=SRC7::#HLSKey=skd://65e68e3e3e5691442e9f5d4f1f1824d7",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1 -o /tmp/65e617c3f9d1154356eabd4c/temp/drm/protected/index.mpd:dual:segdur=2:SID=SRC1,SRC2,SRC3,SRC4,SRC5,SRC6,SRC7:profile=main:title=Demo Manifest::info=https://www.demo.com

@rbouqueau
Copy link
Member

You don't need to use $Type$ only. You can use other properties such as PID. Does it help?

@MarianoFacundoArch
Copy link
Author

I am still lost, I am trying to end in a result like the following one generated by the other popular tool:
image

It basically has an index.m3u8 in the main directory, like the main dash manifest. Then a folder for audio, another folder for video, and inside those folders a folder with the track number of that kind (video or audio) and inside that folder the chunks and the m3u8 index for that specific track.

@rbouqueau
Copy link
Member

$ gpac -i /home/rbouqueau/works/fk-encode/signals/data/beepbop.mp4:#HLSPL='$ID$'/index.m3u8 -o hls/live.m3u8:template='$Number$':dual

$ ls -lR hls
hls:
total 16
drwxr-xr-x 2 rbouqueau rbouqueau 4096  8 mars  16:04 1
drwxr-xr-x 2 rbouqueau rbouqueau 4096  8 mars  16:04 2
-rw-r--r-- 1 rbouqueau rbouqueau  277  8 mars  16:04 live.m3u8
-rw-r--r-- 1 rbouqueau rbouqueau 1375  8 mars  16:04 live.mpd

hls/1:
total 28
-rw-r--r-- 1 rbouqueau rbouqueau 2221  8 mars  16:04 1.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 2335  8 mars  16:04 2.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 2365  8 mars  16:04 3.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 2417  8 mars  16:04 4.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 2507  8 mars  16:04 5.m4s
-rw-r--r-- 1 rbouqueau rbouqueau  263  8 mars  16:04 index.m3u8
-rw-r--r-- 1 rbouqueau rbouqueau  861  8 mars  16:04 init.mp4

hls/2:
total 60
-rw-r--r-- 1 rbouqueau rbouqueau 7560  8 mars  16:04 1.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 7774  8 mars  16:04 2.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 8394  8 mars  16:04 3.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 8871  8 mars  16:04 4.m4s
-rw-r--r-- 1 rbouqueau rbouqueau 8975  8 mars  16:04 5.m4s
-rw-r--r-- 1 rbouqueau rbouqueau  231  8 mars  16:04 index.m3u8
-rw-r--r-- 1 rbouqueau rbouqueau  965  8 mars  16:04 init.mp4

Is it what you expect?

@MarianoFacundoArch
Copy link
Author

It's not quite the same. I would like to first have a folder on what type of track it is.
For example:

/live.m3u8 >> Main index

Video tracks and files
video/1/index.m3u8
video/2/index.m3u8

Audio tracks and files
audio/1/index.m3u8
audio/2/index.m3u8

Have I explained my self correctly?
I want to clearly have an independent folder of video and audio tracks, so it is able to be detected later on with lambda functions

@MarianoFacundoArch
Copy link
Author

I came to a good approach, however when trying to use it with Drm the problem is that $Type$ resolves to crypt instead of 'audio' or 'video'
Is there any solution to that?

@rbouqueau
Copy link
Member

The stream type is stored as GF_PROP_PID_ORIG_STREAM_TYPE but using $OrigStreamType$ (e.g. gpac -i beepbop.mp4:#HLSPL='$OrigStreamType$/$ID$'/index.m3u8 cecrypt:cfile=DRM.xml -o hls/live.m3u8:template='$Number$':dual) isn't mapped. It outputs a number instead.

jeanlf added a commit that referenced this issue Mar 13, 2024
@jeanlf
Copy link
Member

jeanlf commented Mar 13, 2024

came to a good approach, however when trying to use it with Drm the problem is that resolves to crypt instead of 'audio' or 'video'

Using latest master, use OType instead of Type, this will resolve to audio/video even when stream is encrypted

@rbouqueau
Copy link
Member

@jeanlf Why does GPAC limit the properties it resolves? I understand we may need to add identifiers, but why remove some? And why rename some (which makes it harder to remember)?

@jeanlf
Copy link
Member

jeanlf commented Mar 13, 2024

it does not, see http://wiki.gpac.io/Filters/filters_general/#url-templating

But we have aliases for a few properties, as documented in above link.

@MarianoFacundoArch
Copy link
Author

@jeanlf Just in case we missed this, there is a bug in naming audio segments:
#2773

gorinje pushed a commit to Bevara/Access-open that referenced this issue Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants