mirror of
https://github.com/mpv-player/mpv
synced 2025-03-03 20:57:45 +00:00
sub: attempt to use video FPS for frame based subtitle formats
This only affects demux_subreader.c for now. Maybe there is some hope this can be used for libavformat demuxers too, but I'm not sure yet.
This commit is contained in:
parent
cfa45c40dc
commit
feb64c2717
@ -1500,6 +1500,7 @@ static int d_check_file(struct demuxer *demuxer)
|
||||
|
||||
p->sh = new_sh_stream(demuxer, STREAM_SUB);
|
||||
p->sh->codec = sd->codec;
|
||||
p->sh->sub->frame_based = !sd->sub_uses_time;
|
||||
|
||||
add_sub_data(demuxer, sd);
|
||||
subdata_free(sd);
|
||||
|
@ -163,6 +163,7 @@ typedef struct sh_sub {
|
||||
SH_COMMON
|
||||
unsigned char *extradata; // extra header data passed from demuxer
|
||||
int extradata_len;
|
||||
int frame_based; // timestamps are frame-based
|
||||
struct ass_track *track; // loaded by libass
|
||||
struct dec_sub *dec_sub; // decoder context
|
||||
} sh_sub_t;
|
||||
|
@ -275,6 +275,10 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_sub *sh)
|
||||
MP_TARRAY_APPEND(tmp, subs.packets, subs.num_packets, pkt);
|
||||
}
|
||||
|
||||
// 23.976 FPS is used as default timebase for frame based formats
|
||||
if (sub->video_fps && sh->frame_based)
|
||||
multiply_timings(&subs, sub->video_fps / 23.976);
|
||||
|
||||
if (opts->sub_fps && sub->video_fps)
|
||||
multiply_timings(&subs, opts->sub_fps / sub->video_fps);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user