mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +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
|
@ -5,8 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibMedia/Containers/Matroska/MatroskaDemuxer.h>
|
||||
#include <LibMedia/FFmpeg/FFmpegDemuxer.h>
|
||||
#include <LibMedia/FFmpeg/FFmpegVideoDecoder.h>
|
||||
#include <LibMedia/VideoFrame.h>
|
||||
|
||||
|
@ -26,21 +27,15 @@ namespace Media {
|
|||
_fatal_expression.release_value(); \
|
||||
})
|
||||
|
||||
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_file(StringView filename)
|
||||
{
|
||||
auto demuxer = TRY(Matroska::MatroskaDemuxer::from_file(filename));
|
||||
return create(move(demuxer));
|
||||
}
|
||||
|
||||
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_mapped_file(NonnullOwnPtr<Core::MappedFile> mapped_file)
|
||||
{
|
||||
auto demuxer = TRY(Matroska::MatroskaDemuxer::from_mapped_file(move(mapped_file)));
|
||||
return create(move(demuxer));
|
||||
}
|
||||
|
||||
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_data(ReadonlyBytes data)
|
||||
{
|
||||
auto demuxer = TRY(Matroska::MatroskaDemuxer::from_data(data));
|
||||
auto stream = make<FixedMemoryStream>(data);
|
||||
return from_stream(move(stream));
|
||||
}
|
||||
|
||||
DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::from_stream(NonnullOwnPtr<SeekableStream> stream)
|
||||
{
|
||||
auto demuxer = MUST(FFmpeg::FFmpegDemuxer::create(move(stream)));
|
||||
return create(move(demuxer));
|
||||
}
|
||||
|
||||
|
@ -93,7 +88,7 @@ AK::Duration PlaybackManager::duration()
|
|||
{
|
||||
auto duration_result = ({
|
||||
auto demuxer_locker = Threading::MutexLocker(m_decoder_mutex);
|
||||
m_demuxer->duration();
|
||||
m_demuxer->duration(m_selected_video_track);
|
||||
});
|
||||
if (duration_result.is_error()) {
|
||||
dispatch_decoder_error(duration_result.release_error());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue