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

Add movie duration and track media duration retrieved from input_file #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions Source/C++/Apps/Mp4Fragment/Mp4Fragment.cpp
Expand Up @@ -102,9 +102,9 @@ PrintUsageAndExit()
static double
strtof(char* s, char** /* end */)
{
_CRT_DOUBLE value = {0.0};
_CRT_DOUBLE value = {0.0};
int result = _atodbl(&value, s);
return result == 0 ? (double)value.x : 0.0;
return result == 0 ? (double)value.x : 0.0;
}
#endif

Expand Down Expand Up @@ -320,12 +320,16 @@ Fragment(AP4_File& input_file,
return;
}

AP4_UI64 movie_duration = AP4_ConvertTime(input_movie->GetDuration(),
input_movie->GetTimeScale(),
timescale ? timescale : AP4_FRAGMENTER_OUTPUT_MOVIE_TIMESCALE);

// create the output file object
AP4_Movie* output_movie = new AP4_Movie(AP4_FRAGMENTER_OUTPUT_MOVIE_TIMESCALE);
AP4_Movie* output_movie = new AP4_Movie(timescale ? timescale : AP4_FRAGMENTER_OUTPUT_MOVIE_TIMESCALE, movie_duration);

// create an mvex container
AP4_ContainerAtom* mvex = new AP4_ContainerAtom(AP4_ATOM_TYPE_MVEX);
AP4_MehdAtom* mehd = new AP4_MehdAtom(0);
AP4_MehdAtom* mehd = new AP4_MehdAtom(movie_duration);
mvex->AddChild(mehd);

// add an output track for each track in the input file
Expand Down Expand Up @@ -353,7 +357,9 @@ Fragment(AP4_File& input_file,
input_movie->GetTimeScale(),
timescale?timescale:AP4_FRAGMENTER_OUTPUT_MOVIE_TIMESCALE),
timescale?timescale:track->GetMediaTimeScale(),
0,//track->GetMediaDuration(),
AP4_ConvertTime(track->GetMediaDuration(),
track->GetMediaTimeScale(),
timescale ? timescale : 1000),
track);

// add an edit list if needed
Expand Down