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

question for segment/resegment #319

Closed
joyhope opened this issue Jan 22, 2024 · 7 comments
Closed

question for segment/resegment #319

joyhope opened this issue Jan 22, 2024 · 7 comments

Comments

@joyhope
Copy link

joyhope commented Jan 22, 2024

I think segment and resegment should be a pair application. Whether current is an only demo.

Currently the segment app will output many segment files for xxx_a1_$num, xxx_v1_$num, but the resegment app is unable to combine all the files to one file.

If it is a pair app, it seems more understandable.

I do not know how to combine the multi-segment files back to one file.

@tobbee
Copy link
Collaborator

tobbee commented Jan 22, 2024

You just concatenate an init segment with the media segments to get a multi-segment file

cat init.mp4 *.m4s > combined.mp4

That file can be played with ffplay or other tools.

You can even do it on the fly like cat init.mp4 *.m4s | ffplay -.

Of course, if you have many segment files you must add the one-digit segments before the two-digit ones etc:

cat init.mp4 ?.m4s ??.m4s ???.m4s| ffplay -

@joyhope
Copy link
Author

joyhope commented Jan 23, 2024

For the mp4 without audio, the command cat init.mp4 *.m4s > combined.mp4 works!!!

But for the mp4 with audio and video, what is the proper combine sequence?

xx_v1_init.mp4 xx_a1_init.mp4 xxx_v1_01.m4s xxx_a1_01.m4s ... ,

@joyhope
Copy link
Author

joyhope commented Jan 23, 2024

I have a problem with combining both audio and video segments. help for how to combine the segment files.

@tobbee
Copy link
Collaborator

tobbee commented Jan 23, 2024

Typically you should not combine them if they are segmented. That is the approach that DASH-IF and HLS are taking for VoD assets. Not combining them gives much more possibilities for bitrate adaptation and combinations of languages and that is what ABR streaming is about.

If you combine them, you need to make a multiplexed init segment with different tracks for audio and video.
There are mp4ff functions that can be used, but you need to know what you're doing.

I would suggest that you use MP4Box for the job. After you have joined the video segments into v.mp4 and audio segments into a.mp4, use MP4Box like

MP4Box -add v.mp4 -add a.mp4 av.mp4

and you will have a combined (progressive) mp4 file.

@joyhope
Copy link
Author

joyhope commented Jan 24, 2024

My question: For the fragment MP4 with audio and video, there is no such single file for the player to play. Is it true?

As my previous understanding, the segment app could separate the progress the MP4 file into segments. It is suitable for the player. The resegment could combine the segment files into one, so it is easy to contribute. (I think it is a wrong understanding.)

@tobbee
Copy link
Collaborator

tobbee commented Jan 24, 2024

Sure, you can have multiplexed segments with both audio and video in the same segment. They will be different tracks defined in the init segment with two different trak boxes and then specified with two different traf boxes in the media segments.

I wrote some code Python code for multiplexing segments a long time ago. That code is available at https://github.com/Dash-Industry-Forum/dash-live-source-simulator/blob/develop/dashlivesim/dashlib/segmentmuxer.py

@joyhope
Copy link
Author

joyhope commented Jan 24, 2024

Thank you for help

@tobbee tobbee closed this as completed Feb 1, 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

2 participants