echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
Example final command
ffmpeg -i "http://host/folder/file.m3u8" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4
@magicdawn, most of the ffmpeg options here don't do anything so it's particularly confusing trying to understand them.
In most all situations you just need this:
ffmpeg -i "http://host/folder/file.m3u8" -c copy file.mp4
or
to breakdown the original command...
-c copy -vcodec copy
is redundant.
-c copy
says "for all streams, do a stream copy" (no re-encoding). And then-vcodec copy
says "for the video stream[s], do a stream copy".-c copy
is all that's needed. You could also do-vcodec copy -acodec copy
or-codec copy
since-c
is just a short version of-codec
.-crf 50
As you pointed out, since there's no transcoding going on, this video quality flag does nothing. And if it did work,
50
is such low quality that you probably wouldn't like the result. Also this flag is only supported by some codecs. (I wish ffmpeg gave you a warning when you pass in a useless flag!)-bsf:a aac_adtstoasc
These days ffmpeg is smart enough to automatically insert this filter when needed. IMHO it's cleaner to just rely on that rather than always inserting it even when it's not necessary. (like in non-AAC+MPEG-TS streams) If you turn on verbose messaging with
-v verbose
you'll see that ffmpeg informs you of this:You can pull all this together and test things by downloading a stream with and without all these options and see that the resulting files are identical!
Another tip: if youtube-dl works but you want to control how ffmpeg downloads a stream without having to manually snoop for the .m3u8 file, just use youtube-dl's
-g
flag and it'll print out the m3u8 url and exit.$ youtube-dl -g "https://host.com/some-webplay-video"
for example