Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
56e2ac6b
Commit
56e2ac6b
authored
Mar 15, 2011
by
Anton Khirnov
Committed by
Justin Ruggles
Mar 15, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
id3v2: merge TYER/TDAT/TIME to date tag
parent
aaff3b31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
id3v2.c
libavformat/id3v2.c
+47
-0
No files found.
libavformat/id3v2.c
View file @
56e2ac6b
...
...
@@ -136,6 +136,52 @@ static void read_ttag(AVFormatContext *s, AVIOContext *pb, int taglen, const cha
av_metadata_set2
(
&
s
->
metadata
,
key
,
val
,
AV_METADATA_DONT_OVERWRITE
);
}
static
int
is_number
(
const
char
*
str
)
{
while
(
*
str
>=
'0'
&&
*
str
<=
'9'
)
str
++
;
return
!*
str
;
}
static
AVMetadataTag
*
get_date_tag
(
AVMetadata
*
m
,
const
char
*
tag
)
{
AVMetadataTag
*
t
;
if
((
t
=
av_metadata_get
(
m
,
tag
,
NULL
,
AV_METADATA_MATCH_CASE
))
&&
strlen
(
t
->
value
)
==
4
&&
is_number
(
t
->
value
))
return
t
;
return
NULL
;
}
static
void
merge_date
(
AVMetadata
**
m
)
{
AVMetadataTag
*
t
;
char
date
[
17
]
=
{
0
};
// YYYY-MM-DD hh:mm
if
(
!
(
t
=
get_date_tag
(
*
m
,
"TYER"
))
&&
!
(
t
=
get_date_tag
(
*
m
,
"TYE"
)))
return
;
av_strlcpy
(
date
,
t
->
value
,
5
);
av_metadata_set2
(
m
,
"TYER"
,
NULL
,
0
);
av_metadata_set2
(
m
,
"TYE"
,
NULL
,
0
);
if
(
!
(
t
=
get_date_tag
(
*
m
,
"TDAT"
))
&&
!
(
t
=
get_date_tag
(
*
m
,
"TDA"
)))
goto
finish
;
snprintf
(
date
+
4
,
sizeof
(
date
)
-
4
,
"-%.2s-%.2s"
,
t
->
value
+
2
,
t
->
value
);
av_metadata_set2
(
m
,
"TDAT"
,
NULL
,
0
);
av_metadata_set2
(
m
,
"TDA"
,
NULL
,
0
);
if
(
!
(
t
=
get_date_tag
(
*
m
,
"TIME"
))
&&
!
(
t
=
get_date_tag
(
*
m
,
"TIM"
)))
goto
finish
;
snprintf
(
date
+
10
,
sizeof
(
date
)
-
10
,
" %.2s:%.2s"
,
t
->
value
,
t
->
value
+
2
);
av_metadata_set2
(
m
,
"TIME"
,
NULL
,
0
);
av_metadata_set2
(
m
,
"TIM"
,
NULL
,
0
);
finish:
if
(
date
[
0
])
av_metadata_set2
(
m
,
"date"
,
date
,
0
);
}
static
void
ff_id3v2_parse
(
AVFormatContext
*
s
,
int
len
,
uint8_t
version
,
uint8_t
flags
)
{
int
isv34
,
tlen
,
unsync
;
...
...
@@ -277,6 +323,7 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic)
ff_metadata_conv
(
&
s
->
metadata
,
NULL
,
ff_id3v2_34_metadata_conv
);
ff_metadata_conv
(
&
s
->
metadata
,
NULL
,
ff_id3v2_2_metadata_conv
);
ff_metadata_conv
(
&
s
->
metadata
,
NULL
,
ff_id3v2_4_metadata_conv
);
merge_date
(
&
s
->
metadata
);
}
const
AVMetadataConv
ff_id3v2_34_metadata_conv
[]
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment