Giter Club home page Giter Club logo

hd_fpv_video_tool's Introduction

HD FPV video tool

What it is and what it can be used for

It is a Unix compatible command line tool intended to be used for various tasks related to modifying videos recorded with the DJI and Walksnail Avatar FPV video systems (but also works with other video sources) and working with .osd files recorded onto the goggles.

How to use

Available commands

display-osd-file-info

Displays information about the specified OSD file like the recorded OSD layout and font variant which should be used to render the OSD file.

generate-overlay-frames

Generates OSD overlay frames. This command generates numbered OSD frame images from the specified OSD file and writes them into the specified output directory.

Use this command when you want to generate OSD frame images to check what the OSD looks like or when you want to manually burn the OSD onto a video.

generate-overlay-video

Generates an OSD overlay video. This command generates a transparent video with the OSD frames rendered from the specified OSD file. The generated video can then be used to play an FPV video with OSD without having to burn the OSD into the video using the play-video-with-osd command (or any other video player which can overlay a VP8/9 transparent video other another video in real time).

cut-video

Cuts a video file without transcoding by specifying the desired start and/or end timestamp.

fix-video-audio

Fixes a DJI Air Unit video's audio synchronization and/or volume

transcode-video

Transcodes a video file optionally burning OSD onto it. Also provides the option to fix the audio synchronization and/or volume at the same time as transcoding and also to hide things like dead pixels or dirt on the lens.

play-video-with-osd

Plays a video using the MPV video player with OSD by overlaying a transparent OSD video in real time. The transparent OSD video can be generated with the generate-overlay-video command.

help

Prints the CLI commands or help of the given subcommand(s)

Command aliases

The commands can be a bit long to write. For convenience they are aliased to the concatenation of the first letter of each word. For example the generate-overlay-video command can also be called with the gov command.

OSD fonts

To generate OSD overlays the OSD fonts in WTF.FPV bin format are needed. This program is using the fonts in the WTF.FPV bin format for rendering the OSD for both the DJI and Walksnail system. If needed you can convert your custom OSD font from Walksnail format to WTF.FPV bin format using hd_fpv_osd_font_tool. If you are using DJI goggles the same OSD font files you are using on your goggles can be used. You can put the files inside the ~/.local/share/hd_fpv_video_tool/fonts directory so that the program will use them automatically. You can also put them in any location on your filesystem and tell the program where to look using the DJI_OSD_FONTS_DIR environment variable or using the --font-dir or --osd-font-dir options depending on the command.

Example usage

For these examples we are assuming that:

  • You have installed the fonts in the default directory so that they will be found automatically
  • These files are present in the current directory:
    • DJIG0000.osd (the OSD file recorded by your goggles hacked with FPV.WTF)
    • DJIG0000.mp4 (video recorded by your goggles)
    • DJIU0000.mp4 (video recorded by your air unit if it has the capability)

Transcoding a video and burning the OSD onto it

hd_fpv_video_tool transcode-video --osd DJIG0000.mp4

Will automatically use the DJIG0000.osd file in the same directory as the video and automatically select a name for the output file: DJIG0000_transcoded.mp4. The OSD file can automatically be found if it is named with the same DJIGXXXX prefix as the video file or with the same name but with .osd extension. You can also specify the OSD file to use and the output file name manually. The default encoder is libx265 so the output is encoded with the H.265 codec but the video encoder used can be selected with the --video-encoder option. The above command is equivalent to:

hd_fpv_video_tool transcode-video --osd-file DJIG0000.osd DJIG0000.mp4 DJIG0000_transcoded.mp4

If you want to burn the OSD onto a video coming from a DJI FPV air unit with audio you can do so while also fixing the audio synchronization and volume using this command:

hd_fpv_video_tool transcode-video --fix-audio --osd DJIU0000.mp4

Run hd_fpv_video_tool transcode-video --help or hd_fpv_video_tool help transcode-video for a list of all the options available for this command.

Generating a transparent OSD overlay video and playing an unmodified video with OSD

First we need to generate the transparent OSD overlay video:

hd_fpv_video_tool generate-overlay-video --target-video-file DJIG0000.mp4 DJIG0000.osd

This command will encode a transparent OSD overlay video encoded with the VP8 coded by default and write it into the DJIG0000_osd.webm file. The original video DJIG0000.mp4 will not be modified. It is only used to choose the right resolution and OSD scaling for the output video. We can then use the play-video-with-osd command to play the DJIG0000.mp4 file with overlayed OSD:

hd_fpv_video_tool play-video-with-osd DJIG0000.mp4

Installation

Easiest way

The easiest way is to use the AppImage provided in the latest release. It includes all the necessary dependencies. It can be put anywhere on your filesystem, just make it executable and run it. The only disadvantage of this method is that since the AppImage file contains all the dependencies it is fairly big.

Note that the generated AppImage files have only been tested on Fedora and Ubuntu and that on some distros like Ubuntu you may still need to install libfuse v2 for it to work without using the --appimage-extract option. To install libfuse on Debian and derivatives like Ubuntu use this command: sudo apt-get install -y libfuse2.

Building from source

Build dependencies

On Fedora

You probably want to instead install ffmpeg from RPM fusion on Fedora which has support for more codecs so start by installing the RPM Fusion repository:

sudo dnf install "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm"

then run

sudo dnf install -y ffmpeg{,-devel} clang

On Debian or Debian derivatives

sudo apt-get install -y ffmpeg libav{format,util,filter,device}-dev clang pkg-config

On macOS

Install rust and ffmpeg packages with brew:

brew install rust ffmpeg

