Add playblast: viewport capture to H.264 MP4 via libavcodec

- TimelinePanel: Playblast button opens modal with output dir (native
  folder picker via IFileOpenDialog), custom resolution (HD/FHD/4K
  presets), frame range, and movie export toggle
- UsdSceneRenderer: CaptureFrame() reads pixels from resolved MSAA FBO;
  Render() stores last dimensions for off-screen re-render at capture res
- MovieEncoder: streams RGBA frames directly into MP4 using libavcodec/
  libswscale (H.264, tries libx264 → nvenc → qsv → amf → openh264)
- Application: CapturePlayblastFrame() re-renders at capture resolution
  each frame; opens/writes/closes MovieEncoder inline with the render loop
- FileDialog: BrowseFolder() using Vista-style IFileOpenDialog (COM)
- CMake: FindFFmpeg.cmake locates prebuilt BtbN GPL shared package in
  third_party/ffmpeg; links and copies DLLs for main and test targets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-23 09:36:30 +08:00
parent c796c76561
commit 0538dd3243
12 changed files with 764 additions and 3 deletions
+23
View File
@@ -14,6 +14,7 @@ find_package(OpenGL REQUIRED)
find_package(OpenUSD REQUIRED)
find_package(Imgui REQUIRED)
find_package(Glad REQUIRED)
find_package(FFmpeg REQUIRED)
# USD build that includes hdEmbree (built with PXR_ENABLE_EMBREE_PLUGIN=ON).
# Can be a separate install from OpenUSD_ROOT_DIR; leave empty to search there instead.
@@ -177,6 +178,13 @@ target_link_libraries(UsdLayerManager PRIVATE
OpenUSD::OpenUSD
Imgui::Imgui
Glad::Glad
FFmpeg::FFmpeg
ole32
shell32
)
target_include_directories(UsdLayerManager PRIVATE
"${CMAKE_SOURCE_DIR}/third_party/ffmpeg/include"
)
# Cycles is an ExternalProject; UsdLayerManager must wait for it to finish
@@ -194,6 +202,17 @@ if(WIN32)
_CRT_SECURE_NO_WARNINGS
)
# FFmpeg DLLs — copy all .dll files from third_party/ffmpeg/bin
file(GLOB FFMPEG_RUNTIME_DLLS "${CMAKE_SOURCE_DIR}/third_party/ffmpeg/bin/*.dll")
if(FFMPEG_RUNTIME_DLLS)
add_custom_command(TARGET UsdLayerManager POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${FFMPEG_RUNTIME_DLLS}
"$<TARGET_FILE_DIR:UsdLayerManager>"
COMMENT "Copying FFmpeg runtime DLLs..."
)
endif()
# Copy runtime DLLs to output directory for each configuration
add_custom_command(TARGET UsdLayerManager POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:UsdLayerManager>"
@@ -504,11 +523,13 @@ add_executable(ViewportDisplayTest
target_include_directories(ViewportDisplayTest PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/include
"${CMAKE_SOURCE_DIR}/third_party/ffmpeg/include"
)
target_link_libraries(ViewportDisplayTest PRIVATE
OpenUSD::OpenUSD
Glad::Glad
FFmpeg::FFmpeg
)
if(WIN32)
@@ -550,11 +571,13 @@ add_executable(RendererDiagnosticTest
target_include_directories(RendererDiagnosticTest PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/include
"${CMAKE_SOURCE_DIR}/third_party/ffmpeg/include"
)
target_link_libraries(RendererDiagnosticTest PRIVATE
OpenUSD::OpenUSD
Glad::Glad
FFmpeg::FFmpeg
)
if(WIN32)