File size: 607 Bytes
5c6ae28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from ffmpy import FFmpeg

def ffmpeg_stream(file_url,token, output="tmp/cache/output.mp4"):
    try:
        # Set up the FFmpeg command with quality options
        ff = FFmpeg(
            inputs={
                file_url: None
            },
            outputs={
                f'{output}': '-c:v libx264 -crf 23 -preset medium -c:a aac -b:a 192k'
            },
            global_options= f'-headers "Authorization: Bearer {token}"'
        )
        
        # Run the command
        ff.run()

    except Exception as e:
        print(f"Error using FFmpeg to stream file: {e}")
        return None