[FFmpeg-devel] [PATCH] AVFormat: LRC demuxer and muxer

Star Brilliant m13253 at hotmail.com
Wed Jul 9 16:55:47 CEST 2014


于 2014年07月09日 22:24, Derek Buitenhuis 写道:
>> +/*
>> + * LRC lyrics file format decoder
>> + * Copyright (c) 2014 StarBrilliant <m13253 at hotmail.com>
>
> For copyright purposes we generally use real names.

Thank you for your reminder.
But I consider my real name piracy.
If this really causes trouble to FFmpeg team, I will change it.

>> +#include "libavcodec/internal.h"
>
> Ew. What are you using from this?

I copied this line from assdec.c, I used to think it is useful.
Removing it is okay.

>> +#include "libavutil/bprint.h"
>> +#include "libavutil/dict.h"
>> +
>> +typedef struct LRCContext {
>> +    FFDemuxSubtitlesQueue q;
>> +    int ts_offset;
>
> Is int enough for a timestamp difference?

bprint is used for string and buffer manipulation. Again this #include 
is adapted from assdec.c.

timestamp difference is far from enough, since LRC comes with arbitrary 
line order.
Another reason is repeated line feature. LRC can have single line that 
is sung multiple times assigned with different timestamps.
This is why I use FFDemuxSubtitlesQueue to sort those lines.

ts_offset is a metadata item. By specifying "offset" in metadata, the 
whole lyrics would shift in timestamps to get sync with different 
versions of music.
My implementation does offset shifting on demuxing. So I have to keep a 
ts_offset member.

>> +        *start = -(mm*60000LL + ss*1000LL + cs*10LL); // just in case negative pts
>
> Why are you mangling the timestamps? Negative timestamps are technically valid.

Negative timestamps are not effective in real LRCs. However, with the 
feature called "offset" mentioned just above. A normal timestamp can 
easily become negative.
Since most players ignore uneffective lines (LRC has no official spec, 
it is a de-facto standard). So I will let the players drop those 
negative timestamps, instead of losing data at FFmpeg layer.


Finally, I attached an incremental patch, fixing an #include issue and a 
mistype.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-AVFormat-LRC-demuxer-and-muxer.patch
Type: text/x-patch
Size: 1339 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140709/be3ce0e1/attachment.bin>


More information about the ffmpeg-devel mailing list