Fix MP4 mux for web playback: add faststart and genpts
- Add -movflags +faststart to move moov atom to start - Add -fflags +genpts for proper timestamp generation - Fixes jerky playback and video/audio desync Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -402,25 +402,31 @@ async def get_run(
|
||||
# Detect media type using magic bytes, fall back to database item_type
|
||||
output_cid = run["output_cid"]
|
||||
media_type = None
|
||||
try:
|
||||
from ..services.run_service import detect_media_type
|
||||
cache_path = get_cache_manager().get_by_cid(output_cid)
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
media_type = type_to_mime(simple_type)
|
||||
output_media_type = media_type
|
||||
except Exception:
|
||||
pass
|
||||
# Fall back to database item_type if local detection failed
|
||||
if not media_type:
|
||||
|
||||
# Streaming runs (with ipfs_cid) are always video/mp4
|
||||
if run.get("ipfs_cid"):
|
||||
media_type = "video/mp4"
|
||||
output_media_type = media_type
|
||||
else:
|
||||
try:
|
||||
import database
|
||||
item_types = await database.get_item_types(output_cid, run.get("actor_id"))
|
||||
if item_types:
|
||||
media_type = type_to_mime(item_types[0].get("type"))
|
||||
from ..services.run_service import detect_media_type
|
||||
cache_path = get_cache_manager().get_by_cid(output_cid)
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
media_type = type_to_mime(simple_type)
|
||||
output_media_type = media_type
|
||||
except Exception:
|
||||
pass
|
||||
# Fall back to database item_type if local detection failed
|
||||
if not media_type:
|
||||
try:
|
||||
import database
|
||||
item_types = await database.get_item_types(output_cid, run.get("actor_id"))
|
||||
if item_types:
|
||||
media_type = type_to_mime(item_types[0].get("type"))
|
||||
output_media_type = media_type
|
||||
except Exception:
|
||||
pass
|
||||
artifacts.append({
|
||||
"cid": output_cid,
|
||||
"step_name": "Output",
|
||||
@@ -568,13 +574,17 @@ async def list_runs(
|
||||
for run in runs:
|
||||
# Add output media info
|
||||
if run.get("output_cid"):
|
||||
try:
|
||||
cache_path = cache_manager.get_by_cid(run["output_cid"])
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
run["output_media_type"] = type_to_mime(simple_type)
|
||||
except Exception:
|
||||
pass
|
||||
# Streaming runs (with ipfs_cid) are always video/mp4
|
||||
if run.get("ipfs_cid"):
|
||||
run["output_media_type"] = "video/mp4"
|
||||
else:
|
||||
try:
|
||||
cache_path = cache_manager.get_by_cid(run["output_cid"])
|
||||
if cache_path and cache_path.exists():
|
||||
simple_type = detect_media_type(cache_path)
|
||||
run["output_media_type"] = type_to_mime(simple_type)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Add input media info (first 3 inputs)
|
||||
input_previews = []
|
||||
|
||||
Reference in New Issue
Block a user