Ffmpeg command to stream mkv file to iPhone. The mkv file consists of hevc video, stereo…
- 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
- 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.mp4Key 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 seekinghttp://0.0.0.0:8080/stream.mp4- Serves on all network interfaces on port 8080
To use this:
- Run the command on your computer
- On your iPhone, open Safari and navigate to
http://[your-computer-ip]:8080/stream.mp4 - 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.mp4Note that burning in subtitles requires re-encoding the video, which will use CPU resources and may affect streaming performance depending on your hardware.
- User
Transcode it using intel quicksync
- 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.mp4For 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.mp4Key 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.mp4Note: 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.mp4Make sure your system has Intel Quick Sync support and FFmpeg is compiled with
--enable-libmfxor--enable-libvplfor Quick Sync support.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.