summaryrefslogtreecommitdiff
path: root/ffmpeg/tools/ismindex.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/tools/ismindex.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/tools/ismindex.c')
-rw-r--r--ffmpeg/tools/ismindex.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/ffmpeg/tools/ismindex.c b/ffmpeg/tools/ismindex.c
index 502a7dc..4dc3e12 100644
--- a/ffmpeg/tools/ismindex.c
+++ b/ffmpeg/tools/ismindex.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2012 Martin Storsjo
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -34,15 +34,11 @@
#include <stdio.h>
#include <string.h>
-#include <sys/stat.h>
-#ifdef _WIN32
-#include <direct.h>
-#define mkdir(a, b) _mkdir(a)
-#endif
#include "cmdutils.h"
#include "libavformat/avformat.h"
+#include "libavformat/os_support.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
@@ -55,7 +51,7 @@ static int usage(const char *argv0, int ret)
struct MoofOffset {
int64_t time;
int64_t offset;
- int duration;
+ int64_t duration;
};
struct Track {
@@ -132,7 +128,8 @@ static int write_fragments(struct Tracks *tracks, int start_index,
struct Track *track = tracks->tracks[i];
const char *type = track->is_video ? "video" : "audio";
snprintf(dirname, sizeof(dirname), "QualityLevels(%d)", track->bitrate);
- mkdir(dirname, 0777);
+ if (mkdir(dirname, 0777) == -1)
+ return AVERROR(errno);
for (j = 0; j < track->chunks; j++) {
snprintf(filename, sizeof(filename), "%s/Fragments(%s=%"PRId64")",
dirname, type, track->offsets[j].time);
@@ -224,7 +221,7 @@ static int read_mfra(struct Tracks *tracks, int start_index,
}
if (split)
- write_fragments(tracks, start_index, f);
+ err = write_fragments(tracks, start_index, f);
fail:
if (f)
@@ -301,8 +298,6 @@ static int handle_file(struct Tracks *tracks, const char *file, int split)
fprintf(stderr, "No streams found in %s\n", file);
goto fail;
}
- if (!tracks->duration)
- tracks->duration = ctx->duration;
for (i = 0; i < ctx->nb_streams; i++) {
struct Track **temp;
@@ -329,8 +324,7 @@ static int handle_file(struct Tracks *tracks, const char *file, int split)
track->bitrate = st->codec->bit_rate;
track->track_id = st->id;
track->timescale = st->time_base.den;
- track->duration = av_rescale_rnd(ctx->duration, track->timescale,
- AV_TIME_BASE, AV_ROUND_UP);
+ track->duration = st->duration;
track->is_audio = st->codec->codec_type == AVMEDIA_TYPE_AUDIO;
track->is_video = st->codec->codec_type == AVMEDIA_TYPE_VIDEO;
@@ -342,6 +336,10 @@ static int handle_file(struct Tracks *tracks, const char *file, int split)
continue;
}
+ tracks->duration = FFMAX(tracks->duration,
+ av_rescale_rnd(track->duration, AV_TIME_BASE,
+ track->timescale, AV_ROUND_UP));
+
if (track->is_audio) {
if (tracks->audio_track < 0)
tracks->audio_track = tracks->nb_tracks;
@@ -433,7 +431,7 @@ static void print_track_chunks(FILE *out, struct Tracks *tracks, int main,
fprintf(stderr, "Mismatched duration of %s chunk %d in %s and %s\n",
type, i, track->name, tracks->tracks[j]->name);
}
- fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n",
+ fprintf(out, "\t\t<c n=\"%d\" d=\"%"PRId64"\" />\n",
i, track->offsets[i].duration);
}
}