mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibMedia: Demux videos with FFmpeg
This gives us access to container types other than Matroska, the biggest one being MP4.
This commit is contained in:
parent
3412935a62
commit
b789ba5e5f
Notes:
github-actions[bot]
2025-03-13 18:34:55 +00:00
Author: https://github.com/Lubrsi
Commit: b789ba5e5f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3892
Reviewed-by: https://github.com/ADKaster
12 changed files with 358 additions and 29 deletions
50
Libraries/LibMedia/FFmpeg/FFmpegDemuxer.h
Normal file
50
Libraries/LibMedia/FFmpeg/FFmpegDemuxer.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <LibMedia/Demuxer.h>
|
||||
#include <LibMedia/FFmpeg/FFmpegIOContext.h>
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
namespace Media::FFmpeg {
|
||||
|
||||
class FFmpegDemuxer : public Demuxer {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<FFmpegDemuxer>> create(NonnullOwnPtr<SeekableStream> stream);
|
||||
|
||||
FFmpegDemuxer(NonnullOwnPtr<SeekableStream> stream, NonnullOwnPtr<Media::FFmpeg::FFmpegIOContext>);
|
||||
virtual ~FFmpegDemuxer() override;
|
||||
|
||||
virtual DecoderErrorOr<Vector<Track>> get_tracks_for_type(TrackType type) override;
|
||||
|
||||
virtual DecoderErrorOr<Optional<AK::Duration>> seek_to_most_recent_keyframe(Track track, AK::Duration timestamp, Optional<AK::Duration> earliest_available_sample = OptionalNone()) override;
|
||||
|
||||
virtual DecoderErrorOr<AK::Duration> duration(Track track) override;
|
||||
|
||||
virtual DecoderErrorOr<CodecID> get_codec_id_for_track(Track track) override;
|
||||
|
||||
virtual DecoderErrorOr<ReadonlyBytes> get_codec_initialization_data_for_track(Track track) override;
|
||||
|
||||
virtual DecoderErrorOr<Sample> get_next_sample_for_track(Track track) override;
|
||||
|
||||
private:
|
||||
DecoderErrorOr<AK::Duration> duration_of_track_in_milliseconds(Track const& track);
|
||||
|
||||
NonnullOwnPtr<SeekableStream> m_stream;
|
||||
AVCodecContext* m_codec_context { nullptr };
|
||||
AVFormatContext* m_format_context { nullptr };
|
||||
NonnullOwnPtr<Media::FFmpeg::FFmpegIOContext> m_io_context;
|
||||
AVPacket* m_packet { nullptr };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue