WWBN / AVideo-Encoder

Encoder Server for AVideo Platform Open-Source
https://platform.avideo.com
GNU Affero General Public License v3.0
151 stars 188 forks source link

Multiple encoding at the same time #277

Open akhilleusuggo opened 4 years ago

akhilleusuggo commented 4 years ago

I know @DanielnetoDotCom that YOU think that encoding multiple files at once it's gonna take longer , but that not true . Decoding will be the time savior here . To encode you need to decode ( read ) , but if you decode every time the video's source , you're actually decoding 3 times the same video .

To save some time , you could decode it once for the 3 resolutions . To do that , we need to use the same method as we do on HLS . Example :

ffmpeg -i $input -yourparameters -f mp4 $destination_HD -yourparameters -f mp4 $destination_SD -yourparameters $destination_low

With this line , we're decoding only once , to encode it 3 times.

This could be the real line :

ffmpeg -i {$pathFileName} -vf scale=-2:360 -movflags faststart -preset ultrafast -vcodec h264 -acodec aac -strict -2 -y {$destinationFile_low} -vf scale=-2:480 -movflags faststart -preset ultrafast -vcodec h264 -acodec aac -strict -2 -y {$destinationFile_SD} -vf scale=-2:720 -movflags faststart -preset ultrafast -vcodec h264 -acodec aac -strict -2 -y {$destinationFile_HD}

This would be the ultimate and fastest way to encode a video . As much low end server and high end server will profit from this , since in both cases they're saving a low of decoding power .

The clear example is the pull request that I've made here : https://github.com/WWBN/AVideo-Encoder/commit/53b56c8cd2c6a2fc032a8d8829e775da822bd80d

This one has saved a ton on cpu power .

DanielnetoDotCom commented 4 years ago

I see. This will be a hard upgrade but make sense to me.

at the same line, we can decode all resolutions at once. but I agree it is a really good idea and it will be implemented in the future

akhilleusuggo commented 4 years ago

I really wish to see the mp4 video encoding reworked even if it's a payed plugin . Basically like the HLS , where there's an automatic quality detector and resolutions from 144p to 4k . You did it very well with HLS , and works beatifully . With mp4 will be much much easier , since you don't really need to do much on it , no fragments , no zipping , no EXTM3U playlist , no key required , no protection .

The good thing about mp4 , is the IO saving and fast delivery .