Then you can continue building the tool with cargo.

Building

cargo install --locked --git https://github.com/shellixyz/hd_fpv_video_tool.git hd_fpv_video_tool

Run-time dependencies

  • ffmpeg built with support for the video codecs you want to use and also VP8/VP9 for using the generate-overlay-video command
  • MPV video player if you want to use the play-video-with-osd command
Installing on Fedora

sudo dnf install -y ffmpeg-free mpv

Note that you probably want to instead install ffmpeg from RPM fusion on Fedora which has support for more codecs:

sudo dnf install "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm"
sudo dnf install -y ffmpeg
Installing on Debian or Debian derivatives

sudo apt-get install -y ffmpeg mpv

hd_fpv_video_tool's People

Contributors

dz0ny avatar iharosi avatar shellixyz avatar skorokithakis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hd_fpv_video_tool's Issues

Walksnail OSD scaling incorrect

When using default scaling, walksnail OSD from Betaflight 4.4 doesn't get scaled appropriately. It seems that the height is correct, but the width seems to stop 1/2 of the way through the actual frame width.

2023-05-07-150529_2545x1233_scrot
AvatarG0018_osd.webm

"AIR" should be bottom centre. The LQ should be top right.

I've tried using -r but it wants 5 values but 2 provided. From the --help it should just be -r 720p or -r 1280x720 but this doesn't seem to work as intended.

OSD file attached.
AvatarG0018.osd.zip

Video stream info:
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m, progressive), 1280x720, 38327 kb/s, 60.13 fps, 60 tbr, 90k tbn (default)

MacOS BF AvatarHD various issues

Hi,

first of al thanks for the great work !

I'm a user with:

Avatar system firmware 31
Betaflight 4.4
MacOS Monterey ( 12.6.x )

using WTF font_hd.bin

I'm having difficulties managing hiding informations ( expecialilty gps ) but that could be an avatar or font limitation I guess ?

the installation is Ok but I have this issues using the tool:

playwithosd not working because it searches for a Videofilename_osd.webm ( I have installed mpv and it works as a standalone cli program )

I want to move the OSD or hide regions but I cannot get any results from the commands :

--min-osd-margins
--osd-hide-regions

I tried this values :

--osd-hide-regions 1,22:100x100
--min-osd-margins 100:100

and other combinations but I get no results and no apparent errors.

Another last cosmetic problem maybe it's simple to correct : return immediately and not at the end of the encoding the error if --osd-hide-items is not working , here is an example of my error:

hd_fpv_video_tool transcode-video --osd --osd-hide-items gpslat,gpslon ./AvatarG0076.mp4
INFO > looking for OSD file associated to video file: ./AvatarG0076.mp4
INFO > found: ./AvatarG0076.osd
INFO > transcoding video: ./AvatarG0076.mp4 -> ./AvatarG0076_with_osd.mp4
INFO > calculated best approach: tile kind: HD - scaling: yes - overlay resolution: 1166x680
INFO > detected HD kind of tiles in /Users/montagna/.local/share/hd_fpv_video_tool/fonts/font_hd.bin
INFO > resizing 256 tiles from 24x36 to 22x34
ERROR > unknown OSD item for Unknown font variant: gpslat

macOS 14 installation fails

Hey there.

Just a quick update on macOS 14.4 installation.
For me it failed with errors E0425, E0609 because of ffmpeg-next 6. Version 7 worked for me

So I've modified the Cargo.toml:

[[package]]
name = "ffmpeg-next"
version = "7.0.0"

and compiled it via cargo install --path .

Thanks pal.

thread main panick

hello

I am trying to add the osd and transcode a walksnail video and I keep getting this error. Other videos work fine, but this one does not

thread 'main' panicked at 'index out of bounds: the len is 512 but the index is 515', src/osd/overlay.rs:99:18

let me know if I should upload the video and osd files somewhere

thank you
Jose Mateus

Trying to find some specific OSD tool

Hi, I am trying to find some specific tool that would export Dji OSD file as PNG sequence with alpha (transparent background), using specified WTFOS font I've created myself (4 bin files). I am on Windows, so not sure if there is anything already developed for that. WTFOS OSD tool exports OSD only burned to DVR footage, but I want it to be on transparent background, so I can overlay it on the top of my GoPro footage that's synced to DVR footage. They do offer some export without the video, but it's on solid color background and then I'd have to manually clean it out (keying) in my video editors, but it never gives me clean, sharp fonts and icons in the final export.

For Walksnail Avatar, I use two py tools and I get perfect results, but there is nothing for Dji WTFOS OSD files out there.

I'd greatly appreciate if you could point me towards the solution. Thank you so much in advance!
Seii-FPV

`DimensionMismatch` error

Since Betaflight 4.4, the HD OSD layout is available and using these .osd files I'm getting the following error on cli:
Screenshot 2023-03-18 at 22 55 59
It looks like it's some kind of a layout dimension mismatch issue.
I've tried the generate-overlay-frames and the transcode-video options but getting the same error.

Info about the .osd file:

INFO  > detected OSD file with DJI_SD tile layout

OSD file type: DJI FPV
Format version: 1
OSD size: 30x15 tiles
OSD tiles dimension: 36x54 px
OSD video offset: x: 180, y: 0 px
OSD Font variant: 1 (Betaflight)
Number of OSD frames: 3477
Highest video frame index: 22776
OSD update rate: 15% of the video frames (9.2Hz or approximately every 7 frames)

Strange thing it's been recognized as an SD file.
I'm not sure if the error is on wtfos, betaflight or hd_fpv_video_tool end. :S

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.