I wanted to pipe ffmpeg output to VLC on Windows which took a little while to figure out. ffmpeg cannot detect
what format to use when piping, so I went through some obvious options but it was unclear what was best. So I
wrote an extremely naive benchmarking script that would run a common stream for two minutes and then take the
CPU/Memory usage data from tasklist /v
before killing the two processes.
system
Proc: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz 3.39GHz
RAM: 16.0 GB
OS: Windows 10 Pro
ffmpeg version
ffmpeg version N-83243-g2080bc3 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 45.100 / 55. 45.100
libavcodec 57. 75.100 / 57. 75.100
libavformat 57. 63.100 / 57. 63.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 70.100 / 6. 70.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
vlc version 2.2.4 Weatherwax
Check results.md for the final table. I believe there is not enough data for any real conclusion since there was not much control (the stream was relatively consistent between runs but not exact by any means) and not much accuracy (cpu usage measured in seconds rather than ms or us). Regardless, it would appear mpegts would be the best overall format for this use case, with mpegtsraw being preferred if CPU was more valued than memory.
This makes sense; I believe HLS streams are m3u8 playlists that consist of ".ts" files which coincide with the mpegts format. Hopefully ffmpeg is just passing this through. The difference between mpegts and mpegtsraw makes some sense: mpegtsraw would have ffmpeg shouldering the cpu burden rather than VLC and it would make sense that ffmpeg would be the better workhorse.
The test.js
file is extremely rough. It has some useful snippets for wrapping the Windows command line tools, such as
getTaskList and killPid. However, nothing handles errors and it'd be much better if everything returned Promises. Finally,
the test.js
file uses console.log for its output rather than something more sane (like writing to a log file). So if
you re-use test.js
for something make sure you capture the output!