Skip to content
The Chat Archive
claude-opus-4-20250514· Anthropic LMArena Human Preference 140K

Ffmpeg command to stream mkv file to iPhone. The mkv file consists of hevc video, stereo…

  1. User

    Ffmpeg command to stream mkv file to iPhone. The mkv file consists of hevc video, stereo aac audio and ass subtitles. Burn in the subtitles when streaming to compatible formats for iphone 13

  2. Assistant

    Here's an FFmpeg command to stream an MKV file with HEVC video, AAC audio, and burned-in ASS subtitles to an iPhone 13:

    ffmpeg -i input.mkv -vf "subtitles=input.mkv" -c:v libx264 -preset fast -crf 23 -profile:v high -level 4.1 -pix_fmt yuv420p -c:a aac -b:a 128k -ac 2 -movflags +faststart -f mp4 -listen 1 -seekable 1 http://0.0.0.0:8080/stream.mp4
    

    Key parameters explained:

    • -vf "subtitles=input.mkv" - Burns in the ASS subtitles from the MKV file
    • -c:v libx264 - Re-encodes to H.264 since it has better compatibility than HEVC for streaming
    • -preset fast - Balances encoding speed and quality for real-time streaming
    • -crf 23 - Good quality setting (lower = better quality, higher = smaller file)
    • -profile:v high -level 4.1 - Compatible with iPhone 13
    • -pix_fmt yuv420p - Ensures compatibility
    • -c:a aac -b:a 128k -ac 2 - Keeps AAC audio, ensures stereo output
    • -movflags +faststart - Optimizes for streaming
    • -f mp4 - Output format
    • -listen 1 -seekable 1 - Creates an HTTP server that allows seeking
    • http://0.0.0.0:8080/stream.mp4 - Serves on all network interfaces on port 8080

    To use this:

    1. Run the command on your computer
    2. On your iPhone, open Safari and navigate to http://[your-computer-ip]:8080/stream.mp4
    3. The video should play directly in the browser

    If you want to keep HEVC (iPhone 13 supports it) and avoid re-encoding for better performance:

    ffmpeg -i input.mkv -vf "subtitles=input.mkv" -c:v libx265 -preset ultrafast -crf 23 -tag:v hvc1 -c:a copy -movflags +faststart -f mp4 -listen 1 -seekable 1 http://0.0.0.0:8080/stream.mp4
    

    Note that burning in subtitles requires re-encoding the video, which will use CPU resources and may affect streaming performance depending on your hardware.

  3. User

    Transcode it using intel quicksync

  4. Assistant

    Here's an FFmpeg command using Intel Quick Sync for hardware-accelerated transcoding:

    ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -i input.mkv -vf "subtitles=input.mkv,format=nv12,hwupload=extra_hw_frames=64" -c:v h264_qsv -preset fast -global_quality 23 -profile:v high -level 4.1 -c:a aac -b:a 128k -ac 2 -movflags +faststart -f mp4 -listen 1 -seekable 1 http://0.0.0.0:8080/stream.mp4
    

    For better performance with subtitle burning, you might want to use this approach:

    ffmpeg -hwaccel qsv -hwaccel_output_format qsv -i input.mkv -vf "subtitles=input.mkv,format=nv12" -c:v h264_qsv -preset fast -global_quality 23 -profile:v high -level 4.1 -c:a aac -b:a 128k -ac 2 -movflags +faststart -f mp4 -listen 1 -seekable 1 http://0.0.0.0:8080/stream.mp4
    

    Key Quick Sync parameters:

    • -hwaccel qsv - Enables Quick Sync hardware acceleration
    • -hwaccel_output_format qsv - Keeps frames in GPU memory
    • -c:v h264_qsv - Uses Intel Quick Sync H.264 encoder
    • -global_quality 23 - Quality setting for QSV (similar to CRF)
    • -preset fast - QSV preset (veryfast, faster, fast, medium, slow, slower, veryslow)

    If you want to keep HEVC with Quick Sync:

    ffmpeg -hwaccel qsv -hwaccel_output_format qsv -i input.mkv -vf "subtitles=input.mkv,format=nv12" -c:v hevc_qsv -preset fast -global_quality 23 -tag:v hvc1 -c:a aac -b:a 128k -ac 2 -movflags +faststart -f mp4 -listen 1 -seekable 1 http://0.0.0.0:8080/stream.mp4
    

    Note: Subtitle burning requires CPU processing even with hardware encoding, as the subtitle filter runs on CPU. This creates a CPU->GPU transfer bottleneck. For pure hardware acceleration without subtitles, you could use:

    ffmpeg -hwaccel qsv -hwaccel_output_format qsv -c:v hevc_qsv -i input.mkv -c:v h264_qsv -preset fast -global_quality 23 -profile:v high -level 4.1 -c:a aac -b:a 128k -ac 2 -movflags +faststart -f mp4 -listen 1 -seekable 1 http://0.0.0.0:8080/stream.mp4
    

    Make sure your system has Intel Quick Sync support and FFmpeg is compiled with --enable-libmfx or --enable-libvpl for Quick Sync support.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.