Add all audio tracks and mov flags to try and allow stream
This commit is contained in:
@@ -153,30 +153,17 @@ async def stream_video(video_id: str, current_user: dict = Depends(is_user)):
|
|||||||
raise HTTPException(status_code=404, detail="Video file not found on disk")
|
raise HTTPException(status_code=404, detail="Video file not found on disk")
|
||||||
|
|
||||||
async def generate_video_chunks():
|
async def generate_video_chunks():
|
||||||
# FFmpeg command to transcode to MP4 (H.264/AAC) and output to stdout
|
|
||||||
# -i: input file
|
|
||||||
# -movflags frag_keyframe+empty_moov: essential for fragmented MP4,
|
|
||||||
# allowing playback before full file is downloaded
|
|
||||||
# -f mp4: output format is MP4
|
|
||||||
# -codec:v libx264: video codec H.264
|
|
||||||
# -preset veryfast: transcoding speed vs quality trade-off (adjust as needed)
|
|
||||||
# -crf 28: constant rate factor for H.264 quality (higher is lower quality/smaller file, 23 is default for libx264)
|
|
||||||
# -codec:a aac: audio codec AAC
|
|
||||||
# -b:a 128k: audio bitrate
|
|
||||||
# -vf scale=-1:720: scale video height to 720 pixels, maintain aspect ratio (adjust or remove if not needed)
|
|
||||||
# -loglevel warning -hide_banner: suppress verbose FFmpeg output for cleaner logs
|
|
||||||
# pipe:1: output to stdout
|
|
||||||
ffmpeg_command = [
|
ffmpeg_command = [
|
||||||
'ffmpeg',
|
'ffmpeg',
|
||||||
'-i', full_path,
|
'-i', full_path,
|
||||||
'-movflags', 'frag_keyframe+empty_moov',
|
'-movflags', 'frag_keyframe+empty_moov+omit_tfhd_offset+frag_discont+default_base_moof',
|
||||||
'-f', 'mp4',
|
'-f', 'mp4',
|
||||||
'-codec:v', 'libx264',
|
'-codec:v', 'libx264',
|
||||||
'-preset', 'ultrafast',
|
'-preset', 'ultrafast',
|
||||||
'-crf', '28',
|
'-crf', '28',
|
||||||
'-codec:a', 'aac',
|
'-codec:a', 'aac',
|
||||||
'-b:a', '128k',
|
'-b:a', '128k',
|
||||||
'-vf', '"scale=iw/2:ih/2"',
|
'-map', '0:a',
|
||||||
'-loglevel', 'warning',
|
'-loglevel', 'warning',
|
||||||
'-hide_banner',
|
'-hide_banner',
|
||||||
'pipe:1'
|
'pipe:1'
|
||||||
|
|||||||
Reference in New Issue
Block a user