4 ms·
For synchronized group watching I typically encode to h264 and aac in mp4. Video: render subtitles if available, downscale to 720p if larger, ensure yuv420p, e
by Am4TIfIsER0ppos 2y ago
For synchronized group watching I typically encode to h264 and aac in mp4. Video: render subtitles if available, downscale to 720p if larger, ensure yuv420p, encode with: preset slow, crf 24, and tune animation or film as appropriate. Copy audio if aac, 2 channel, and bitrate is less than 160k otherwise: force 2 channel, encode at 128k. Fast start is needed otherwise I'd use a separate program to put the "header" at the start.
As for your command line, what do you think -g 52 does? Why do you give conflicting audio channel settings?
- atoav 2y agoEnsuring yuv410p is the real important addition of this post. If you don't do that, depending on the user input you will end up with a mp4 that won't play. AAC is more standard for mp4 video than opus, although I agree opus is the superior CODEC. Whether the benefits of opus outweigh the downsides of it being non-standard in your usecase is not mine to decide, but if you are looking to produce a thing that is similar to most other web video things out there I'd go with AAC. The saved bandwith is probably miniscule in comparison to what you could save on the video side.
- indulona 2y agoopus has no issues with support, why go with older aac then?
- anotherhue 2y agoIf you think opus has no issues you must not have tested many devices. If your subset handles it, great, but don't be dismissive.
- atoav 2y agoMany users of youtube/Vimeo are used to supplying their files like that. Most GUI tools won't have Opus. So if you care about your users delivering already encoded files AAC might be the wiser choice. This depends on your target audience however
- indulona 2y ago[flagged]
- ccvannorman 2y agoSeconding this: adding "-pix_fmt yuv420p" to your conversion will ensure compatibility, for example if you try attaching a converted MP4 to a WhatsApp chat, it will not show a preview or play unless you include this flag.
- indulona 2y ago-g 52 = at the latest every 52nd frame will be a key-frame(so little over 2 seconds at 24 fps), this influences seeking(how long an image might have artifacts before it renders properly). there are no two conflicting audio channels settings. the -ar is audio sampling rate(data points per second) whereas -maxrate:a is bitrate(actual bits of data per second). the yuv is good point, i guess i is a safe-guard for exotic input. also, copying the audio might be worth it, although then i would end up with mixed output files where one might be original aac and another might be opus. so i think i prefer the uniform output over some saving in processing.
- Am4TIfIsER0ppos 2y agoOkay there is some thought put into your choice of keyframe interval. And there is a conflict. You allow the aformat filter to negotiate for 5.1, 7.1, or stereo but then insist there must be 2 audio channels. I copy the audio when it is suitable just to save another lossy encode.
- indulona 2y agohttps://trac.ffmpeg.org/ticket/5718 https://trac.ffmpeg.org/ticket/5718