Skip to content

Instantly share code, notes, and snippets.

@Pmmlabs
Last active March 17, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pmmlabs/3786dc53486e1da1b058 to your computer and use it in GitHub Desktop.
Save Pmmlabs/3786dc53486e1da1b058 to your computer and use it in GitHub Desktop.
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index ab71d41..53a9e0c 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -209,6 +209,7 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
int metadata_count = 0;
int64_t metadata_size_pos, data_size, metadata_count_pos;
AVDictionaryEntry *tag = NULL;
+ char *sprop = NULL;
/* write meta_tag */
avio_w8(pb, 18); // tag type META
@@ -307,11 +308,71 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
av_log(s, AV_LOG_DEBUG, "Ignoring metadata for %s\n", tag->key);
continue;
}
+ if (!strcmp(tag->key, "sprop-parameter-sets")) {
+ sprop = strdup(tag->value);
+ continue;
+ }
put_amf_string(pb, tag->key);
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, tag->value);
metadata_count++;
}
+
+ // For Wowza Server
+ if (sprop) {
+ put_amf_string(pb, "audiochannels");
+ put_amf_double(pb, flv->audio_enc->channels);
+ metadata_count++;
+
+ put_amf_string(pb, "trackinfo");
+ avio_w8(pb, AMF_DATA_TYPE_ARRAY);
+ avio_wb32(pb, 2);
+
+ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+ avio_wb32(pb, 2);
+
+ put_amf_string(pb, "type");
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
+ put_amf_string(pb, "video");
+
+ put_amf_string(pb, "sprop-parameter-sets");
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
+ put_amf_string(pb, sprop);
+
+ put_amf_string(pb, "");
+ avio_w8(pb, AMF_END_OF_OBJECT);
+
+ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+ avio_wb32(pb, 2);
+
+ put_amf_string(pb, "type");
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
+ put_amf_string(pb, "audio");
+
+ put_amf_string(pb, "config");
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
+ put_amf_string(pb, "1208");
+
+ put_amf_string(pb, "");
+ avio_w8(pb, AMF_END_OF_OBJECT);
+
+ put_amf_string(pb, "");
+ avio_w8(pb, AMF_END_OF_OBJECT);
+ metadata_count++;
+
+ put_amf_string(pb, "rtpsessioninfo");
+ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+ avio_wb32(pb, 1);
+
+ put_amf_string(pb, "timing");
+ avio_w8(pb, AMF_DATA_TYPE_STRING);
+ put_amf_string(pb, "0 0");
+
+ put_amf_string(pb, "");
+ avio_w8(pb, AMF_END_OF_OBJECT);
+ metadata_count++;
+ }
+ // End Wowza
put_amf_string(pb, "filesize");
flv->filesize_offset = avio_tell(pb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment