Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile from source code? #1778

Closed
4 tasks done
artenax opened this issue Nov 15, 2023 · 13 comments
Closed
4 tasks done

How to compile from source code? #1778

artenax opened this issue Nov 15, 2023 · 13 comments

Comments

@artenax
Copy link

artenax commented Nov 15, 2023

I have a lot of issues to go through, so in order to make it easier for me to help you, I ask that you please try these things first

Description

Provide instructions, please. I have Ubuntu 22.04. I would like to recompile the program and increase the bitrate, it is too low, poor quality.

Graph using plotbitrate:
lossless-cut

@mifi
Copy link
Owner

mifi commented Nov 15, 2023

Are you talking about smart cut bit rate?

https://github.com/mifi/lossless-cut/blob/master/.github/workflows/build.yml

@artenax
Copy link
Author

artenax commented Nov 15, 2023

build.yml

What should I do with this file? Will GitHub build it?

Are you talking about smart cut bit rate?

Yes.

@mifi
Copy link
Owner

mifi commented Nov 15, 2023

What should I do with this file? Will GitHub build it?

yes you can either use github actions in your fork, or you can translate/run commands from that file locally on your computer

Are you talking about smart cut bit rate?

Yes.

I already increased bitrate by 20%, but maybe that was not enough: c01f0cf

see also existing discussions here: #126 (comment)

What does bit_rate and max_bit_rate metadata say on the file you're trying to smart cut?

@artenax
Copy link
Author

artenax commented Nov 15, 2023

I installed nodejs 18.18.2 in /usr/local
sudo npm install -g yarn

git clone https://github.com/mifi/lossless-cut
cd lossless-cut
git checkout abacff91a40e83002a7560cab481e372386141b3

In lossless-cut/src/smartcut.js
changed:
videoBitrate = Math.floor(videoBitrate * 1.2)
to:
videoBitrate = Math.floor(videoBitrate * 20)

yarn install
yarn build
yarn download-ffmpeg-linux-x64
yarn run
yarn start

The program starts slowly in this mode, I encountered a packaging problem.
Now everything is fine, bitrate is normal.

I had two video files:

  1. WebM VP9 from YouTube.
  2. MKV H.264 encoded by me with crf 18.

On both of them only multiplier 20 is good.
See how to build on the github server here.

@artenax
Copy link
Author

artenax commented Nov 15, 2023

I don't know how to use GitHub Actions, never tried it.
For packaging I have to create resources/app.asar it seems using the asar utility. I don't know exactly how.

@mifi
Copy link
Owner

mifi commented Nov 15, 2023

Can you share info about your file? Multiplier 20 seems quite extreme. I wonder why such a multiplier is necesaary

@mifi
Copy link
Owner

mifi commented Nov 15, 2023

Do your files by any chance have bit rate «N/A» for the video track?

@mifi
Copy link
Owner

mifi commented Nov 15, 2023

I think there’s a bug in the code that estimates bitrate when bit_rate is N/A. It estimates bit rate from size/duration, but that is bytes/sec, ffmpeg -b expects bits, so we need to multiply by 8 here:

videoBitrate = stats.size / videoDuration;

this also explains your high multiplier and also some people who complained about low quality some times

@mifi mifi closed this as completed in 3b823a2 Nov 15, 2023
@mifi
Copy link
Owner

mifi commented Nov 15, 2023

you can try new nightly build tomorrow if you like

@artenax
Copy link
Author

artenax commented Nov 15, 2023

Can you share info about your file?

The file is regular, downloaded from YouTube https://www.youtube.com/watch?v=RtFocW6gi5c with yt-dlp, streams 247+251, mux in ffmpeg 6.0. WebM (VP9 720p + Opus). I don't have much traffic left, please download it yourself.

General
Format                                   : WebM
Format version                           : Version 4
File size                                : 182 MiB
Duration                                 : 28 min 40 s
Overall bit rate                         : 889 kb/s
Writing application                      : Lavf60.3.100
Writing library                          : Lavf60.3.100

Video
ID                                       : 1
Format                                   : VP9
Codec ID                                 : V_VP9
Duration                                 : 28 min 40 s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Language                                 : English
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : Opus
Codec ID                                 : A_OPUS
Duration                                 : 28 min 40 s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Bit depth                                : 32 bits
Compression mode                         : Lossy
Language                                 : English
Default                                  : Yes
Forced                                   : No

Do your files by any chance have bit rate «N/A» for the video track?

How can I check this?
The MediaInfo utility does not really show either the video bitrate or the audio bitrate. Only the total. Since everywhere is VBR, and info tags ffmpeg does not insert (in webm/mkv). However, even repackaging in MKVToolnix didn't help. MKVToolnix inserted info tags (track statistic tags) and MediaInfo utility showed bitrate (video, audio, total), but only MediaInfo.

I think there’s a bug in the code that estimates bitrate when bit_rate is N/A. It estimates bit rate from size/duration, but that is bytes/sec, ffmpeg -b expects bits, so we need to multiply by 8 here

LosslessCut selects a bitrate 3 times lower. I checked.
More precisely, such bitrate is obtained in files after LosslessCut (in the transcoded area). I haven't looked at the exact command line. Since encoders may not always respect the specified bitrate.

you can try new nightly build tomorrow if you like

I could try. But I also like to choose the bitrate myself in my build.

@artenax
Copy link
Author

artenax commented Nov 15, 2023

I tried the nightly build. It's much better now. The bitrate is higher by a factor of x1.07 ... x1.37. This was clearly a bit/byte problem, which you fixed. Thanks.
lossless-cut
I'd like the bitrate even higher, of course. Because I'm still seeing some artifacts.
YouTube uses VP9 more efficiently, probably with a hardware encoder.

@artenax
Copy link
Author

artenax commented Nov 15, 2023

The nightly builds have an expiration date and require a github account, so I've re-uploaded them. They may be useful for those who don't have a github account.

@mifi
Copy link
Owner

mifi commented Nov 17, 2023

cool. note that nightly builds will eventually turn into an actual release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants