2012-01-09 17:27:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 Martin Storsjo
|
|
|
|
*
|
2013-08-15 23:12:51 +02:00
|
|
|
* This file is part of FFmpeg.
|
2012-01-09 17:27:33 +01:00
|
|
|
*
|
2013-08-15 23:12:51 +02:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-01-09 17:27:33 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2013-08-15 23:12:51 +02:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-01-09 17:27:33 +01:00
|
|
|
* 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
|
2013-08-15 23:12:51 +02:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-01-09 17:27:33 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To create a simple file for smooth streaming:
|
2012-05-27 15:34:47 +02:00
|
|
|
* ffmpeg <normal input/transcoding options> -movflags frag_keyframe foo.ismv
|
2012-01-09 17:27:33 +01:00
|
|
|
* ismindex -n foo foo.ismv
|
|
|
|
* This step creates foo.ism and foo.ismc that is required by IIS for
|
|
|
|
* serving it.
|
|
|
|
*
|
2014-09-04 17:09:46 +02:00
|
|
|
* With -ismf, it also creates foo.ismf, which maps fragment names to
|
|
|
|
* start-end offsets in the ismv, for use in your own streaming server.
|
|
|
|
*
|
2014-07-02 21:44:32 +02:00
|
|
|
* By adding -path-prefix path/, the produced foo.ism will refer to the
|
|
|
|
* files foo.ismv as "path/foo.ismv" - the prefix for the generated ismc
|
|
|
|
* file can be set with the -ismc-prefix option similarly.
|
|
|
|
*
|
2012-01-09 17:27:33 +01:00
|
|
|
* To pre-split files for serving as static files by a web server without
|
|
|
|
* any extra server support, create the ismv file as above, and split it:
|
|
|
|
* ismindex -split foo.ismv
|
|
|
|
* This step creates a file Manifest and directories QualityLevel(...),
|
|
|
|
* that can be read directly by a smooth streaming player.
|
2014-07-02 22:02:58 +02:00
|
|
|
*
|
|
|
|
* The -output dir option can be used to request that output files
|
|
|
|
* (both .ism/.ismc, or Manifest/QualityLevels* when splitting)
|
|
|
|
* should be written to this directory instead of in the current directory.
|
|
|
|
* (The directory itself isn't created if it doesn't already exist.)
|
2012-01-09 17:27:33 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2012-01-25 15:03:18 +01:00
|
|
|
|
2013-02-27 18:13:09 +01:00
|
|
|
#include "cmdutils.h"
|
|
|
|
|
2012-01-09 17:27:33 +01:00
|
|
|
#include "libavformat/avformat.h"
|
2013-08-05 00:06:06 +02:00
|
|
|
#include "libavformat/os_support.h"
|
2012-01-09 17:27:33 +01:00
|
|
|
#include "libavutil/intreadwrite.h"
|
|
|
|
#include "libavutil/mathematics.h"
|
|
|
|
|
|
|
|
static int usage(const char *argv0, int ret)
|
|
|
|
{
|
2014-09-04 17:09:46 +02:00
|
|
|
fprintf(stderr, "%s [-split] [-ismf] [-n basename] [-path-prefix prefix] "
|
2014-07-02 22:02:58 +02:00
|
|
|
"[-ismc-prefix prefix] [-output dir] file1 [file2] ...\n", argv0);
|
2012-01-09 17:27:33 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MoofOffset {
|
|
|
|
int64_t time;
|
|
|
|
int64_t offset;
|
2013-10-04 09:14:49 +02:00
|
|
|
int64_t duration;
|
2012-01-09 17:27:33 +01:00
|
|
|
};
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
struct Track {
|
2012-01-09 17:27:33 +01:00
|
|
|
const char *name;
|
|
|
|
int64_t duration;
|
|
|
|
int bitrate;
|
|
|
|
int track_id;
|
|
|
|
int is_audio, is_video;
|
|
|
|
int width, height;
|
|
|
|
int chunks;
|
|
|
|
int sample_rate, channels;
|
|
|
|
uint8_t *codec_private;
|
|
|
|
int codec_private_size;
|
|
|
|
struct MoofOffset *offsets;
|
|
|
|
int timescale;
|
|
|
|
const char *fourcc;
|
|
|
|
int blocksize;
|
|
|
|
int tag;
|
|
|
|
};
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
struct Tracks {
|
|
|
|
int nb_tracks;
|
2012-01-09 17:27:33 +01:00
|
|
|
int64_t duration;
|
2013-03-13 10:42:34 +01:00
|
|
|
struct Track **tracks;
|
|
|
|
int video_track, audio_track;
|
|
|
|
int nb_video_tracks, nb_audio_tracks;
|
2012-01-09 17:27:33 +01:00
|
|
|
};
|
|
|
|
|
2014-09-04 17:09:46 +02:00
|
|
|
static int expect_tag(int32_t got_tag, int32_t expected_tag) {
|
|
|
|
if (got_tag != expected_tag) {
|
|
|
|
char got_tag_str[4], expected_tag_str[4];
|
|
|
|
AV_WB32(got_tag_str, got_tag);
|
|
|
|
AV_WB32(expected_tag_str, expected_tag);
|
|
|
|
fprintf(stderr, "wanted tag %.4s, got %.4s\n", expected_tag_str,
|
|
|
|
got_tag_str);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-09 17:27:33 +01:00
|
|
|
static int copy_tag(AVIOContext *in, AVIOContext *out, int32_t tag_name)
|
|
|
|
{
|
|
|
|
int32_t size, tag;
|
|
|
|
|
|
|
|
size = avio_rb32(in);
|
2012-01-25 15:03:18 +01:00
|
|
|
tag = avio_rb32(in);
|
2012-01-09 17:27:33 +01:00
|
|
|
avio_wb32(out, size);
|
|
|
|
avio_wb32(out, tag);
|
2014-09-04 17:09:46 +02:00
|
|
|
if (expect_tag(tag, tag_name) != 0)
|
2012-01-09 17:27:33 +01:00
|
|
|
return -1;
|
|
|
|
size -= 8;
|
|
|
|
while (size > 0) {
|
|
|
|
char buf[1024];
|
|
|
|
int len = FFMIN(sizeof(buf), size);
|
2014-09-01 15:16:49 +02:00
|
|
|
int got;
|
|
|
|
if ((got = avio_read(in, buf, len)) != len) {
|
|
|
|
fprintf(stderr, "short read, wanted %d, got %d\n", len, got);
|
2012-01-09 17:27:33 +01:00
|
|
|
break;
|
2014-09-01 15:16:49 +02:00
|
|
|
}
|
2012-01-09 17:27:33 +01:00
|
|
|
avio_write(out, buf, len);
|
|
|
|
size -= len;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:09:46 +02:00
|
|
|
static int skip_tag(AVIOContext *in, int32_t tag_name)
|
|
|
|
{
|
|
|
|
int64_t pos = avio_tell(in);
|
|
|
|
int32_t size, tag;
|
|
|
|
|
|
|
|
size = avio_rb32(in);
|
|
|
|
tag = avio_rb32(in);
|
|
|
|
if (expect_tag(tag, tag_name) != 0)
|
|
|
|
return -1;
|
|
|
|
avio_seek(in, pos + size, SEEK_SET);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-09 17:27:33 +01:00
|
|
|
static int write_fragment(const char *filename, AVIOContext *in)
|
|
|
|
{
|
|
|
|
AVIOContext *out = NULL;
|
|
|
|
int ret;
|
|
|
|
|
2014-09-01 15:16:49 +02:00
|
|
|
if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, NULL, NULL)) < 0) {
|
|
|
|
char errbuf[100];
|
|
|
|
av_strerror(ret, errbuf, sizeof(errbuf));
|
|
|
|
fprintf(stderr, "Unable to open %s: %s\n", filename, errbuf);
|
2012-01-09 17:27:33 +01:00
|
|
|
return ret;
|
2014-09-01 15:16:49 +02:00
|
|
|
}
|
|
|
|
ret = copy_tag(in, out, MKBETAG('m', 'o', 'o', 'f'));
|
|
|
|
if (!ret)
|
|
|
|
ret = copy_tag(in, out, MKBETAG('m', 'd', 'a', 't'));
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
avio_flush(out);
|
|
|
|
avio_close(out);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:09:46 +02:00
|
|
|
static int skip_fragment(AVIOContext *in)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
2014-09-04 17:09:46 +02:00
|
|
|
int ret;
|
|
|
|
ret = skip_tag(in, MKBETAG('m', 'o', 'o', 'f'));
|
|
|
|
if (!ret)
|
|
|
|
ret = skip_tag(in, MKBETAG('m', 'd', 'a', 't'));
|
|
|
|
return ret;
|
|
|
|
}
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2014-09-04 17:09:46 +02:00
|
|
|
static int write_fragments(struct Tracks *tracks, int start_index,
|
|
|
|
AVIOContext *in, const char *basename,
|
|
|
|
int split, int ismf, const char* output_prefix)
|
|
|
|
{
|
|
|
|
char dirname[2048], filename[2048], idxname[2048];
|
|
|
|
int i, j, ret = 0, fragment_ret;
|
|
|
|
FILE* out = NULL;
|
|
|
|
|
|
|
|
if (ismf) {
|
|
|
|
snprintf(idxname, sizeof(idxname), "%s%s.ismf", output_prefix, basename);
|
|
|
|
out = fopen(idxname, "w");
|
|
|
|
if (!out) {
|
|
|
|
ret = AVERROR(errno);
|
|
|
|
perror(idxname);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
for (i = start_index; i < tracks->nb_tracks; i++) {
|
|
|
|
struct Track *track = tracks->tracks[i];
|
|
|
|
const char *type = track->is_video ? "video" : "audio";
|
2014-07-02 22:02:58 +02:00
|
|
|
snprintf(dirname, sizeof(dirname), "%sQualityLevels(%d)", output_prefix, track->bitrate);
|
2014-09-04 17:09:46 +02:00
|
|
|
if (split) {
|
|
|
|
if (mkdir(dirname, 0777) == -1 && errno != EEXIST) {
|
|
|
|
ret = AVERROR(errno);
|
|
|
|
perror(dirname);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
for (j = 0; j < track->chunks; j++) {
|
2012-01-09 17:27:33 +01:00
|
|
|
snprintf(filename, sizeof(filename), "%s/Fragments(%s=%"PRId64")",
|
2013-03-13 10:42:34 +01:00
|
|
|
dirname, type, track->offsets[j].time);
|
|
|
|
avio_seek(in, track->offsets[j].offset, SEEK_SET);
|
2014-09-04 17:09:46 +02:00
|
|
|
if (ismf)
|
|
|
|
fprintf(out, "%s %"PRId64, filename, avio_tell(in));
|
|
|
|
if (split)
|
|
|
|
fragment_ret = write_fragment(filename, in);
|
|
|
|
else
|
|
|
|
fragment_ret = skip_fragment(in);
|
|
|
|
if (ismf)
|
|
|
|
fprintf(out, " %"PRId64"\n", avio_tell(in));
|
|
|
|
if (fragment_ret != 0) {
|
|
|
|
fprintf(stderr, "failed fragment %d in track %d (%s)\n", j,
|
|
|
|
track->track_id, track->name);
|
|
|
|
ret = fragment_ret;
|
|
|
|
}
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-04 17:09:46 +02:00
|
|
|
fail:
|
|
|
|
if (out)
|
|
|
|
fclose(out);
|
|
|
|
return ret;
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
static int read_tfra(struct Tracks *tracks, int start_index, AVIOContext *f)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
int ret = AVERROR_EOF, track_id;
|
|
|
|
int version, fieldlength, i, j;
|
2012-01-25 15:03:18 +01:00
|
|
|
int64_t pos = avio_tell(f);
|
2012-01-09 17:27:33 +01:00
|
|
|
uint32_t size = avio_rb32(f);
|
2013-03-13 10:42:34 +01:00
|
|
|
struct Track *track = NULL;
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
if (avio_rb32(f) != MKBETAG('t', 'f', 'r', 'a'))
|
|
|
|
goto fail;
|
|
|
|
version = avio_r8(f);
|
|
|
|
avio_rb24(f);
|
|
|
|
track_id = avio_rb32(f); /* track id */
|
2013-03-13 10:42:34 +01:00
|
|
|
for (i = start_index; i < tracks->nb_tracks && !track; i++)
|
|
|
|
if (tracks->tracks[i]->track_id == track_id)
|
|
|
|
track = tracks->tracks[i];
|
|
|
|
if (!track) {
|
2012-01-09 17:27:33 +01:00
|
|
|
/* Ok, continue parsing the next atom */
|
|
|
|
ret = 0;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
fieldlength = avio_rb32(f);
|
2013-03-13 10:42:34 +01:00
|
|
|
track->chunks = avio_rb32(f);
|
2014-05-05 18:40:55 +02:00
|
|
|
track->offsets = av_mallocz_array(track->chunks, sizeof(*track->offsets));
|
2013-03-13 10:42:34 +01:00
|
|
|
if (!track->offsets) {
|
2012-01-09 17:27:33 +01:00
|
|
|
ret = AVERROR(ENOMEM);
|
|
|
|
goto fail;
|
|
|
|
}
|
2014-09-14 18:00:56 +02:00
|
|
|
// The duration here is always the difference between consecutive
|
|
|
|
// start times and doesn't even try to read the actual duration of the
|
|
|
|
// media fragments. This is what other smooth streaming tools tend to
|
|
|
|
// do too, but cannot express missing fragments, and the start times
|
|
|
|
// may not match the stream metadata we get from libavformat. Correct
|
|
|
|
// calculation would require parsing the tfxd atom (if present, it's
|
|
|
|
// not mandatory) or parsing the full moof atoms separately.
|
2013-03-13 10:42:34 +01:00
|
|
|
for (i = 0; i < track->chunks; i++) {
|
2012-01-09 17:27:33 +01:00
|
|
|
if (version == 1) {
|
2013-03-13 10:42:34 +01:00
|
|
|
track->offsets[i].time = avio_rb64(f);
|
|
|
|
track->offsets[i].offset = avio_rb64(f);
|
2012-01-09 17:27:33 +01:00
|
|
|
} else {
|
2013-03-13 10:42:34 +01:00
|
|
|
track->offsets[i].time = avio_rb32(f);
|
|
|
|
track->offsets[i].offset = avio_rb32(f);
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
|
|
|
|
avio_r8(f);
|
|
|
|
for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
|
|
|
|
avio_r8(f);
|
|
|
|
for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
|
|
|
|
avio_r8(f);
|
|
|
|
if (i > 0)
|
2013-03-13 10:42:34 +01:00
|
|
|
track->offsets[i - 1].duration = track->offsets[i].time -
|
|
|
|
track->offsets[i - 1].time;
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
2014-09-14 18:00:56 +02:00
|
|
|
if (track->chunks > 0) {
|
|
|
|
track->offsets[track->chunks - 1].duration = track->offsets[0].time +
|
|
|
|
track->duration -
|
2013-03-13 10:42:34 +01:00
|
|
|
track->offsets[track->chunks - 1].time;
|
2014-09-14 18:00:56 +02:00
|
|
|
if (track->offsets[track->chunks - 1].duration <= 0) {
|
|
|
|
fprintf(stderr, "Calculated last chunk duration for track %d "
|
|
|
|
"was non-positive (%"PRId64"), probably due to missing "
|
|
|
|
"fragments ", track->track_id,
|
|
|
|
track->offsets[track->chunks - 1].duration);
|
|
|
|
if (track->chunks > 1) {
|
|
|
|
track->offsets[track->chunks - 1].duration =
|
|
|
|
track->offsets[track->chunks - 2].duration;
|
|
|
|
} else {
|
|
|
|
track->offsets[track->chunks - 1].duration = 1;
|
|
|
|
}
|
|
|
|
fprintf(stderr, "corrected to %"PRId64"\n",
|
|
|
|
track->offsets[track->chunks - 1].duration);
|
|
|
|
track->duration = track->offsets[track->chunks - 1].time +
|
|
|
|
track->offsets[track->chunks - 1].duration -
|
|
|
|
track->offsets[0].time;
|
|
|
|
fprintf(stderr, "Track duration corrected to %"PRId64"\n",
|
|
|
|
track->duration);
|
|
|
|
}
|
|
|
|
}
|
2012-01-09 17:27:33 +01:00
|
|
|
ret = 0;
|
2012-01-25 15:03:18 +01:00
|
|
|
|
2012-01-09 17:27:33 +01:00
|
|
|
fail:
|
|
|
|
avio_seek(f, pos + size, SEEK_SET);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
static int read_mfra(struct Tracks *tracks, int start_index,
|
2014-09-04 17:09:46 +02:00
|
|
|
const char *file, int split, int ismf,
|
|
|
|
const char *basename, const char* output_prefix)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
int err = 0;
|
2014-09-01 15:16:49 +02:00
|
|
|
const char* err_str = "";
|
2012-01-09 17:27:33 +01:00
|
|
|
AVIOContext *f = NULL;
|
|
|
|
int32_t mfra_size;
|
|
|
|
|
|
|
|
if ((err = avio_open2(&f, file, AVIO_FLAG_READ, NULL, NULL)) < 0)
|
|
|
|
goto fail;
|
|
|
|
avio_seek(f, avio_size(f) - 4, SEEK_SET);
|
|
|
|
mfra_size = avio_rb32(f);
|
|
|
|
avio_seek(f, -mfra_size, SEEK_CUR);
|
2012-07-03 13:18:58 +02:00
|
|
|
if (avio_rb32(f) != mfra_size) {
|
|
|
|
err = AVERROR_INVALIDDATA;
|
2014-09-01 15:16:49 +02:00
|
|
|
err_str = "mfra size mismatch";
|
2012-01-09 17:27:33 +01:00
|
|
|
goto fail;
|
2012-07-03 13:18:58 +02:00
|
|
|
}
|
|
|
|
if (avio_rb32(f) != MKBETAG('m', 'f', 'r', 'a')) {
|
|
|
|
err = AVERROR_INVALIDDATA;
|
2014-09-01 15:16:49 +02:00
|
|
|
err_str = "mfra tag mismatch";
|
2012-01-09 17:27:33 +01:00
|
|
|
goto fail;
|
2012-07-03 13:18:58 +02:00
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
while (!read_tfra(tracks, start_index, f)) {
|
2012-01-09 17:27:33 +01:00
|
|
|
/* Empty */
|
|
|
|
}
|
|
|
|
|
2014-09-04 17:09:46 +02:00
|
|
|
if (split || ismf)
|
|
|
|
err = write_fragments(tracks, start_index, f, basename, split, ismf,
|
|
|
|
output_prefix);
|
|
|
|
err_str = "error in write_fragments";
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
fail:
|
|
|
|
if (f)
|
|
|
|
avio_close(f);
|
2012-07-03 13:18:58 +02:00
|
|
|
if (err)
|
2014-09-01 15:16:49 +02:00
|
|
|
fprintf(stderr, "Unable to read the MFRA atom in %s (%s)\n", file, err_str);
|
2012-01-09 17:27:33 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
static int get_private_data(struct Track *track, AVCodecContext *codec)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
2013-03-13 10:42:34 +01:00
|
|
|
track->codec_private_size = codec->extradata_size;
|
|
|
|
track->codec_private = av_mallocz(codec->extradata_size);
|
|
|
|
if (!track->codec_private)
|
2012-01-09 17:27:33 +01:00
|
|
|
return AVERROR(ENOMEM);
|
2013-03-13 10:42:34 +01:00
|
|
|
memcpy(track->codec_private, codec->extradata, codec->extradata_size);
|
2012-01-09 17:27:33 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
static int get_video_private_data(struct Track *track, AVCodecContext *codec)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
AVIOContext *io = NULL;
|
|
|
|
uint16_t sps_size, pps_size;
|
2014-09-01 15:16:49 +02:00
|
|
|
int err;
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2012-08-05 11:11:04 +02:00
|
|
|
if (codec->codec_id == AV_CODEC_ID_VC1)
|
2013-03-13 10:42:34 +01:00
|
|
|
return get_private_data(track, codec);
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2014-09-01 15:16:49 +02:00
|
|
|
if ((err = avio_open_dyn_buf(&io)) < 0)
|
2012-10-29 02:53:43 +01:00
|
|
|
goto fail;
|
2014-09-01 15:16:49 +02:00
|
|
|
err = AVERROR(EINVAL);
|
2012-01-09 17:27:33 +01:00
|
|
|
if (codec->extradata_size < 11 || codec->extradata[0] != 1)
|
|
|
|
goto fail;
|
|
|
|
sps_size = AV_RB16(&codec->extradata[6]);
|
|
|
|
if (11 + sps_size > codec->extradata_size)
|
|
|
|
goto fail;
|
|
|
|
avio_wb32(io, 0x00000001);
|
|
|
|
avio_write(io, &codec->extradata[8], sps_size);
|
|
|
|
pps_size = AV_RB16(&codec->extradata[9 + sps_size]);
|
|
|
|
if (11 + sps_size + pps_size > codec->extradata_size)
|
|
|
|
goto fail;
|
|
|
|
avio_wb32(io, 0x00000001);
|
|
|
|
avio_write(io, &codec->extradata[11 + sps_size], pps_size);
|
|
|
|
err = 0;
|
2012-01-25 15:03:18 +01:00
|
|
|
|
2012-01-09 17:27:33 +01:00
|
|
|
fail:
|
2013-03-13 10:42:34 +01:00
|
|
|
track->codec_private_size = avio_close_dyn_buf(io, &track->codec_private);
|
2012-01-09 17:27:33 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-07-02 22:02:58 +02:00
|
|
|
static int handle_file(struct Tracks *tracks, const char *file, int split,
|
2014-09-04 17:09:46 +02:00
|
|
|
int ismf, const char *basename,
|
|
|
|
const char* output_prefix)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
AVFormatContext *ctx = NULL;
|
2013-03-13 10:42:34 +01:00
|
|
|
int err = 0, i, orig_tracks = tracks->nb_tracks;
|
2012-01-09 17:27:33 +01:00
|
|
|
char errbuf[50], *ptr;
|
2013-03-13 10:42:34 +01:00
|
|
|
struct Track *track;
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
err = avformat_open_input(&ctx, file, NULL, NULL);
|
|
|
|
if (err < 0) {
|
|
|
|
av_strerror(err, errbuf, sizeof(errbuf));
|
|
|
|
fprintf(stderr, "Unable to open %s: %s\n", file, errbuf);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = avformat_find_stream_info(ctx, NULL);
|
|
|
|
if (err < 0) {
|
|
|
|
av_strerror(err, errbuf, sizeof(errbuf));
|
|
|
|
fprintf(stderr, "Unable to identify %s: %s\n", file, errbuf);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx->nb_streams < 1) {
|
|
|
|
fprintf(stderr, "No streams found in %s\n", file);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ctx->nb_streams; i++) {
|
2013-03-13 13:13:46 +01:00
|
|
|
struct Track **temp;
|
2012-01-09 17:27:33 +01:00
|
|
|
AVStream *st = ctx->streams[i];
|
2014-09-03 08:13:46 +02:00
|
|
|
|
|
|
|
if (st->codec->bit_rate == 0) {
|
2014-09-04 17:09:46 +02:00
|
|
|
fprintf(stderr, "Skipping track %d in %s as it has zero bitrate\n",
|
|
|
|
st->id, file);
|
2014-09-03 08:13:46 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
track = av_mallocz(sizeof(*track));
|
2013-03-13 13:13:46 +01:00
|
|
|
if (!track) {
|
|
|
|
err = AVERROR(ENOMEM);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
temp = av_realloc(tracks->tracks,
|
|
|
|
sizeof(*tracks->tracks) * (tracks->nb_tracks + 1));
|
|
|
|
if (!temp) {
|
|
|
|
av_free(track);
|
|
|
|
err = AVERROR(ENOMEM);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
tracks->tracks = temp;
|
2013-03-13 10:42:34 +01:00
|
|
|
tracks->tracks[tracks->nb_tracks] = track;
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
track->name = file;
|
2014-08-14 22:31:25 +02:00
|
|
|
if ((ptr = strrchr(file, '/')))
|
2013-03-13 10:42:34 +01:00
|
|
|
track->name = ptr + 1;
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
track->bitrate = st->codec->bit_rate;
|
|
|
|
track->track_id = st->id;
|
|
|
|
track->timescale = st->time_base.den;
|
2013-10-03 00:52:37 +02:00
|
|
|
track->duration = st->duration;
|
2013-03-13 10:42:34 +01:00
|
|
|
track->is_audio = st->codec->codec_type == AVMEDIA_TYPE_AUDIO;
|
|
|
|
track->is_video = st->codec->codec_type == AVMEDIA_TYPE_VIDEO;
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
if (!track->is_audio && !track->is_video) {
|
2012-01-25 15:03:18 +01:00
|
|
|
fprintf(stderr,
|
|
|
|
"Track %d in %s is neither video nor audio, skipping\n",
|
2013-03-13 10:42:34 +01:00
|
|
|
track->track_id, file);
|
|
|
|
av_freep(&tracks->tracks[tracks->nb_tracks]);
|
2012-01-09 17:27:33 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-10-04 09:12:07 +02:00
|
|
|
tracks->duration = FFMAX(tracks->duration,
|
|
|
|
av_rescale_rnd(track->duration, AV_TIME_BASE,
|
|
|
|
track->timescale, AV_ROUND_UP));
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
if (track->is_audio) {
|
|
|
|
if (tracks->audio_track < 0)
|
|
|
|
tracks->audio_track = tracks->nb_tracks;
|
|
|
|
tracks->nb_audio_tracks++;
|
|
|
|
track->channels = st->codec->channels;
|
|
|
|
track->sample_rate = st->codec->sample_rate;
|
2012-08-05 11:11:04 +02:00
|
|
|
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
|
2013-03-13 10:42:34 +01:00
|
|
|
track->fourcc = "AACL";
|
|
|
|
track->tag = 255;
|
|
|
|
track->blocksize = 4;
|
2012-08-05 11:11:04 +02:00
|
|
|
} else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
|
2013-03-13 10:42:34 +01:00
|
|
|
track->fourcc = "WMAP";
|
|
|
|
track->tag = st->codec->codec_tag;
|
|
|
|
track->blocksize = st->codec->block_align;
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
get_private_data(track, st->codec);
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
if (track->is_video) {
|
|
|
|
if (tracks->video_track < 0)
|
|
|
|
tracks->video_track = tracks->nb_tracks;
|
|
|
|
tracks->nb_video_tracks++;
|
|
|
|
track->width = st->codec->width;
|
|
|
|
track->height = st->codec->height;
|
2012-08-05 11:11:04 +02:00
|
|
|
if (st->codec->codec_id == AV_CODEC_ID_H264)
|
2013-03-13 10:42:34 +01:00
|
|
|
track->fourcc = "H264";
|
2012-08-05 11:11:04 +02:00
|
|
|
else if (st->codec->codec_id == AV_CODEC_ID_VC1)
|
2013-03-13 10:42:34 +01:00
|
|
|
track->fourcc = "WVC1";
|
|
|
|
get_video_private_data(track, st->codec);
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
tracks->nb_tracks++;
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
avformat_close_input(&ctx);
|
|
|
|
|
2014-09-04 17:09:46 +02:00
|
|
|
err = read_mfra(tracks, orig_tracks, file, split, ismf, basename,
|
|
|
|
output_prefix);
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
fail:
|
|
|
|
if (ctx)
|
|
|
|
avformat_close_input(&ctx);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-07-02 22:02:58 +02:00
|
|
|
static void output_server_manifest(struct Tracks *tracks, const char *basename,
|
|
|
|
const char *output_prefix,
|
|
|
|
const char *path_prefix,
|
2014-07-02 21:44:32 +02:00
|
|
|
const char *ismc_prefix)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
char filename[1000];
|
|
|
|
FILE *out;
|
|
|
|
int i;
|
|
|
|
|
2014-07-02 22:02:58 +02:00
|
|
|
snprintf(filename, sizeof(filename), "%s%s.ism", output_prefix, basename);
|
2012-01-09 17:27:33 +01:00
|
|
|
out = fopen(filename, "w");
|
|
|
|
if (!out) {
|
|
|
|
perror(filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
|
|
|
fprintf(out, "<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\">\n");
|
|
|
|
fprintf(out, "\t<head>\n");
|
|
|
|
fprintf(out, "\t\t<meta name=\"clientManifestRelativePath\" "
|
2014-07-02 21:44:32 +02:00
|
|
|
"content=\"%s%s.ismc\" />\n", ismc_prefix, basename);
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\t</head>\n");
|
|
|
|
fprintf(out, "\t<body>\n");
|
|
|
|
fprintf(out, "\t\t<switch>\n");
|
2013-03-13 10:42:34 +01:00
|
|
|
for (i = 0; i < tracks->nb_tracks; i++) {
|
|
|
|
struct Track *track = tracks->tracks[i];
|
|
|
|
const char *type = track->is_video ? "video" : "audio";
|
2014-07-02 21:44:32 +02:00
|
|
|
fprintf(out, "\t\t\t<%s src=\"%s%s\" systemBitrate=\"%d\">\n",
|
|
|
|
type, path_prefix, track->name, track->bitrate);
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\t\t\t\t<param name=\"trackID\" value=\"%d\" "
|
2013-03-13 10:42:34 +01:00
|
|
|
"valueType=\"data\" />\n", track->track_id);
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\t\t\t</%s>\n", type);
|
|
|
|
}
|
|
|
|
fprintf(out, "\t\t</switch>\n");
|
|
|
|
fprintf(out, "\t</body>\n");
|
|
|
|
fprintf(out, "</smil>\n");
|
|
|
|
fclose(out);
|
|
|
|
}
|
|
|
|
|
2013-03-13 11:29:43 +01:00
|
|
|
static void print_track_chunks(FILE *out, struct Tracks *tracks, int main,
|
|
|
|
const char *type)
|
|
|
|
{
|
|
|
|
int i, j;
|
2014-09-14 18:00:56 +02:00
|
|
|
int64_t pos = 0;
|
2013-03-13 11:29:43 +01:00
|
|
|
struct Track *track = tracks->tracks[main];
|
2014-09-01 15:16:49 +02:00
|
|
|
int should_print_time_mismatch = 1;
|
|
|
|
|
2013-03-13 11:29:43 +01:00
|
|
|
for (i = 0; i < track->chunks; i++) {
|
|
|
|
for (j = main + 1; j < tracks->nb_tracks; j++) {
|
2014-09-01 15:16:49 +02:00
|
|
|
if (tracks->tracks[j]->is_audio == track->is_audio) {
|
|
|
|
if (track->offsets[i].duration != tracks->tracks[j]->offsets[i].duration) {
|
|
|
|
fprintf(stderr, "Mismatched duration of %s chunk %d in %s (%d) and %s (%d)\n",
|
|
|
|
type, i, track->name, main, tracks->tracks[j]->name, j);
|
|
|
|
should_print_time_mismatch = 1;
|
|
|
|
}
|
|
|
|
if (track->offsets[i].time != tracks->tracks[j]->offsets[i].time) {
|
|
|
|
if (should_print_time_mismatch)
|
|
|
|
fprintf(stderr, "Mismatched (start) time of %s chunk %d in %s (%d) and %s (%d)\n",
|
|
|
|
type, i, track->name, main, tracks->tracks[j]->name, j);
|
|
|
|
should_print_time_mismatch = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-03-13 11:29:43 +01:00
|
|
|
}
|
2014-09-14 18:00:56 +02:00
|
|
|
fprintf(out, "\t\t<c n=\"%d\" d=\"%"PRId64"\" ",
|
2013-03-13 11:29:43 +01:00
|
|
|
i, track->offsets[i].duration);
|
2014-09-14 18:00:56 +02:00
|
|
|
if (pos != track->offsets[i].time) {
|
|
|
|
// With the current logic for calculation of durations from
|
|
|
|
// chunk start times, this branch can only be hit on the first
|
|
|
|
// chunk - but that's still useful and this will keep working
|
|
|
|
// if the duration calculation is improved.
|
|
|
|
fprintf(out, "t=\"%"PRId64"\" ", track->offsets[i].time);
|
|
|
|
pos = track->offsets[i].time;
|
|
|
|
}
|
|
|
|
pos += track->offsets[i].duration;
|
|
|
|
fprintf(out, "/>\n");
|
2013-03-13 11:29:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-02 22:02:58 +02:00
|
|
|
static void output_client_manifest(struct Tracks *tracks, const char *basename,
|
|
|
|
const char *output_prefix, int split)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
char filename[1000];
|
|
|
|
FILE *out;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if (split)
|
2014-07-02 22:02:58 +02:00
|
|
|
snprintf(filename, sizeof(filename), "%sManifest", output_prefix);
|
2012-01-09 17:27:33 +01:00
|
|
|
else
|
2014-07-02 22:02:58 +02:00
|
|
|
snprintf(filename, sizeof(filename), "%s%s.ismc", output_prefix, basename);
|
2012-01-09 17:27:33 +01:00
|
|
|
out = fopen(filename, "w");
|
|
|
|
if (!out) {
|
|
|
|
perror(filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
|
|
|
fprintf(out, "<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" "
|
2013-03-13 10:42:34 +01:00
|
|
|
"Duration=\"%"PRId64 "\">\n", tracks->duration * 10);
|
|
|
|
if (tracks->video_track >= 0) {
|
|
|
|
struct Track *track = tracks->tracks[tracks->video_track];
|
|
|
|
struct Track *first_track = track;
|
2012-01-09 17:27:33 +01:00
|
|
|
int index = 0;
|
2012-01-25 15:03:18 +01:00
|
|
|
fprintf(out,
|
|
|
|
"\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" "
|
|
|
|
"Chunks=\"%d\" "
|
|
|
|
"Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n",
|
2013-03-13 10:42:34 +01:00
|
|
|
tracks->nb_video_tracks, track->chunks);
|
|
|
|
for (i = 0; i < tracks->nb_tracks; i++) {
|
|
|
|
track = tracks->tracks[i];
|
|
|
|
if (!track->is_video)
|
2012-01-09 17:27:33 +01:00
|
|
|
continue;
|
2012-01-25 15:03:18 +01:00
|
|
|
fprintf(out,
|
|
|
|
"\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
|
|
|
|
"FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" "
|
|
|
|
"CodecPrivateData=\"",
|
2013-03-13 10:42:34 +01:00
|
|
|
index, track->bitrate, track->fourcc, track->width, track->height);
|
|
|
|
for (j = 0; j < track->codec_private_size; j++)
|
|
|
|
fprintf(out, "%02X", track->codec_private[j]);
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
index++;
|
2013-03-13 10:42:34 +01:00
|
|
|
if (track->chunks != first_track->chunks)
|
2014-09-01 15:16:49 +02:00
|
|
|
fprintf(stderr, "Mismatched number of video chunks in %s (id: %d, chunks %d) and %s (id: %d, chunks %d)\n",
|
|
|
|
track->name, track->track_id, track->chunks, first_track->name, first_track->track_id, first_track->chunks);
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
2013-03-13 11:29:43 +01:00
|
|
|
print_track_chunks(out, tracks, tracks->video_track, "video");
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\t</StreamIndex>\n");
|
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
if (tracks->audio_track >= 0) {
|
|
|
|
struct Track *track = tracks->tracks[tracks->audio_track];
|
|
|
|
struct Track *first_track = track;
|
2012-01-09 17:27:33 +01:00
|
|
|
int index = 0;
|
2012-01-25 15:03:18 +01:00
|
|
|
fprintf(out,
|
|
|
|
"\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" "
|
|
|
|
"Chunks=\"%d\" "
|
|
|
|
"Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n",
|
2013-03-13 10:42:34 +01:00
|
|
|
tracks->nb_audio_tracks, track->chunks);
|
|
|
|
for (i = 0; i < tracks->nb_tracks; i++) {
|
|
|
|
track = tracks->tracks[i];
|
|
|
|
if (!track->is_audio)
|
2012-01-09 17:27:33 +01:00
|
|
|
continue;
|
2012-01-25 15:03:18 +01:00
|
|
|
fprintf(out,
|
|
|
|
"\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
|
|
|
|
"FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" "
|
|
|
|
"BitsPerSample=\"16\" PacketSize=\"%d\" "
|
|
|
|
"AudioTag=\"%d\" CodecPrivateData=\"",
|
2013-03-13 10:42:34 +01:00
|
|
|
index, track->bitrate, track->fourcc, track->sample_rate,
|
|
|
|
track->channels, track->blocksize, track->tag);
|
|
|
|
for (j = 0; j < track->codec_private_size; j++)
|
|
|
|
fprintf(out, "%02X", track->codec_private[j]);
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\" />\n");
|
|
|
|
index++;
|
2013-03-13 10:42:34 +01:00
|
|
|
if (track->chunks != first_track->chunks)
|
2012-07-03 13:58:52 +02:00
|
|
|
fprintf(stderr, "Mismatched number of audio chunks in %s and %s\n",
|
2013-03-13 10:42:34 +01:00
|
|
|
track->name, first_track->name);
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
2013-03-13 11:29:43 +01:00
|
|
|
print_track_chunks(out, tracks, tracks->audio_track, "audio");
|
2012-01-09 17:27:33 +01:00
|
|
|
fprintf(out, "\t</StreamIndex>\n");
|
|
|
|
}
|
|
|
|
fprintf(out, "</SmoothStreamingMedia>\n");
|
|
|
|
fclose(out);
|
|
|
|
}
|
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
static void clean_tracks(struct Tracks *tracks)
|
2012-01-09 17:27:33 +01:00
|
|
|
{
|
|
|
|
int i;
|
2013-03-13 10:42:34 +01:00
|
|
|
for (i = 0; i < tracks->nb_tracks; i++) {
|
|
|
|
av_freep(&tracks->tracks[i]->codec_private);
|
|
|
|
av_freep(&tracks->tracks[i]->offsets);
|
|
|
|
av_freep(&tracks->tracks[i]);
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
av_freep(&tracks->tracks);
|
|
|
|
tracks->nb_tracks = 0;
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
const char *basename = NULL;
|
2014-07-02 21:44:32 +02:00
|
|
|
const char *path_prefix = "", *ismc_prefix = "";
|
2014-07-02 22:02:58 +02:00
|
|
|
const char *output_prefix = "";
|
|
|
|
char output_prefix_buf[2048];
|
2014-09-04 17:09:46 +02:00
|
|
|
int split = 0, ismf = 0, i;
|
2013-03-13 10:42:34 +01:00
|
|
|
struct Tracks tracks = { 0, .video_track = -1, .audio_track = -1 };
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
av_register_all();
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (!strcmp(argv[i], "-n")) {
|
|
|
|
basename = argv[i + 1];
|
|
|
|
i++;
|
2014-07-02 21:44:32 +02:00
|
|
|
} else if (!strcmp(argv[i], "-path-prefix")) {
|
|
|
|
path_prefix = argv[i + 1];
|
|
|
|
i++;
|
|
|
|
} else if (!strcmp(argv[i], "-ismc-prefix")) {
|
|
|
|
ismc_prefix = argv[i + 1];
|
|
|
|
i++;
|
2014-07-02 22:02:58 +02:00
|
|
|
} else if (!strcmp(argv[i], "-output")) {
|
|
|
|
output_prefix = argv[i + 1];
|
|
|
|
i++;
|
|
|
|
if (output_prefix[strlen(output_prefix) - 1] != '/') {
|
|
|
|
snprintf(output_prefix_buf, sizeof(output_prefix_buf),
|
|
|
|
"%s/", output_prefix);
|
|
|
|
output_prefix = output_prefix_buf;
|
|
|
|
}
|
2012-01-09 17:27:33 +01:00
|
|
|
} else if (!strcmp(argv[i], "-split")) {
|
|
|
|
split = 1;
|
2014-09-04 17:09:46 +02:00
|
|
|
} else if (!strcmp(argv[i], "-ismf")) {
|
|
|
|
ismf = 1;
|
2012-01-09 17:27:33 +01:00
|
|
|
} else if (argv[i][0] == '-') {
|
|
|
|
return usage(argv[0], 1);
|
|
|
|
} else {
|
2014-09-05 21:50:24 +02:00
|
|
|
if (!basename)
|
|
|
|
ismf = 0;
|
2014-09-04 17:09:46 +02:00
|
|
|
if (handle_file(&tracks, argv[i], split, ismf,
|
|
|
|
basename, output_prefix))
|
2012-07-03 13:18:58 +02:00
|
|
|
return 1;
|
2012-01-09 17:27:33 +01:00
|
|
|
}
|
|
|
|
}
|
2013-03-13 10:42:34 +01:00
|
|
|
if (!tracks.nb_tracks || (!basename && !split))
|
2012-01-09 17:27:33 +01:00
|
|
|
return usage(argv[0], 1);
|
|
|
|
|
|
|
|
if (!split)
|
2014-07-02 22:02:58 +02:00
|
|
|
output_server_manifest(&tracks, basename, output_prefix,
|
|
|
|
path_prefix, ismc_prefix);
|
|
|
|
output_client_manifest(&tracks, basename, output_prefix, split);
|
2012-01-09 17:27:33 +01:00
|
|
|
|
2013-03-13 10:42:34 +01:00
|
|
|
clean_tracks(&tracks);
|
2012-01-09 17:27:33 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|