kiến thức Tổng hợp những addon chất cho Firefox / Chromium

xxx cái config của fen là không dùng av01 mà
đổi thành ytdl-format=bestvideo[height<=?1080][vcodec=av01]+bestaudio/best
:beat_shot::beat_brick:
thank fen
Mới tìm ra cách sử dụng profile-cond để ép các trang web trả về chất lượng tùy ý, ví dụ mình muốn Youtube trả về 720p, ép 30FPS cục MP4 gộp cả hình lẫn tiếng, mở file mpv.conf lên thêm vào cuối cùng của file:

Code:
[quality-youtube]
profile-cond=path:match"youtube" ~= nil or filename:match"youtube" ~= nil
profile-restore=copy
ytdl-format=bestvideo[container*=dash][proto*=http_dash_segments][height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/best[height<=720]

Tất nhiên là nếu muốn to hơn 720 thì phải bỏ khả năng gộp video+audio đi và bỏ 30FPS đi mới tăng được, và code sẽ như sau, định dạng MP4:
Code:
[quality-youtube]
profile-cond=path:match"youtube" ~= nil or filename:match"youtube" ~= nil
profile-restore=copy
ytdl-format=bestvideo[height<=?1080][vcodec!=?vp9]+bestaudio/best[height<=1080]

Hoặc nếu muốn định dạng VP9, cá nhân mình không thích VP9 vì nó ngốn CPU và ngốn pin, giảm được tí dung lượng:
Code:
[quality-youtube]
profile-cond=path:match"youtube" ~= nil or filename:match"youtube" ~= nil
profile-restore=copy
ytdl-format=bestvideo[height<=?1080]+bestaudio/best[height<=1080]

Hoặc nếu muốn định dạng VP9 một cách chính xác không nhân nhượng đàm phán gì cả:
Code:
[quality-youtube]
profile-cond=path:match"youtube" ~= nil or filename:match"youtube" ~= nil
profile-restore=copy
ytdl-format=bestvideo[height<=?1080][vcodec*=?vp9]+bestaudio/best[height<=1080]

Hoặc nếu muốn AV1 (kén GPU xịn đời mới, nếu không có nó đẩy về CPU load nặng vô đối):
Code:
[quality-youtube]
profile-cond=path:match"youtube" ~= nil or filename:match"youtube" ~= nil
profile-restore=copy
ytdl-format=bestvideo[height<=?1080][vcodec*=?av01]+bestaudio/best[height<=1080]

Sửa chút lại cho Twitch và ép 480p, ép 30FPS:
Code:
[quality-twitch]
profile-cond=path:match"twitch" ~= nil or filename:match"twitch" ~= nil
profile-restore=copy
ytdl-format=bestvideo[container*=dash][proto*=http_dash_segments][height<=?480][fps<=?30][vcodec!=?vp9]+bestaudio/best

Đơn giản mà hiệu quả, cứ dựa vào của mình chỉnh chọt chút là ngon lành :D, trước mình có chia sẻ một plugin để tự động đổi, mà giờ biết dùng profile-cond rồi thì không cần tới nữa.

Đã cho lên #1.
Đã fix nhé, chắc do trước sửa đi sửa lại thành sửa nhầm luôn do copy từ phần
Tất nhiên là nếu muốn to hơn 720 thì phải bỏ khả năng gộp video+audio đi và bỏ 30FPS đi mới tăng được, và code sẽ như sau, định dạng MP4:

làm phôi trong khi bài hỏi đáp thì lại đúng. :D
 
thank fen
Không dùng VP09 : ytdl-format=bestvideo[height<=?1080][vcodec!*=vp09]+bestaudio/best
Chỉ dùng AV01 : ytdl-format=bestvideo[height<=?1080][vcodec*=av01]+bestaudio/best

dRPgmcw.png
 
Script kéo thả nó cũng thế thím à :adore: chắc vì 1 lý do nào đấy mà nó đẩy về mpv bị cắt luôn đoạn scheme mpv:// chỉ còn có play/abc123 :sneaky:
Thế thì giải pháp dễ nhất chỉ có check hệ điều hành, rồi tự động sửa cho Mac, cái này để xem xem, hình như lua nó cho kiểm tra hệ điều hành.

Có vẻ ez:
Code:
local BinaryFormat = package.cpath:match("%p[\\|/]?%p(%a+)")
if BinaryFormat == "dll" then
    function os.name()
        return "Windows"
    end
elseif BinaryFormat == "so" then
    function os.name()
        return "Linux"
    end
elseif BinaryFormat == "dylib" then
    function os.name()
        return "MacOS"
    end
end
BinaryFormat = nil
 
Thế thì giải pháp dễ nhất chỉ có check hệ điều hành, rồi tự động sửa cho Mac, cái này để xem xem, hình như lua nó cho kiểm tra hệ điều hành.

Có vẻ ez:
local BinaryFormat = package.cpath:match("%p[\\|/]?%p(%a+)")
if BinaryFormat == "dll" then
function os.name()
return "Windows"
end
elseif BinaryFormat == "so" then
function os.name()
return "Linux"
end
elseif BinaryFormat == "dylib" then
function os.name()
return "MacOS"
end
end
BinaryFormat = nil
em đang sửa tạm thế này, thêm vào đằng trc dòng if (url:find("mpv://") ~= 1) then

Python:
local os_name = '', ''
-- LuaJIT shortcut
if jit and jit.os and jit.arch then
    os_name = jit.os
else
    if package.config:sub(1,1) == '\\' then
        -- Windows
        local env_OS = os.getenv('OS')
        if env_OS then
            os_name = env_OS
        end
    else
        -- other platform, assume uname support and popen support
        os_name = io.popen('uname -s','r'):read('*l')
    end
end
if (os_name:lower() == 'darwin') then
    -- msg.info("Dirty fix for MacOS: Add 'mpv://' to start")
    url = 'mpv://' .. url
end

Edit: Sửa lại nốt cho nó đầy đủ, chạy luôn trên cả Windows (code cũ chạy trên Windows sẽ gặp lỗi vì bộ lệnh không có uname)
M7EYXjT.png
 
Last edited:
em đang sửa tạm thế này, thêm vào đằng trc dòng if (url:find("mpv://") ~= 1) then

Less:
local os_name = io.popen('uname -s','r'):read('*l'):lower()
if (os_name == 'darwin') then
        -- msg.info("Dirty fix for MacOS: Add 'mpv://' to start")
        url = 'mpv://' .. url
end
Mình thì chắc chốt với giải pháp này, nếu nó hoạt động như ý nó sẽ cho cả Windows, Mac và Linux, hiện mình mới test nó trên Windows và ra kết quả chính xác, test rất đơn giản nó lợi dụng thư viện loader của MPV để nhận diện hệ thống, dll=win, so=linux, dylib=mac, cách này mình ưng vì hiệu năng tốt, không gọi tiến trình phụ:

Code:
local function getOS()
    local BinaryFormat = package.cpath
    print(BinaryFormat)
    if BinaryFormat:match("dll$") then
        return "Windows"
    elseif BinaryFormat:match("so$") then
        return "Linux"
    elseif BinaryFormat:match("dylib$") then
        return "MacOS"
    end
end

print(getOS())

[protocol_hook] D:\mpv\?.dll;D:\mpv\loadall.dll
[protocol_hook] Windows
 
Mình thì chắc chốt với giải pháp này, nếu nó hoạt động như ý nó sẽ cho cả Windows, Mac và Linux, hiện mình mới test nó trên Windows và ra kết quả chính xác, test rất đơn giản nó lợi dụng thư viện loader của MPV để nhận diện hệ thống, dll=win, so=linux, dylib=mac, cách này mình ưng vì hiệu năng tốt, không gọi tiến trình phụ:

local function getOS()
local BinaryFormat = package.cpath
print(BinaryFormat)
if BinaryFormat:match("dll$") then
return "Windows"
elseif BinaryFormat:match("so$") then
return "Linux"
elseif BinaryFormat:match("dylib$") then
return "MacOS"
end
end

print(getOS())

[protocol_hook] D:\mpv\?.dll;D:\mpv\loadall.dll
[protocol_hook] Windows

Cái này sạch đẹp rồi đó fen :beauty: mình cũng vừa phải sửa lại code trên vì trên Windows không có uname nên lại cũng crash luôn mpv.

Update mới: Mạc-bục lại dùng thư viện dạng .so của Linux
1695737795394.png
 
Last edited:
Cái này sạch đẹp rồi đó fen :beauty: mình cũng vừa phải sửa lại code trên vì trên Windows không có uname nên lại cũng crash luôn mpv.

Update mới: Mạc-bục lại dùng thư viện dạng .so của Linux
View attachment 2093979
Nếu lỗi trên xảy ra cả ở Linux thì không cần quan tâm là so hay dylib, hay là lại dựa vào homebrew để nhận diện ra Mac hay Linux nhỉ, mà Mac nếu cài MPV bằng cách khác thì nó có dùng thư mục homebrew không nhỉ hay là cứ sống chết mặc bay theo đuổi hiệu năng thì đây là trái đắng:

Code:
local function getOS()
    local BinaryFormat = package.cpath
    print(BinaryFormat)
    if BinaryFormat:match("dll$") then
        return "Windows"
    elseif BinaryFormat:match("so$") then
        if BinaryFormat:match("homebrew") then
            return "MacOS"
        else
            return "Linux"
        end
    elseif BinaryFormat:match("dylib$") then
        return "MacOS"
    end
end

print(getOS())

Hơi cục súc nhưng mà hiệu năng vẫn năm cao.
 
@toi la gay :sosad:
À có một fact ko biết thầy để ý ko thì đội ngũ dev của floorp là một đội toàn học sinh, sinh viên đó
Đúng rồi, cơ mà Floorp đã tồn tại ở bên Nhật từ rất lâu rồi và do sinh viên một trường đại học phát triển.

Bởi lớn lên đi làm mục mả ở bên Nhật khó có thời gian để phát triển trình duyệt lắm, sinh viên may ra còn có thời gian. Mà cũng phải công nhận tính năng mới họ thêm vào quá năng suất và tốt đi, phía Firefox có làm nửa năm xong 1 tính năng.
 
Back
Top