dfaker / WebmGenerator

UI and Automation to cut, filter and join high quality webms, mp4s or gifs.
Mozilla Public License 2.0
505 stars 33 forks source link

VP9 in MP4 container #99

Open mossly opened 1 year ago

mossly commented 1 year ago

Support for encoding VP9 in an MP4 container would be useful for Discord as webm lacks native iOS support and therefore does not embed.

VP9 is natively supported and does embed on iOS when uploaded in mp4.

Encoding works in ffmpeg, but my attempt to make a custom encode profile for webmgenerator has been unsuccessful.

{"name":"Discord 50M VP9 mp4","editable":false,"outputFormat":"mp4:VP9","maximumSize":"50.0","audioChannels":"No audio"}

dfaker commented 1 year ago

A customer encoder spec would be the way to go, but a direct copy of the vpn doesn't seem to work on iphone:

{
    "name":"VP9 mp4",
    "baseEncoder":"",
    "extension":"mp4",
    "multi-pass-encode":true,
    "commandBlocks":[
        {"cmds":["-shortest", "-copyts", "-start_at_zero", "-c:v","libvpx-vp9"]},

        {"conditions":[["audioChannels","contains","Copy"]],
         "cmds":["-c:a","libopus"],
         "altCmds":[]
        },

        {"cmds":["-stats","-threads","{encoderStageThreads}"]},

        {"selection":{  
            "name":"auto-alt-ref",
            "label":"VP9 auto-alt-ref",
            "default":"6",
            "type":"int",
            "cmds":["-auto-alt-ref", "{value}"]
        }},

        {"selection":{  
            "name":"lag-in-frames",
            "label":"VP9 lag-in-frames",
            "default":"25",
            "type":"int",
            "cmds":["-lag-in-frames", "{value}"]
        }},

        {"conditions":[["passPhase","equals","1"]],
         "cmds":[],
         "altCmds":["-speed", "1"]
        },

        {"cmds":["-flags", "+psnr", "-row-mt", "1", "-tile-columns", "{tileColumns}", "-tile-rows", "0"
                ,"-aq-mode", "0"]
        },

        {"selection":{  
            "name":"arnr-maxframes",
            "label":"VP9 ARNR maximum frames",
            "default":"15",
            "type":"int",
            "cmds":["-arnr-maxframes", "{value}"]
        }},

        {"selection":{  
            "name":"arnr-strength",
            "label":"VP9 ARNR noise filter strength",
            "default":"0",
            "type":"int",
            "cmds":["-arnr-strength", "{value}"]
        }},

        {"selection":{  
            "name":"pixfmt",
            "label":"Output Pixel Format",
            "default":"yuv420p profile:0",
            "options":[
                {"name":"yuv420p10le profile:2","cmds":["-profile:v", "2", "-pix_fmt", "yuv420p10le"]},
                {"name":"yuv420p profile:0","cmds":["-profile:v", "0", "-pix_fmt", "yuv420p"]},
                {"name":"yuv444p12le profile:3","cmds":["-profile:v", "3", "-pix_fmt", "yuv444p12le"]}
            ]
        }},

        {"selection":{  
            "name":"quality",
            "label":"Deadline / Quality",
            "default":"good",
            "options":[
                {"name":"Good","cmds":["-quality", "good"]},
                {"name":"Best","cmds":["-quality", "best"]},
                {"name":"Realtime","cmds":["-quality", "realtime"]}
            ]
        }},

        {"cmds":["-tune-content", "default", "-enable-tpl", "1", "-frame-parallel", "0"
                ,"-metadata", "Title={metadata_title}","-b:v","{br}"]
        },

        {"conditions":[["audioChannels","contains","No audio"]],
         "cmds":["-an"]
        },
        {"conditions":[["audioChannels","contains","Stereo"]],
         "cmds":["-ac","2","-ar","48k", "-b:a","{audoBitrate}"]
        },
        {"conditions":[["audioChannels","contains","Mono"]],
         "cmds":["-ac","1","-ar","48k", "-b:a","{audoBitrate}"]
        },
        {"conditions":[["audioChannels","contains","Copy"]],
         "cmds":["-c:a","copy"]
        },
        {"cmds":["-sn"]}
    ]
}

Any ideas on additonal parameters or options you'd want?