st->need_parsing = AVSTREAM_PARSE_FULL;
st->start_time = 0;
+ // lcm of all mp3 sample rates
+ av_set_pts_info(st, 64, 1, 14112000);
+
ff_id3v2_read(s);
+ off = url_ftell(s->pb);
+
if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
ff_id3v1_read(s);
- off = url_ftell(s->pb);
if (mp3_parse_vbr_tags(s, st, off) < 0)
url_fseek(s->pb, off, SEEK_SET);
count += id3v1_set_string(s, "title", buf + 3, 30);
count += id3v1_set_string(s, "author", buf + 33, 30);
count += id3v1_set_string(s, "album", buf + 63, 30);
- count += id3v1_set_string(s, "year", buf + 93, 4);
+ count += id3v1_set_string(s, "date", buf + 93, 4);
count += id3v1_set_string(s, "comment", buf + 97, 30);
if ((tag = av_metadata_get(s->metadata, "track", NULL, 0))) {
buf[125] = 0;
}
+static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+ put_buffer(s->pb, pkt->data, pkt->size);
+ put_flush_packet(s->pb);
+ return 0;
+}
+
+static int mp3_write_trailer(struct AVFormatContext *s)
+{
+ uint8_t buf[ID3v1_TAG_SIZE];
+
+ /* write the id3v1 tag */
+ if (id3v1_create_tag(s, buf) > 0) {
+ put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
+ put_flush_packet(s->pb);
+ }
+ return 0;
+}
+#endif /* CONFIG_MP2_MUXER || CONFIG_MP3_MUXER */
+
+#if CONFIG_MP2_MUXER
+AVOutputFormat mp2_muxer = {
+ "mp2",
+ NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
+ "audio/x-mpeg",
+ "mp2,m2a",
+ 0,
+ CODEC_ID_MP2,
+ CODEC_ID_NONE,
+ NULL,
+ mp3_write_packet,
+ mp3_write_trailer,
+};
+#endif
+
+#if CONFIG_MP3_MUXER
/**
* Write an ID3v2.4 header at beginning of stream
*/
while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
uint32_t tag = 0;
- if (t->key[0] == 'T' && strcmp(t->key, "TSSE")) {
+ if (t->key[0] == 'T' && strlen(t->key) == 4) {
int i;
for (i = 0; *ff_id3v2_tags[i]; i++)
if (AV_RB32(t->key) == AV_RB32(ff_id3v2_tags[i])) {
av_free(buf);
}
}
- if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
- totlen += strlen(LIBAVFORMAT_IDENT) + ID3v2_HEADER_SIZE + 2;
- id3v2_put_ttag(s, LIBAVFORMAT_IDENT, strlen(LIBAVFORMAT_IDENT) + 1,
- MKBETAG('T', 'S', 'S', 'E'));
- }
cur_pos = url_ftell(s->pb);
url_fseek(s->pb, size_pos, SEEK_SET);
return 0;
}
-static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt)
-{
- put_buffer(s->pb, pkt->data, pkt->size);
- put_flush_packet(s->pb);
- return 0;
-}
-
-static int mp3_write_trailer(struct AVFormatContext *s)
-{
- uint8_t buf[ID3v1_TAG_SIZE];
-
- /* write the id3v1 tag */
- if (id3v1_create_tag(s, buf) > 0) {
- put_buffer(s->pb, buf, ID3v1_TAG_SIZE);
- put_flush_packet(s->pb);
- }
- return 0;
-}
-#endif /* CONFIG_MP2_MUXER || CONFIG_MP3_MUXER */
-
-#if CONFIG_MP2_MUXER
-AVOutputFormat mp2_muxer = {
- "mp2",
- NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
- "audio/x-mpeg",
- "mp2,m2a",
- 0,
- CODEC_ID_MP2,
- CODEC_ID_NONE,
- NULL,
- mp3_write_packet,
- mp3_write_trailer,
-};
-#endif
-#if CONFIG_MP3_MUXER
AVOutputFormat mp3_muxer = {
"mp3",
NULL_IF_CONFIG_SMALL("MPEG audio layer 3"),