Implement FFmpegVideoEncoder based on modern APIs for VPX
Categories
(Core :: Audio/Video, task, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox122 | --- | fixed |
People
(Reporter: chunmin, Assigned: chunmin)
References
(Blocks 1 open bug, Regressed 1 open bug)
Details
Attachments
(36 files, 6 obsolete files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
There is no MediaDataEncoder implementation on Linux right now. To implement WebCodec's video encoder properly, it's best to implement an FFmpegVideoEncoder with a MediaDataEncoder interface
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 1•2 years ago
|
||
Depends on D193602
| Assignee | ||
Comment 2•2 years ago
|
||
Depends on D193936
| Assignee | ||
Comment 3•2 years ago
|
||
Depends on D193937
| Assignee | ||
Comment 4•2 years ago
|
||
Depends on D193602
| Assignee | ||
Comment 5•2 years ago
|
||
Depends on D193939
| Assignee | ||
Comment 6•2 years ago
|
||
Depends on D193940
| Assignee | ||
Comment 7•2 years ago
|
||
Depends on D193941
| Assignee | ||
Comment 8•2 years ago
|
||
Note that FFmpegEncoderModule won't be built since it's not included in
any moz.build yet. The following patches will add this into related
moz.build to build it.
Depends on D193942
| Assignee | ||
Comment 9•2 years ago
|
||
Depends on D193943
| Assignee | ||
Comment 10•2 years ago
|
||
Depends on D193944
| Assignee | ||
Comment 11•2 years ago
|
||
This patch creates an (blank) ffmpeg video encoder and builds it within
ffvpx and ffmpeg libraries with different versions. This encoder can be
obtained via FFmpegEncoderModule::CreateVideoEncoder
Depends on D193945
| Assignee | ||
Comment 12•2 years ago
|
||
Depends on D193946
| Assignee | ||
Comment 13•2 years ago
|
||
Depends on D193947
| Assignee | ||
Comment 14•2 years ago
|
||
Depends on D193948
| Assignee | ||
Comment 15•2 years ago
|
||
In FFmpegEncoderModule::CreateVideoEncoder, we should only create video
encoder when the mime type is supported by the underlying FFmpeg
encoder.
Depends on D193949
| Assignee | ||
Comment 16•2 years ago
|
||
Depends on D193950
| Assignee | ||
Comment 17•2 years ago
|
||
This patch addes a gfx::gfxVars::Initialize() in PEMFactory, as what
PDMFactory does.
gfx::gfxVars::CanUseHardwareVideoDecoding() will be checked in
FFmpegLibWrapper::LinkVAAPILibs() during FF{VPX,
mpeg}RuntimeLinker::CreateEncoder via ::Init(). This API required to be
called after gfxVars are initialized. PEMFactory ctor seems a good place
to initialize gfx vars.
Depends on D193951
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 18•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 19•2 years ago
|
||
./mach clang-format --path
dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
Depends on D193601
| Assignee | ||
Comment 20•2 years ago
|
||
Depends on D193601
| Assignee | ||
Comment 21•2 years ago
|
||
Depends on D194127
| Assignee | ||
Comment 22•2 years ago
|
||
Depends on D194120
| Assignee | ||
Comment 23•2 years ago
|
||
Depends on D193945
| Assignee | ||
Comment 24•2 years ago
|
||
Depends on D193945
Updated•2 years ago
|
| Assignee | ||
Comment 25•2 years ago
|
||
This patch implements a function to get AVCodecID by mime type.
| Assignee | ||
Comment 26•2 years ago
|
||
This patch partially implements Init() and Shutdown() to allocate and
release the AVCodecContext respectively. These two functions will be
exectued on the platform's encoder task queue specified in the given
CreateEncoderParams. Thus, the allocated AVCodecContext is a task-queue
only member variable.
Depends on D193952
| Assignee | ||
Comment 27•2 years ago
|
||
This patch add a VideoConfig member into FFmpegVideoEncoder. Since
VideoConfig is a template, its associated type is introduced into
FFmpegVideoEncoder's template.
Depends on D194580
| Assignee | ||
Comment 28•2 years ago
|
||
Depends on D194580
| Assignee | ||
Comment 29•2 years ago
|
||
This patch maps the VideoConfig's member values to AVCodecContext's
member values.
Depends on D194581
| Assignee | ||
Comment 30•2 years ago
|
||
avcodec_open2 is not thread-safe until version 60 [1]. Besides, even it
claims to be thread-safe now, data race can appear in situations [2, 3].
To accommodate order FFmpeg versions, opening/closing the AVCodecContext
in a critical section is the simplest way to avoid data race issues.
The following related tests:
- MediaDataEncoderTest.VP8Create
- MediaDataEncoderTest.VP8Inits
- MediaDataEncoderTest.VP9Create
- MediaDataEncoderTest.VP9Inits
can be run via below command:
MOZ_LOG="FFmpegVideo:5" /mach gtest <MediaDataEncoderTest 1-4>
[1] https://github.com/FFmpeg/FFmpeg/commit/ebf1d0f4bb7e849a4a4481eeba3a96c1df674308
[2] https://ffmpeg.org/pipermail/ffmpeg-devel/2022-January/290914.html
[3] https://ffmpeg.org/pipermail/ffmpeg-devel/2022-January/thread.html#290914
Depends on D194913
| Assignee | ||
Comment 31•2 years ago
|
||
Depends on D194914
| Assignee | ||
Comment 32•2 years ago
|
||
Depends on D195056
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 33•2 years ago
|
||
This patch implement an encoder function based on avcodec_send_frame and
avcodec_receive_packet, which were introduced in FFmpeg 58.
Depends on D195057
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 34•2 years ago
|
||
This patch completes the encoding functionality. It implements a
function copying AVPacket's data to a MediaRawData. Accordingly, the
main encode function can return the encoded data properly.
Depends on D195328
| Assignee | ||
Comment 35•2 years ago
|
||
Depends on D195377
| Assignee | ||
Comment 36•2 years ago
|
||
This patch implements drain function based on avcodec_send_frame and
avcodec_receive_packet, similar to what Encode function did.
Thus, it only works when ffmpeg version is at least 58.
It's worth mentioning that the encoder cannot continue encoding once it
enters draining mode, due to API limitation. Users need to encode data
after draining are encouraged to create a new encoder.
Still, the alternative does exist. If AV_CODEC_CAP_ENCODER_FLUSH is set
in the AVCodec's capabilities of the AVCodecContext, then
avcodec_flush_buffers can be used to flush or drain all the encoded
data without explicitly entering draining mode, instead of sending a
NULL to the avcodec_send_frame. However, since this flag is not set
when using the libvpx encoder (at least on my machine), this approach is
put to the backlog.
With the Drain implementation, the patches so far can be tested with the
additional tests below:
- MediaDataEncoderTest.VP8Encodes
- MediaDataEncoderTest.VP9Encodes
via the following command:
MOZ_LOG="FFmpegVideo:5" ./mach gtest MediaDataEncoderTest.*
Those tests can check the sanity of Encode() and Drain().
Depends on D195378
| Assignee | ||
Comment 37•2 years ago
|
||
This patch re-impelements the av_err2str macro to get the error
message from the error code, since av_strerror needs to be called via
the FFmpegLibWrapper.
Depends on D195379
| Assignee | ||
Comment 38•2 years ago
|
||
Since the current Encode API is implemented by the modern APIs
introduced in ffmpeg 58, the encoder functionalities should be limited
by the version accordingly.
Depends on D195380
| Assignee | ||
Comment 39•2 years ago
|
||
Since the encode(/decode) APIs were changed in ffmpeg 58, I am going to rename this bug and push the implementation based on the older APIs in another bug.
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 40•2 years ago
|
||
The current implementation is only for libvpx, so I am going to reflect this on the bug. Other format support will be tracked in bug 1868402
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 41•2 years ago
|
||
This patch enables the encoding of RGB-type images.
Depends on D195328
Updated•2 years ago
|
| Assignee | ||
Comment 42•2 years ago
|
||
This patch allows linking FFVPX library on any thread.
Depends on D195381
| Assignee | ||
Comment 43•2 years ago
|
||
This patch creates a media.ffmpeg.encoder.enabled pref for enabling
FFmpegVideoEncoder. As a result, it won't be activated in the webrtc
case.
Depends on D195739
Comment 44•2 years ago
|
||
Updated•2 years ago
|
Comment 45•2 years ago
|
||
Comment 46•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/f80b95e89dc3
https://hg.mozilla.org/mozilla-central/rev/87a375e3cf8b
https://hg.mozilla.org/mozilla-central/rev/f373dc87bf48
https://hg.mozilla.org/mozilla-central/rev/7acf94ed98f4
https://hg.mozilla.org/mozilla-central/rev/effde2256c28
https://hg.mozilla.org/mozilla-central/rev/b3160edece06
https://hg.mozilla.org/mozilla-central/rev/86138ee1179f
https://hg.mozilla.org/mozilla-central/rev/fa0141a69328
https://hg.mozilla.org/mozilla-central/rev/64a46c99eaec
https://hg.mozilla.org/mozilla-central/rev/c96b85ca5f90
https://hg.mozilla.org/mozilla-central/rev/fa0d4633cbc9
https://hg.mozilla.org/mozilla-central/rev/5be4e6ab78f1
https://hg.mozilla.org/mozilla-central/rev/c93459f6cdbe
https://hg.mozilla.org/mozilla-central/rev/1c5001fba1a9
https://hg.mozilla.org/mozilla-central/rev/dcc0d26d1be0
https://hg.mozilla.org/mozilla-central/rev/b831b0a96d8f
https://hg.mozilla.org/mozilla-central/rev/e4fc220d0923
https://hg.mozilla.org/mozilla-central/rev/7b938872c0d0
https://hg.mozilla.org/mozilla-central/rev/01e99865ca02
https://hg.mozilla.org/mozilla-central/rev/774a4e3053b3
https://hg.mozilla.org/mozilla-central/rev/3eb4213f5e34
https://hg.mozilla.org/mozilla-central/rev/ccbb7e5e48ae
https://hg.mozilla.org/mozilla-central/rev/2628ce993127
https://hg.mozilla.org/mozilla-central/rev/377ff93825e3
https://hg.mozilla.org/mozilla-central/rev/012bcf903fa8
https://hg.mozilla.org/mozilla-central/rev/5ef06b306a36
https://hg.mozilla.org/mozilla-central/rev/9095886717c2
https://hg.mozilla.org/mozilla-central/rev/5b152c42a6a7
https://hg.mozilla.org/mozilla-central/rev/901e3b9a8e11
https://hg.mozilla.org/mozilla-central/rev/f44e4a298b94
https://hg.mozilla.org/mozilla-central/rev/0b7884423c94
https://hg.mozilla.org/mozilla-central/rev/153024a89a78
https://hg.mozilla.org/mozilla-central/rev/514a900b5ef2
https://hg.mozilla.org/mozilla-central/rev/fa5a88486f5a
https://hg.mozilla.org/mozilla-central/rev/f24499e2e7af
https://hg.mozilla.org/mozilla-central/rev/935b39fd15fd
https://hg.mozilla.org/mozilla-central/rev/dad6d260d8b9
Comment 47•2 years ago
|
||
Comment on attachment 9367506 [details]
Bug 1860899 - Update the new ffmpeg PEM with the new PEM interface. r?chunmin
Revision D195805 was moved to bug 1867542. Setting attachment 9367506 [details] to obsolete.
Description
•