flat assembler
Message board for the users of flat assembler.
Index
> Linux > [fasm2] mpv wrapper for VAAPI example |
| Author |
|
|
Jessé 04 Apr 2026, 22:06
This is a simple idea I had, based on a necessity, which I think many Linux users know beforehand: playing high resolution, high bit rate HEVC files on Linux kind of s..[k], if you know what I mean: you set it right, then in another hardware is broken, or came an update and it stops working at you favorite (most probably only option) player.
I've found a setting over mpv player, that keeps delivering it good across platforms I've tested, so, I decided to turn it into a simple application that sets everything properly and play the video using hardware decoding! Code: ; mpv player wrapper for VAAPI mode ; ; Also ensures rotation disabled, and scale player down to 0.4 ; at start ; format ELF64 executable 3 at 1 shl 36 include 'fastcall_v1.inc' include 'stdmacros.inc' include 'stdio.inc' _code param: .hw.dec db '--hwdec=vaapi', 0 .vo.scale db '--vo-vaapi-scaling=hq', 0 .wnd.scale db '--window-scale=0.4', 0 .wnd.resize db '--auto-window-resize=no', 0 .vid.rotate db '--video-rotate=0', 0 .ply.mode db '--player-operation-mode=pseudo-gui', 0 align 4 Start entry: endbr64 ; Modify first parameter to 'mpv' mov r10, [rsp+8] mov [r10], dword 'mpv' ; Count passed parameters mov ecx, 6 + 3 + 1 ; include extra rep to store NULL pointer add ecx, [rsp] ; plus extra for 16-byte alignment ; Calculate needed stack space ; while preserving 16-byte align shl ecx, 3 and cl, 0F0h ; Save original external parameters' ; pointer and alloc stack space lea rsi, [rsp+8] sub rsp, rcx ; Create new argv[] with wrapper parameters mov rdi, rsp mov r11, rsp movsq lea rax, [param.hw.dec] stosq lea rax, [param.vo.scale] stosq lea rax, [param.wnd.scale] stosq lea rax, [param.wnd.resize] stosq lea rax, [param.vid.rotate] stosq lea rax, [param.ply.mode] stosq shr ecx, 3 sub ecx, 9 rep movsq ; Show full command line printf(<27,"[1;94m","Wrapper command line: ",27,"[1;33m%s ",27,"[0;36m%s", \ " %s %s %s %s %s",27,"[0;32m ",0>, [r11], [r11+8], [r11+16], \ [r11+24], [r11+32], [r11+40], [r11+48]); ; Parse and show user commands lea rbx, [rsp+56] @@ test [rbx], qword -1 jz @f printf("%s ", [rbx]); add rbx, 8 jmp @b ; Append new line at the end, and reset cli colors @@ printf(<27,"[0m",10,0>); ; Exchange place with mpv application with the new ; command line execvp("mpv", rsp); ; If returned, something went wrong perror("Error lauching mpv player"); exit(-1); Of course, this needs mpv player installed on your system. Also, I haven't included a mime type creator to this wrapper application ('cause I don't know how to do it yet), so, you'll probably need to do it by hand. Kind of easy to do on Plasma, by the way. Another point is that it ensures no rotation on the output. Some players can play DJI or GoPro videos, but they play it upside down. Or with no sound. With this wrapper, sound is there, as well as correct video orientation. And, finally, mpv command line is kind of buggy, so, the order of the parameters, if changed, may render them unapplied. As mostly with my examples, all of those beautiful include files can be found here. Not all people will find it useful, unless you have a GoPro or DJI camera file which seems to not be playable on Linux. I also must mention that this modifier uses VAAPI, which is supported by either Intel or AMD GPUs, not Nvidia. So, if you have a 100% Nvidia GPU setup, you'll probably need to change it to VDPAU mode, which I haven't tested. Intel GPUs need 'intel-media-driver' to be installed as well. Cheers!
|
|||||||||||
|
|
Jessé 04 Apr 2026, 22:56
I have deleted the following section, because I think maybe this time people will understand the point. But, anyways, there it is:
-------------------------------------------------- FAQ for the unfocused ones, who can't find the real purpose of my posts yet: Quote:
Hope that I've answered their (dull) questions, let's go into the simple example: ----------------------------------------------------------- Hope it helps. Thanks. Edit: just include your question on my FAQ statement... Last edited by Jessé on 04 Apr 2026, 23:04; edited 1 time in total |
|||
|
|
Jessé 04 Apr 2026, 23:00
Also, I must mention that most (if not all) of those 'great and/or friendly' O.S.es out there has a lot of "wrappers" (or something) to ease the end user experience.
And they're great because of this. Must mention BigLinux here, maybe Linux Mint as well. People writing code for things that could be aliased, or typed in a terminal, or made in python/shell script, but not everyone wants to do it that way! |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.