News for hackers. Stuff that matters.
Re:How Facebook encodes videos by londons_explore on Sunday April 25, 2021 @05:49PM (#26937030)
I'm surprised Facebook still uses software to do video encoding.

Most big companies with millions of hours of video uploaded each day have realised it's cheaper to stick a bunch of hardware video encoding chips onto an accelerator board and be able to transcode 100 HD streams simultaneously into all the formats and resolutions you need to host.

The power savings on CPU's pay for the custom hardware in a matter of months.

It does reduce flexibility when new video formats get released though.

Re:How Facebook encodes videos by ksec on Monday April 26, 2021 @01:50AM (#26939607)
Google released the paper [1] "Warehouse-scale video acceleration: co-design and deployment in the wild " a few days ago.

https://news.ycombinator.com/item?id=26925307

>It does reduce flexibility when new video formats get released though.

A new video codec is released and adopted once every ten years. So I dont think it would be a problem. Hardware encoding also trade compression quality for speed. And they are compensating it with slightly higher bitrate. It will also reduce their incentives for improving open source encoder.

Although I think even Netflix switched to BEAMR ( Cant really blame them though )

I think the next frontier, for both Audio and Video will be Codec designed with LiveStreaming / Low Latency in mind.

( Or pretty much everything computing, I wish we could focus on latency, from Hardware Input, Display, Network, Disk, etc. Apple is certainly moving in that direction without talking about it. )

Re:How Facebook encodes videos by cpeterso on Monday April 26, 2021 @02:09AM (#26939738)
I was talking with a Netflix product manager a few years ago and, IIUC, he said Netflix re-encodes their entire catalog monthly to take advantage of new encoder optimizations. Disk is cheap. They want to optimize network transfers to both save money and improve user experience.
Re:How Facebook encodes videos by teruakohatu on Monday April 26, 2021 @04:21AM (#26940439)
Netflix has about 36,000 hours of content. On Youtube that much content is uploaded every 1 hour and 20 minutes! Or to put it another way, Netflix re-encodes every month what YouTube encodes in just over an hour.
Re:How Facebook encodes videos by henvic on Monday April 26, 2021 @08:40AM (#26941877)
Your numbers are off. Netflix has more than 36.000 hours of content.
Re:How Facebook encodes videos by viciousvoxel on Monday April 26, 2021 @04:04PM (#26947357)
I don't know the reliability of these sources, but according to one article[1], as of 1 year ago, US Netflix had ~5.8K titles, totaling 36K hours of content. Another more recent source[2] claims that worldwide, Netflix has ~15K titles, so assuming the same distribution of runtimes, it would be closer to 93K hours of content. So, while you're correct, it's still the same order of magnitude.

sources:

[1] https://www.whats-on-netflix.com/news/how-long-would-it-take...

[2] https://www.comparitech.com/blog/vpn-privacy/netflix-statist...

Re:How Facebook encodes videos by sandebert on Monday April 26, 2021 @01:04PM (#26944966)
Care to cite a source?
Re:How Facebook encodes videos by henvic on Monday April 26, 2021 @07:35PM (#26949695)
Back-of-the-envelope calculation: a slacker suffering from insomnia watching 5 streams of Netflix at once × 20 hours/day × 365 days non-stop would otherwise watch the whole catalog in less than a year.

Convinced?

Re:How Facebook encodes videos by sandebert on Tuesday April 27, 2021 @05:44AM (#26953865)
Not really.

If we unpack your calculation to slightly more typical human behaviour: Watching 1 stream × 10 hours/day × 365 days non-stop, one person would need 10 years to watch the whole catalog.

Doesn't seem unreasonable to me.

Re:How Facebook encodes videos by henvic on Tuesday May 04, 2021 @08:11AM (#27036718)
You didn't get the core idea of my calculation: to show that Netflix has times of magnitude more than just 36k hours of content.
Re:How Facebook encodes videos by cpeterso on Monday April 26, 2021 @05:03PM (#26948103)
FWIW, that conversation about Netflix re-encoding their catalog monthly was from about seven years ago! Their process has surely changed since then. :)

Also, IIUC, they re-encoded about once a month, but the re-encoding didn't necessarily take one month of compute time.

Re:How Facebook encodes videos by BlueTemplar on Monday April 26, 2021 @08:57PM (#26950399)
Next codec is likely to be AV1. How does it fare in these situations ?

But also this might be more about protocols, but AFAIK streaming protocols have mostly been abandoned to the favor of chunk downloads over HTTPS ?

Re:How Facebook encodes videos by meteorfox on Sunday April 25, 2021 @05:59PM (#26937109)
Facebook does have hardware for video transcoding. [1] https://youtu.be/0yk4SPRisPA
Re:How Facebook encodes videos by astrange on Sunday April 25, 2021 @09:42PM (#26938438)
Hardware encoders are not as good because they have worse algorithms in order to make them faster. I don’t think you could make an x265 ASIC.

Also, good video codec engineers can’t be hired for any predictable amount of money, and ones who speak Verilog barely exist.

Re:How Facebook encodes videos by yaur on Sunday April 25, 2021 @10:50PM (#26938767)
This used to be true but modern NVIDIA cards beat x264 on both quality and energy cost.
Re:How Facebook encodes videos by izacus on Monday April 26, 2021 @02:40AM (#26939905)
Any links for this? Since my experience shows that Ampere encoding blocks still aren't close to x264 / slow preset when it comes to saving bandwith and delivering quality.

Even with power savings it was usually more economically efficient to run encodes on a large (12+ core) machine than to deal with limited amount of nvenc slots on GPUs.

Re:How Facebook encodes videos by astrange on Monday April 26, 2021 @01:28AM (#26939486)
I believe it, and of course it's going to be better on energy cost. Is that because it supports newer codecs though, or is it on H.264?
Re:How Facebook encodes videos by Wowfunhappy on Monday April 26, 2021 @12:56AM (#26939346)
They do?! Even on the slow presets?
Re:How Facebook encodes videos by paulmd on Monday April 26, 2021 @01:25AM (#26939468)
NVENC beats x264 medium. Not quite up to the level of the "slow" presets yet but you have to throw a huge amount of hardware at it to match them let alone beat them. Basically the number I came up with a few weeks ago from playing around with x264 settings on ffmpeg was between 6 and 12 cores to keep up with NVENC at 720p and 1080p, depending on framerate and the quality preset.
Re:How Facebook encodes videos by ksec on Monday April 26, 2021 @02:01AM (#26939683)
What sort of bitrate are we talking about? I haven't tried using NVENC for years and last time I check it was clearly missing many details that x264 tries to preserve.

NVENC is good at cleaning the noise and fast encoding. ( Or basically Game Streaming ). Which isn't something you want to do if you want to do movies encoding.

Re:How Facebook encodes videos by paulmd on Monday April 26, 2021 @12:20PM (#26944337)
Re:How Facebook encodes videos by Wowfunhappy on Monday April 26, 2021 @01:13PM (#26945090)
> but you have to throw a huge amount of hardware at it to match them let alone beat them.

Sure, and I think hardware encoders are great when you need speed, certainly for real-time video. But in other cases, well, the medium preset sucks. I always encode videos at `veryslow`, and there's just no way to get close to that with a gpu.

Re:How Facebook encodes videos by BlueTemplar on Monday April 26, 2021 @09:00PM (#26950426)
How come ? This looks like to be easily parallelised, so GPUs should wipe the floor with CPUs ?
Re:How Facebook encodes videos by astrange on Tuesday April 27, 2021 @01:50AM (#26952473)
Video encoding isn't GPU-parallelizable. It's a good fit for either CPU+SIMD or custom ASICs. It's just a kind of compression, which means it's based on unpredictable if-statements, which is just what GPUs don't do.

You can mass parallelize it by encoding different clips on different CPUs, this is more optimal because it has less communication overhead.

Re:How Facebook encodes videos by Wowfunhappy on Monday April 26, 2021 @09:20PM (#26950613)
No idea, maybe it will change some day. But right now, if you want the best quality at the smallest filesize, nothing seems to come close to the best software encoders. Maybe x264 and x265 are just really good.
Re:How Facebook encodes videos by astrange on Tuesday April 27, 2021 @01:49AM (#26952462)
They're unusually good because 1. encoding research wasn't done on a business schedule 2. isn't done according to objective metrics (the main ones used, SSIM/PSNR, suck and you have to use human raters) 3. more varied and weirder testcases (some pirated movies, some video game screen recording, more anime).

There's a lot of other free video encoding tools, like avisynth plugins, that are just better than all professional tools. I'm not sure why this is, maybe customers aren't sophisticated enough.

Re:How Facebook encodes videos by BlueTemplar on Tuesday April 27, 2021 @04:15AM (#26953360)
What about AV1 ?
Re:How Facebook encodes videos by retrac on Sunday April 25, 2021 @07:12PM (#26937605)
Hardware encoders for newer codecs tend to be simply less bit-efficient. They can be more limited in features. My desktop's GPU can handle quite a few 1080p H.264 streams in parallel. But it can't do average-bitrate-capped CRF, which I think is the preferred type of encoding for streaming services.
Re:How Facebook encodes videos by rubatuga on Sunday April 25, 2021 @07:18PM (#26937648)
Weird, NVENC supports this, I've used it for streaming before.
Re:How Facebook encodes videos by 867-5309 on Sunday April 25, 2021 @08:23PM (#26938075)
AMD consumer identified
Re:How Facebook encodes videos by jimmySixDOF on Sunday April 25, 2021 @11:00PM (#26938813)
Like someone already pointed out this whole announcement could be in response to Google announcing this week it's new Argos chipset approach to transcoding

[1] https://arstechnica.com/gadgets/2021/04/youtube-is-now-build...

Re:How Facebook encodes videos by manca on Sunday April 25, 2021 @10:23PM (#26938623)
The problem is that most of the big tech thinks they are smarter than 1000's of codec engineers who worked on libx264 and they try to reinvent the wheel. They realize too late that all the money they threw into building their own stuff (or variants) do far worse in general case than the baseline libx264. They just don't want to admit it.
Re:How Facebook encodes videos by mlazos on Monday April 26, 2021 @12:05AM (#26939165)
I don’t think it’s that they don’t want to admit it, it’s that the cost savings from something disruptive may make it worth it at scale. Or that somebody wants to risk their career on it haha and big tech has tons of cash to throw around.
Re:How Facebook encodes videos by LdSGSgvupDV on Sunday April 25, 2021 @11:26PM (#26938956)
BidTechEngineer: Ya, I know, but I need that wasted money.
Re:How Facebook encodes videos by manca on Sunday April 25, 2021 @11:42PM (#26939038)
Absolutely. In fact, I interviewed a guy last week that comes from very big tech and he basically himself admitted that they're basically wasting time and money chasing unknown "ideal" codec while almost always those projects hit dead end. He loves the money, I am sure, but he wants out anyway. :)
Re:How Facebook encodes videos by Tade0 on Monday April 26, 2021 @01:52AM (#26939619)
Who wouldn't eventually?

I've been to a project where, because the development and "hardening" budgets were separate, we knowingly pushed out buggy code so that we could take advantage of the latter.

Had I known that half of the job would be to game the system, I wouldn't have joined.

Re:How Facebook encodes videos by nowherebeen on Monday April 26, 2021 @02:10AM (#26939745)
> half of the job would be to game the system, I wouldn't have joined.

Bureaucracy is inevitable once a certain number of people join a group.

Re:How Facebook encodes videos by ClumsyPilot on Monday April 26, 2021 @05:37AM (#26940796)
"Had I known that half of the job would be to game the system"

You should be happy it's only half!

Re:How Facebook encodes videos by ignoramous on Monday April 26, 2021 @02:11AM (#26939753)
...and I need that promotion to Senior Staff.
Re:How Facebook encodes videos by esperent on Monday April 26, 2021 @02:32AM (#26939856)
I think libx265 is the baseline now BTW (correct me if I'm wrong).
Re:How Facebook encodes videos by webmobdev on Sunday April 25, 2021 @07:30PM (#26937733)
I would be suprised if FB doesn't use hardware encoders. That said, hardware encoders are fast, but they don't match the quality of the software (CPU) encoding. Slower CPU encoding still provide the best quality.
Re:How Facebook encodes videos by thefourthchime on Sunday April 25, 2021 @08:08PM (#26937985)
I can’t speak for all of the encoding options. But I can tell you that Dolby Hybrik, one of the main competitors and encoding space uses relatively cheap ec2 instances.

Based on the speed I see from Telestream and Elemental. I think they’re software based as well

Re:How Facebook encodes videos by cobookman on Monday April 26, 2021 @12:43AM (#26939311)
Youtube and Facebook have a much different encoding problem then say HBO/Netflix/Hulu...etc

YT & FB have a few popular videos, and a ginormous long-tail. That long-tail needs to be encoded, and cheaply as it might not get many views.

The TV/Movie VOD over IP industry stands to benefit optimizing the encoding to have the smallest filesize with highest quality. Spending considerable CPU cycles to find that best quality path.

For those like Netflix, why would you invest with ASICs. You likely don't have a huge infra bill (relatively) when it comes to encoding. And CPU vs ASICs, the ASICs mean you loose flexibility to really fine-tune the quality and use the latest codecs.

For those like YT/FB. You just gotta encode that long tail. Getting something cheap that's 80% the quality of CPU-based encoding is good enough for 99% of the content.

Re:How Facebook encodes videos by mnt16 on Monday April 26, 2021 @02:40AM (#26939902)
Elemental is a mix of software and hardware encoding. They utilize GPU’s for some portion on the encode.
Re:How Facebook encodes videos by dheera on Monday April 26, 2021 @12:04AM (#26939160)
I could see lots of reasons to do software encoding at a company like Facebook which are probably not mentioned in the article, including e.g. extracting the optical flow which can be reused as part of various machine learning workflows.

For example, if you want to only annotate 1 in 100 frames and interpolate with optical flow, you can get the flow in the process of doing video compression.

I don't have inside info but there are various other things like this that I can think of for wanting to do it in software.

Also, hardware encoders suck if the company making the hardware decides to suddenly EOL the product. With software encoders you can easily scale the backend whenever you want, at any time in the future, and without succumbing to supply chain issues.

Re:How Facebook encodes videos by tinus_hn on Monday April 26, 2021 @07:57AM (#26941577)
If you’re Facebook, the company making the hardware doesn’t suddenly decide to EOL the product, or they are sued for millions for breach of contract.
Re:How Facebook encodes videos by ZeroGravitas on Monday April 26, 2021 @04:08AM (#26940387)
I've seen this contrasted with the Google stuff but it seemed to me the two approaches were entirely complementary.

Facebook, which videos will we transcode into what versions.

Google, with this list of videos to transcode how can we do it cheaply on a massive scale.

I didn't spot anything that pitted approaches against each other.

Re:How Facebook encodes videos by ynx on Monday April 26, 2021 @02:12AM (#26939756)
counterpoint: if you're big enough to have your own bona-fide cloud, then you might have more spare CPU capacity that can be flexibly allocated than available PCs with dedicated GPU
Re:How Facebook encodes videos by zaphirplane on Monday April 26, 2021 @07:33AM (#26941424)
If you are in the cloud business you are worried about heating power, with powering down disks a real thing
Re:How Facebook encodes videos by PicassoCTs on Monday April 26, 2021 @06:10AM (#26940990)
? Xilinx for the rescue?
Re:How Facebook encodes videos by prvc on Sunday April 25, 2021 @07:29PM (#26937725)
What was mentioned in the article seem like very basic, obvious considerations. Meanwhile, Youtube has custom ASICs which efficiently produce multiple formats simultaneously.
Re:How Facebook encodes videos by jeffbee on Sunday April 25, 2021 @07:30PM (#26937732)
And yet, despite YouTube's abundantly clear motivation for doing so it took them years and years to develop the hardware and it only recently hit production. Could it be that acceleration for video encoding isn't as easy as people are making it sound?
Re:How Facebook encodes videos by dylan604 on Sunday April 25, 2021 @08:03PM (#26937952)
I'm waiting for the "meh, i could roll it out in a weekend" responses.
Re:How Facebook encodes videos by yjftsjthsd-h on Sunday April 25, 2021 @08:31PM (#26938123)
Of course I could;) It would just be hacky, ugly, unreliable, scale badly, use either GPUs or inadequate FPGAs, and fall over once it exceeded 10 users. My resume doesn't need to know that, though:)
Re:How Facebook encodes videos by dylan604 on Sunday April 25, 2021 @08:52PM (#26938202)
You now know 1 way of not to do it.