Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dumping audio+video to video files #4602

Merged
merged 10 commits into from Aug 14, 2019

Conversation

zhaowenlan1779
Copy link
Member

@zhaowenlan1779 zhaowenlan1779 commented Jan 26, 2019

relevant build-environments changes: citra-emu/build-environments#14
relevant ext-windows-bin changes: citra-emu/ext-windows-bin#20

This supersedes #4295. A lot of code has been refactored/rewritten, and another some is newly written.

To avoid patent issues, the format of the dumped video is restricted to WebM, and it will use the VP9 (video) and vorbis (audio) codecs, which are both royalty-free.

It is recommended to review commit-by-commit. See the commit messages for more details.

Example video: https://mega.nz/#!dttiCIha!qVSvvZ_GqEstuJUK7hhd9PPBhT5R-2P8uQuQf9XBpRo (this is just a intro, so it's probably not rendered by textures but rather just a video, and resolution may seem low)


This change is Reviewable

Copy link
Contributor

@jroweboy jroweboy left a comment

did a quick mini review, sorry i don't have time atm to do a full review.

src/video_core/renderer_opengl/renderer_opengl.cpp Outdated Show resolved Hide resolved
src/citra_qt/main.cpp Outdated Show resolved Hide resolved

namespace VideoDumper {

VideoFrame::VideoFrame(std::size_t width_, std::size_t height_, u8* data_)
Copy link
Contributor

@jroweboy jroweboy Jan 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be possible to just render the pixels in the expected order straight from opengl? doing this copy sounds like its going to be slower than just doing a memcpy here. (haven't been able to profile it tho)

Copy link
Member Author

@zhaowenlan1779 zhaowenlan1779 Aug 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I do not know about any way of doing this directly in OpenGL. Would be great if someone can instruct me on this though.

@bunnei
Copy link
Member

bunnei commented Mar 8, 2019

Temporarily untagging as canary, since this is conflicting with canary

@zhaowenlan1779
Copy link
Member Author

zhaowenlan1779 commented May 13, 2019

Update: removed dumping progress dialog and AbortProcessing function, as double buffer is used now which shouldn't require much time to finalize dumping.

B3n30
B3n30 approved these changes Aug 9, 2019
src/core/dumping/ffmpeg_backend.cpp Outdated Show resolved Hide resolved
src/core/dumping/ffmpeg_backend.h Outdated Show resolved Hide resolved
std::unique_ptr<AVFrame, AVFrameDeleter> audio_frame{};
std::unique_ptr<SwrContext, SwrContextDeleter> swr_context{};

u8** resampled_data{};
Copy link
Contributor

@B3n30 B3n30 Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could probably be a unique_ptr too

Copy link
Member Author

@zhaowenlan1779 zhaowenlan1779 Aug 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more like some 'array of arrays' so I don't really think unique_ptr is suitable for this. And I cannot use actual arrays for this as it has to be created by a certain function which takes some u8***

The VideoFrame is rotated while copying, to put the pixels in their correct positions (OpenGL seems to return the image in reverted order by default)
This is tested to work with all three current methods - HLE, LLE and multithread LLE.
This should be called by the video dumper backend to tell the video core to create necessary buffers/storage, etc.
Two PBOs are used to speed up pixel copying process. To avoid getting the wrong speed/FPS, a new parameter is added to DrawScreens about whether to increase the frame count.
@zhaowenlan1779
Copy link
Member Author

zhaowenlan1779 commented Aug 14, 2019

I'm looking to merge this soon as this is conflicting with many other PRs.

Last call for reviews.

Sorry for the large diff, the implementation is quite long, and I can't really find a good way to split it into commits.
QtConcurrent is used to stop the video dumping in another thread.
This is useful to test whether Citra will compile without any CMake flags, and in Debug type.
@jroweboy jroweboy merged commit e18c7ee into citra-emu:master Aug 14, 2019
2 of 3 checks passed
@zhaowenlan1779 zhaowenlan1779 deleted the video-dump-reborn branch Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants