====== Streamlink & FFMPEG ====== ===== How to download an m3u8 file ===== $ streamlink -o "input.mp4" https://example.m3u8 720p ===== How to download and combine m3u8 files ===== Use this when trying to download one file (usually through Streamlink) only gives you segments of the whole file. I came across this code because of getting shortened files from Nebula. $ ffmpeg -i "video_example.m3u8" -i "audio_example.m3u8" \ -c copy -map 0:v:0 -map 1:a:0 output.mp4 or $ ffmpeg -i video.mp4 -i audio.mp4 -c copy -map 0:v:0 -map 1:a:0 output.mp4 ===== How to encode downloaded file ===== $ ffmpeg -i input.mp4 output.mkv ===== How to encode and change resolution ===== ffmpeg -i 01.mp4 -vf "scale=1280:720" output.mkv ffmpeg -i MyMovie.mkv -vf scale=-1:720 -c:v libx264 -crf 0 -preset veryslow -c:a copy MyMovie_720p.mkv ffmpeg -i MyMovie.mkv -vf scale=-1:720 -c:v libx264 -crf 51 -preset veryslow -c:a copy MyMovie_720p.mkv The scale video filter is for resizing the video. You just set one size – which is the height in this example – and use -1 for the other dimension. ffmpeg will recalculate the correct value automatically while preserving the aspect ratio. \\ \\ Quality controlled with the -crf option:\\ \\ The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality and a subjectively sane range is 18-28. Consider 18 to be visually lossless or nearly so: it should look the same or nearly the same as the input but it isn't technically lossless. The range is exponential, so increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate. General usage is to choose the highest CRF value that still provides an acceptable quality. If the output looks good, then try a higher value and if it looks bad then choose a lower value.\\ \\ You control the tradeoff between video encoding speed and compression efficiency with the -preset options. Those are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow. Default is medium. The veryslow option offers the best compression efficiency (resulting in a smaller file size for the same quality) but it is very slow – as the name says. \\ \\ The audio will be stream copied directly from the input file to the output file without any changes.