Commit 50bad3ee authored by Steve Lhomme's avatar Steve Lhomme

mux:mp4: the duration passed to mp4mux_GetMoovBox() is an mtime_t

We then scale it to the movie and use it scaled.
parent 6bdb25e2
...@@ -1398,7 +1398,7 @@ static bo_t *GetStblBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b ...@@ -1398,7 +1398,7 @@ static bo_t *GetStblBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
} }
bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks, bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
int64_t i_movie_duration, mtime_t i_duration,
bool b_fragmented, bool b_mov, bool b_64_ext, bool b_stco64 ) bool b_fragmented, bool b_mov, bool b_64_ext, bool b_stco64 )
{ {
bo_t *moov, *mvhd; bo_t *moov, *mvhd;
...@@ -1415,17 +1415,16 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un ...@@ -1415,17 +1415,16 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
if(!moov) if(!moov)
return NULL; return NULL;
/* Create general info */ /* Create general info */
if( i_movie_duration == 0 && !b_fragmented ) if( i_duration == 0 && !b_fragmented )
{ {
for (unsigned int i = 0; i < i_tracks; i++) { for (unsigned int i = 0; i < i_tracks; i++) {
mp4mux_trackinfo_t *p_stream = pp_tracks[i]; mp4mux_trackinfo_t *p_stream = pp_tracks[i];
i_movie_duration = __MAX(i_movie_duration, p_stream->i_read_duration); i_duration = __MAX(i_duration, p_stream->i_read_duration);
} }
if(p_obj) if(p_obj)
msg_Dbg(p_obj, "movie duration %"PRId64"s", i_movie_duration / CLOCK_FREQ); msg_Dbg(p_obj, "movie duration %"PRId64"s", i_duration / CLOCK_FREQ);
i_movie_duration = i_movie_duration * i_movie_timescale / CLOCK_FREQ;
} }
int64_t i_movie_duration = i_duration * i_movie_timescale / CLOCK_FREQ;
/* *** add /moov/mvhd *** */ /* *** add /moov/mvhd *** */
if (!b_64_ext) { if (!b_64_ext) {
...@@ -1796,9 +1795,9 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un ...@@ -1796,9 +1795,9 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
if(mehd) if(mehd)
{ {
if(b_64_ext) if(b_64_ext)
bo_add_64be(mehd, i_movie_duration * i_movie_timescale / CLOCK_FREQ); bo_add_64be(mehd, i_movie_duration);
else else
bo_add_32be(mehd, i_movie_duration * i_movie_timescale / CLOCK_FREQ); bo_add_32be(mehd, i_movie_duration);
box_gather(mvex, mehd); box_gather(mvex, mehd);
} }
} }
......
...@@ -85,5 +85,5 @@ void box_gather (bo_t *box, bo_t *box2); ...@@ -85,5 +85,5 @@ void box_gather (bo_t *box, bo_t *box2);
bool mp4mux_CanMux(vlc_object_t *, const es_format_t *, vlc_fourcc_t, bool); bool mp4mux_CanMux(vlc_object_t *, const es_format_t *, vlc_fourcc_t, bool);
bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc); bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc);
bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks, bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
int64_t i_movie_duration, mtime_t i_movie_duration,
bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64); bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment