|
|
|
@ -35,6 +35,7 @@ |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
#include <sys/stat.h> |
|
|
|
|
|
|
|
|
|
#include "libavformat/avformat.h" |
|
|
|
|
#include "libavutil/intreadwrite.h" |
|
|
|
|
#include "libavutil/mathematics.h" |
|
|
|
@ -149,10 +150,9 @@ static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f) |
|
|
|
|
version = avio_r8(f); |
|
|
|
|
avio_rb24(f); |
|
|
|
|
track_id = avio_rb32(f); /* track id */ |
|
|
|
|
for (i = start_index; i < files->nb_files && !vf; i++) { |
|
|
|
|
for (i = start_index; i < files->nb_files && !vf; i++) |
|
|
|
|
if (files->files[i]->track_id == track_id) |
|
|
|
|
vf = files->files[i]; |
|
|
|
|
} |
|
|
|
|
if (!vf) { |
|
|
|
|
/* Ok, continue parsing the next atom */ |
|
|
|
|
ret = 0; |
|
|
|
@ -187,6 +187,7 @@ static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f) |
|
|
|
|
vf->offsets[vf->chunks - 1].duration = vf->duration - |
|
|
|
|
vf->offsets[vf->chunks - 1].time; |
|
|
|
|
ret = 0; |
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
|
avio_seek(f, pos + size, SEEK_SET); |
|
|
|
|
return ret; |
|
|
|
@ -254,6 +255,7 @@ static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec) |
|
|
|
|
avio_wb32(io, 0x00000001); |
|
|
|
|
avio_write(io, &codec->extradata[11 + sps_size], pps_size); |
|
|
|
|
err = 0; |
|
|
|
|
|
|
|
|
|
fail: |
|
|
|
|
vf->codec_private_size = avio_close_dyn_buf(io, &vf->codec_private); |
|
|
|
|
return err; |
|
|
|
@ -307,8 +309,9 @@ static int handle_file(struct VideoFiles *files, const char *file, int split) |
|
|
|
|
vf->is_video = st->codec->codec_type == AVMEDIA_TYPE_VIDEO; |
|
|
|
|
|
|
|
|
|
if (!vf->is_audio && !vf->is_video) { |
|
|
|
|
fprintf(stderr, "Track %d in %s is neither video nor audio, " |
|
|
|
|
"skipping\n", vf->track_id, file); |
|
|
|
|
fprintf(stderr, |
|
|
|
|
"Track %d in %s is neither video nor audio, skipping\n", |
|
|
|
|
vf->track_id, file); |
|
|
|
|
av_freep(&files->files[files->nb_files]); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
@ -414,7 +417,8 @@ static void output_client_manifest(struct VideoFiles *files, |
|
|
|
|
if (files->video_file >= 0) { |
|
|
|
|
struct VideoFile *vf = files->files[files->video_file]; |
|
|
|
|
int index = 0; |
|
|
|
|
fprintf(out, "\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" " |
|
|
|
|
fprintf(out, |
|
|
|
|
"\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" " |
|
|
|
|
"Chunks=\"%d\" " |
|
|
|
|
"Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n", |
|
|
|
|
files->nb_video_files, vf->chunks); |
|
|
|
@ -422,7 +426,8 @@ static void output_client_manifest(struct VideoFiles *files, |
|
|
|
|
vf = files->files[i]; |
|
|
|
|
if (!vf->is_video) |
|
|
|
|
continue; |
|
|
|
|
fprintf(out, "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" " |
|
|
|
|
fprintf(out, |
|
|
|
|
"\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" " |
|
|
|
|
"FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" " |
|
|
|
|
"CodecPrivateData=\"", |
|
|
|
|
index, vf->bitrate, vf->fourcc, vf->width, vf->height); |
|
|
|
@ -440,7 +445,8 @@ static void output_client_manifest(struct VideoFiles *files, |
|
|
|
|
if (files->audio_file >= 0) { |
|
|
|
|
struct VideoFile *vf = files->files[files->audio_file]; |
|
|
|
|
int index = 0; |
|
|
|
|
fprintf(out, "\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" " |
|
|
|
|
fprintf(out, |
|
|
|
|
"\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" " |
|
|
|
|
"Chunks=\"%d\" " |
|
|
|
|
"Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n", |
|
|
|
|
files->nb_audio_files, vf->chunks); |
|
|
|
@ -448,7 +454,8 @@ static void output_client_manifest(struct VideoFiles *files, |
|
|
|
|
vf = files->files[i]; |
|
|
|
|
if (!vf->is_audio) |
|
|
|
|
continue; |
|
|
|
|
fprintf(out, "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" " |
|
|
|
|
fprintf(out, |
|
|
|
|
"\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" " |
|
|
|
|
"FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" " |
|
|
|
|
"BitsPerSample=\"16\" PacketSize=\"%d\" " |
|
|
|
|
"AudioTag=\"%d\" CodecPrivateData=\"", |
|
|
|
|