obs-ffmpeg: Add speed percentage option
(Note: This commit also modifies the deps/media-playback module.) Allows modifying the speed of local file playback. Closes jp9000/obs-studio#1091
This commit is contained in:
9
deps/media-playback/media-playback/decode.c
vendored
9
deps/media-playback/media-playback/decode.c
vendored
@@ -338,6 +338,15 @@ bool mp_decode_next(struct mp_decode *d)
|
||||
d->stream->time_base,
|
||||
(AVRational){1, 1000000000});
|
||||
|
||||
if (d->m->speed != 100) {
|
||||
d->frame_pts = av_rescale_q(d->frame_pts,
|
||||
(AVRational){1, d->m->speed},
|
||||
(AVRational){1, 100});
|
||||
duration = av_rescale_q(duration,
|
||||
(AVRational){1, d->m->speed},
|
||||
(AVRational){1, 100});
|
||||
}
|
||||
|
||||
d->last_duration = duration;
|
||||
d->next_pts = d->frame_pts + duration;
|
||||
}
|
||||
|
6
deps/media-playback/media-playback/media.c
vendored
6
deps/media-playback/media-playback/media.c
vendored
@@ -271,7 +271,7 @@ static void mp_media_next_audio(mp_media_t *m)
|
||||
for (size_t i = 0; i < MAX_AV_PLANES; i++)
|
||||
audio.data[i] = f->data[i];
|
||||
|
||||
audio.samples_per_sec = f->sample_rate;
|
||||
audio.samples_per_sec = f->sample_rate * m->speed / 100;
|
||||
audio.speakers = convert_speaker_layout(f->channels);
|
||||
audio.format = convert_sample_format(f->format);
|
||||
audio.frames = f->nb_samples;
|
||||
@@ -687,8 +687,12 @@ bool mp_media_init(mp_media_t *media, const struct mp_media_info *info)
|
||||
media->v_preload_cb = info->v_preload_cb;
|
||||
media->force_range = info->force_range;
|
||||
media->buffering = info->buffering;
|
||||
media->speed = info->speed;
|
||||
media->is_local_file = info->is_local_file;
|
||||
|
||||
if (!info->is_local_file || media->speed < 1 || media->speed > 200)
|
||||
media->speed = 100;
|
||||
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
av_register_all();
|
||||
|
2
deps/media-playback/media-playback/media.h
vendored
2
deps/media-playback/media-playback/media.h
vendored
@@ -54,6 +54,7 @@ struct mp_media {
|
||||
char *path;
|
||||
char *format_name;
|
||||
int buffering;
|
||||
int speed;
|
||||
|
||||
enum AVPixelFormat scale_format;
|
||||
struct SwsContext *swscale;
|
||||
@@ -107,6 +108,7 @@ struct mp_media_info {
|
||||
const char *path;
|
||||
const char *format;
|
||||
int buffering;
|
||||
int speed;
|
||||
enum video_range_type force_range;
|
||||
bool hardware_decoding;
|
||||
bool is_local_file;
|
||||
|
Reference in New Issue
Block a user