Eyevinn / mp4ff

Library and tools for parsing and writing MP4 files including video, audio and subtitles. The focus is on fragmented files. Includes mp4ff-info, mp4ff-encrypt, mp4ff-decrypt and other tools.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

question for segment/resegment

joyhope opened this issue · comments

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.

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 -

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 ... ,

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

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.

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.)

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

Thank you for help