mirror of
https://github.com/facefusion/facefusion.git
synced 2026-08-03 23:58:37 +02:00
* mark as next * unify the dependency checks in pre_check and add ffprobe (#1181) * drop keep_temp and the common options component (#1180) Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * introduce ffprobe and ffprobe_builder (#1182) * introduce ffprobe and ffprobe_builder Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * introduce ffprobe and ffprobe_builder Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * probe video metadata via ffprobe in vision (#1184) * probe video metadata via ffprobe in vision Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * probe video metadata via ffprobe in vision Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * adopt the workflow task vocabulary from next major (#1185) Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * introduce workflow-mode and workflow-strategy like next major (#1187) Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * restrict hdr color transfer and tag the merge output as bt709 (#1188) * restrict hdr color transfer and tag the merge output as bt709 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * restrict hdr color transfer and tag the merge output as bt709 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * full video migration * compose the hdr fixture via the builder chain Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * compose the test fixtures via the builder and run_ffmpeg Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * compose every test fixture via the builder and run_ffmpeg (#1189) * compose every test fixture via the builder and run_ffmpeg Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * use loops in tests for ffmpeg stuff --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * New Video Manager (#1191) * tiny adjustment for tests * address the review on the video manager Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * introduce the stream strategy for the video workflow (#1192) * introduce the stream strategy for the video workflow Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * address the review on the stream strategy Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * annotate the changes for review Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * annotate the new tests for review Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * match the temp pixel format help to the locale style Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * question the set_input_seek naming Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * question the reader and writer keys Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the review annotations from the encoder mapping tests Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the review annotations from the thread count tests Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the review annotations from the ui files Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * capture the open review questions as annotations Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the settled annotations from the types Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * switch to ffmpeg.style for audio.py * remove todos that were never needed * fix for ffmpeg7 * Add frame_store module (#1194) * add frame_store module * rename and change tests * rename and update tests * route window read through frame_store (#1196) * route window read through frame_store * update proper id * restore todos * restore todos * go v4 style for workflow (#1197) * go v4 style for workflow * remove some todos * route chunk read through frame_store (#1198) * vision integration * Deleted read_video_chunk + read_static_video_chunk * margin decouple (#1199) * fix windows CI fail (#1200) * Cleanup Part1 (#1201) * remove some todos, improve video manager, simplify ffmpeg commands and more * do more * remove thread count for filters * Cleanup Part 2 (#1202) * tons of renaming * tons of renaming * multi reader approach * bring tests to an okay-ish state * bring drain back * improve read_video_frame speed * rename method * move variables * seek video reader only when trim frame start is larger 0 * make stream the default * Cleanup/part 3 (#1203) * remove todo * sort out workflow, to match upcoming v4 * remove look ahead * remove core namespace again * Revamp execution provider overrides/adjustments (#1206) * Split provider hooks into override/adjust with cached CoreML base Replace the single resolve_inference_providers processor hook with two: override_inference_providers (full replacement) and adjust_inference_providers (merge options onto the base providers built by create_inference_providers). This lets CoreML processors inherit ModelCacheDirectory + SpecializationStrategy from the base while layering ModelFormat/MLComputeUnits on top. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HTQCZiYjJyUX11bDpbRSiB * fix caching for execution provider by having override and adjust ways * fix caching for execution provider by having override and adjust ways * fix lint * use proper pytest fixtures --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix update preview bug (#1205) * fix update preview bug * fix update preview bug * remove guard * add is_vision_frame * Restrict the preview frame slider and the reader seek to the last frame index (#1207) * fix index bug * fix rounding bug * avoid tobytes copy (#1208) * beautify tests * hide ffmpeg warnings * simplify process_stream_frame * Use is vision frame everywhere (#1210) * use is_vision_frame everywhere * fix hash * fix lint * fix hash creation in face store * that model does not exist * update workflow ffmpeg * guard workflow (#1211) * bump version and dependencies * Update preview * switch workflow strategy to disk|memory * update preview * update preview * fix wording * last minute change workflow position * adjust wording --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com> Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
131 lines
3.7 KiB
Python
131 lines
3.7 KiB
Python
import subprocess
|
|
from functools import lru_cache
|
|
from typing import Dict, List
|
|
|
|
from facefusion import ffprobe_builder
|
|
from facefusion.types import AudioMetadata, Buffer, Command, Fps, VideoMetadata
|
|
|
|
|
|
def run_ffprobe(commands : List[Command]) -> subprocess.Popen[Buffer]:
|
|
commands = ffprobe_builder.run(commands)
|
|
return subprocess.Popen(commands, stderr = subprocess.PIPE, stdout = subprocess.PIPE)
|
|
|
|
|
|
def parse_entries(output : Buffer) -> Dict[str, str]:
|
|
media_entries = {}
|
|
|
|
if output:
|
|
lines = output.decode().strip().splitlines()
|
|
|
|
for line in lines:
|
|
if '=' in line:
|
|
key, value = line.split('=', 1)
|
|
media_entries[key] = value
|
|
|
|
return media_entries
|
|
|
|
|
|
def probe_audio_entries(audio_path : str, entries : List[str]) -> Dict[str, str]:
|
|
commands = ffprobe_builder.chain(
|
|
ffprobe_builder.select_stream('a:0'),
|
|
ffprobe_builder.show_stream_entries(entries),
|
|
ffprobe_builder.format_to_key_value(),
|
|
ffprobe_builder.set_input(audio_path)
|
|
)
|
|
|
|
output, _ = run_ffprobe(commands).communicate()
|
|
|
|
return parse_entries(output)
|
|
|
|
|
|
def probe_video_entries(video_path : str, entries : List[str]) -> Dict[str, str]:
|
|
commands = ffprobe_builder.chain(
|
|
ffprobe_builder.select_stream('v:0'),
|
|
ffprobe_builder.show_stream_entries(entries),
|
|
ffprobe_builder.format_to_key_value(),
|
|
ffprobe_builder.set_input(video_path)
|
|
)
|
|
|
|
output, _ = run_ffprobe(commands).communicate()
|
|
|
|
return parse_entries(output)
|
|
|
|
|
|
def probe_format_entries(media_path : str, entries : List[str]) -> Dict[str, str]:
|
|
commands = ffprobe_builder.chain(
|
|
ffprobe_builder.show_format_entries(entries),
|
|
ffprobe_builder.format_to_key_value(),
|
|
ffprobe_builder.set_input(media_path)
|
|
)
|
|
|
|
output, _ = run_ffprobe(commands).communicate()
|
|
|
|
return parse_entries(output)
|
|
|
|
|
|
@lru_cache(maxsize = 128)
|
|
def extract_static_audio_metadata(audio_path : str) -> AudioMetadata:
|
|
return extract_audio_metadata(audio_path)
|
|
|
|
|
|
def extract_audio_metadata(audio_path : str) -> AudioMetadata:
|
|
audio_entries = probe_audio_entries(audio_path, [ 'sample_rate', 'channels' ])
|
|
format_entries = probe_format_entries(audio_path, [ 'duration', 'bit_rate' ])
|
|
|
|
duration = float(format_entries.get('duration'))
|
|
sample_rate = int(audio_entries.get('sample_rate'))
|
|
frame_total = round(duration * sample_rate)
|
|
channel_total = int(audio_entries.get('channels'))
|
|
bit_rate = int(format_entries.get('bit_rate'))
|
|
|
|
audio_metadata : AudioMetadata =\
|
|
{
|
|
'duration' : duration,
|
|
'frame_total' : frame_total,
|
|
'channel_total' : channel_total,
|
|
'sample_rate' : sample_rate,
|
|
'bit_rate' : bit_rate
|
|
}
|
|
|
|
return audio_metadata
|
|
|
|
|
|
@lru_cache(maxsize = 128)
|
|
def extract_static_video_metadata(video_path : str) -> VideoMetadata:
|
|
return extract_video_metadata(video_path)
|
|
|
|
|
|
def extract_video_metadata(video_path : str) -> VideoMetadata:
|
|
video_entries = probe_video_entries(video_path, [ 'width', 'height', 'r_frame_rate', 'color_transfer' ])
|
|
format_entries = probe_format_entries(video_path, [ 'duration', 'bit_rate' ])
|
|
|
|
duration = float(format_entries.get('duration'))
|
|
fps = extract_video_fps(video_entries.get('r_frame_rate'))
|
|
frame_total = round(duration * fps)
|
|
width = int(video_entries.get('width'))
|
|
height = int(video_entries.get('height'))
|
|
bit_rate = int(format_entries.get('bit_rate'))
|
|
color_transfer = video_entries.get('color_transfer', 'unknown')
|
|
|
|
video_metadata : VideoMetadata =\
|
|
{
|
|
'duration' : duration,
|
|
'frame_total' : frame_total,
|
|
'fps' : fps,
|
|
'resolution' : (width, height),
|
|
'bit_rate' : bit_rate,
|
|
'color_transfer' : color_transfer
|
|
}
|
|
|
|
return video_metadata
|
|
|
|
|
|
def extract_video_fps(frame_rate : str) -> Fps:
|
|
if frame_rate and '/' in frame_rate:
|
|
numerator, denominator = frame_rate.split('/')
|
|
|
|
if int(numerator) and int(denominator):
|
|
return int(numerator) / int(denominator)
|
|
|
|
return 0.0
|