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

Native support for codecs/formats (TS,H265,mpeg2++) #88

Closed
mifi opened this issue Sep 9, 2018 · 63 comments · Fixed by #1844
Closed

Native support for codecs/formats (TS,H265,mpeg2++) #88

mifi opened this issue Sep 9, 2018 · 63 comments · Fixed by #1844

Comments

@mifi
Copy link
Owner

mifi commented Sep 9, 2018

Due to losslesscut using chromium's html5 video tag which only supports certain container formats and codecs, we currently need to "convert to supported format" when trying to open exotic formats or codecs. This could be improved with the help of ffmpeg.

Workarounds

Compile custom electron

Convert to supported format

Currently it's possible to cut those files by first using the File -> Convert to supported format (slow) function, however this is a re-encoding (although fast) of the whole file, just to be able to view it in the HTML5 video player (note that the original and cut versions will not be re-encoded and are still lossless.)

Improve current proxy/dummy code

Currently a <canvas> element is used, and ffmpeg will stream low-resolution jpeg images to that canvas.

Drawbacks:

  • Slow, laggy, low resolution, low fps
  • No audio

This could be improved:

Related

Electron (Chromium) might never support h265

It seems like Chrome and most other browsers are not going to be supporting H265 as it stands now, and since we are using Chromium (Electron), this will be a problem.
It might be possible to enable a flag to enable H265 decoding, but it requires some modding of electron.

Update: Chromium now supports h265 (hardware decoding only)

@mifi mifi changed the title Support for H265 Native support for H265 Sep 11, 2018
@killaz47
Copy link

killaz47 commented May 5, 2019

Now that more and more cameras (including DJI Mavic 2) are starting to support H265, it would be nice to have support for this here as well.
Currently it's possible to cut those files by first using the File -> Convert to friendly format (slow) function, however this is a re-encoding (although fast) of the whole file, just to be able to view it in the HTML5 video player (note that the original and cut versions will not be re-encoded and are still lossless.)

It seems like Chrome and other browsers are not going to be supporting H265 as it stands now, and since we are using Chromium (Electron), this will be a problem.
It might be possible to enable a flag to enable H265 decoding, but it requires some modding of electron.

If anyone has some bright ideas, shout out!

heres the solution from the chrnoium developers
https://github.com/henrypp/chromium/blob/master/hevc_support.md
https://github.com/henrypp/chromium/blob/master/hevc_support_new.md

@mifi mifi mentioned this issue May 6, 2019
@mifi
Copy link
Owner Author

mifi commented May 6, 2019

I'm not sure how to do this with electron. (LosslessCut uses Electron which uses Chromium.) Feel free to open an issue at electron to see if this can be integrated. I think it is not a trivial task, so I don't have time to look at this now.

@TechManiacHD
Copy link

Lately I swap my gear and see, that recording in HEVC format gives me better quality over H264 even with lower bitrate. I would love to switch to HEVC for all my projects although only Lossless Cut stops me from doing that - https://i.imgur.com/avu5AQE.png (after converting to friendly format).

Is there a chance this will work at some point or should I still sit on old format? Thanks.

@esamattis
Copy link

I'm seeing that too with GoPro 7 HEVC videos and fast convert. The slow one works.

@TechManiacHD
Copy link

You're right! It works with slow one (That quality xD). Enough for cutting no worries :)
Thanks, that will do for time being.

@mifi
Copy link
Owner Author

mifi commented Aug 12, 2019

Great! the reason for the low quality is to make it as fast as remotely possible, and only to be used as a preview.

@antonioriva
Copy link

As LossLess-cut is build in electron do you ever considered to use mpv as player component? I've just found that a project to do that it's already there... https://github.com/Kagami/mpv.js/ with also some samples implementation

@mifi
Copy link
Owner Author

mifi commented Sep 1, 2019

Thanks for the tip! I didn't know about mpv.js, but if it's easy to integrate then that's definitely an option.
Kagami/mpv.js#27

@mifi
Copy link
Owner Author

mifi commented Nov 4, 2019

In 1.5.0 I have implemented a hack that lets us cut H265 videos, but scrubbing and playing only works at a very low fps and currently without audio.

@ThexXTURBOXx
Copy link

grafik
Getting this error when trying to merge 2 H.265 videos together. Is there something I can do about this?

@mifi mifi changed the title Native support for H265 Native support for for formats (H265++) Feb 16, 2020
@peterhighgrove
Copy link

peterhighgrove commented Mar 26, 2020

Is it possible to add support for grabbing a frame at 4k/hevc to jpg even though the preview is not native?

mifi added a commit that referenced this issue Mar 28, 2020
@mifi
Copy link
Owner Author

mifi commented Mar 28, 2020

Is it possible to add support for grabbing a frame at 4k/hevc to jpg even though the preview is not native?

I have implemented this now

@peterhighgrove
Copy link

Nice, thanks! Can't wait to test it in the next release!

@mifi
Copy link
Owner Author

mifi commented Mar 29, 2020

Check out newest version now

@peterhighgrove
Copy link

Thanks, tested 3.17.9. It's working great:)

@ThexXTURBOXx
Copy link

@mifi Is there any news on supporting H265 natively?

@mifi
Copy link
Owner Author

mifi commented Mar 30, 2020

No. I think it needs a lot of work because have to compile a custom electron with a custom chromium that uses a custom ffmpeg. Not something i will prioritize unless this work gets funded somehow, or if we can find the work of someone else who did this already.

@dpallen
Copy link

dpallen commented Dec 18, 2022

Thanks for the quick reply, but I resolved my issue after some more testing. My footage used 4:4:4 chroma subsampling. Using 4:2:0 HEVC footage works perfectly in llc 3.48.2 beta.

@mifi
Copy link
Owner Author

mifi commented Dec 23, 2022

So to summarize, in order to detect if the player/device supports a file, (for example HEVC) we need to:

const mediaConfig = {
  type: 'file',
  video: {
    contentType : 'video/mp4;codecs="hev1.1.6.L120.90"',
    width: 1920,
    height: 1080,
    bitrate: 10000, 
    framerate: 30,
  }
}

const { supported } = await navigator.mediaCapabilities.decodingInfo(mediaConfig);
// result.supported indicates whether or not the video with given profile, width, and height can played well on the browser

The problem is to find the contentType parameter. It is described here: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter but it varies by format/codec. Need to find a library where someone implemented this logic into a library for all formats/codecs. I would think that the output from ffprobe could be transformed into this codec parameter.

Potential implementations for each format/codec:

See also

@ThaUnknown
Copy link

ThaUnknown commented Dec 23, 2022

hate to bear the bad news, but that decoder implementation is incorrect, long story short? the color-space decoding is fucked,
I went into detail here: Alex313031/thorium#70

I probably still recomment uzing StaZhu's or Muril-o patches, as they both seem to do color-space conversion correctly, I'll see about merging StaZhu's patches into Muril-o's as they additionally support more codecs, not just HEVC

@mifi
Copy link
Owner Author

mifi commented Dec 24, 2022

Not sure why that's a problem. the hevc decoder is only used for previewing. When exporting, the decoder will not be used

@Spaarpott
Copy link

@mifi

Not sure why that's a problem. the hevc decoder is only used for previewing. When exporting, the decoder will not be used

And when you save a frame as .jpeg?

@mifi
Copy link
Owner Author

mifi commented Dec 25, 2022

That’s a point. We could have a setting for whether to use <video> tag or ffmpeg to capture frame.

@Spaarpott
Copy link

I'm not a programmer, so I wouldn't know. As long as the image colors are correct in a export whether it is a .jpeg or a movie file.

@mifi
Copy link
Owner Author

mifi commented Dec 31, 2022

I'm not sure how to detect if the player shows black screen. Could someone who sees a black screen with a HEVC file, please try to

  1. press "play",
  2. check Developer Tools log and look for the warning line onVideoError
  3. copy paste this whole line here?

mifi added a commit that referenced this issue Jan 5, 2023
mifi added a commit that referenced this issue Jan 6, 2023
- allow setting capture frame method #88 (comment)
- allow changing quality #1141 #371
@mifi
Copy link
Owner Author

mifi commented Jan 6, 2023

next version will allow choosing ffmpeg or video-tag for capturing frame, as well as captured image quality

@mifi
Copy link
Owner Author

mifi commented Jan 15, 2023

next version will allow disabling the hevc support (for people who have problem with blank screen)
it will also include a basic check for hevc support

mifi added a commit that referenced this issue Jan 15, 2023
@Fred-Vatin
Copy link

Fred-Vatin commented Apr 3, 2023

In my case, my hardware can not read H265. So if the support option is enabled, I have sound but blank screen. But if I disable the option, I have image but no sound.

I have no problem to read H265 in other players.

@mifi mifi changed the title Native support for formats (H265,mpeg2++) Native support for codecs/formats (H265,mpeg2++) Apr 25, 2023
@mifi mifi changed the title Native support for codecs/formats (H265,mpeg2++) Native support for codecs/formats (TS,H265,mpeg2++) Apr 25, 2023
@Delphox
Copy link

Delphox commented Jun 30, 2023

I'm having a strange issue with HEVC. My graphics chip support decoding it, and most HEVC videos play fine on LosslessCut, however videos specifically recorded from OBS then converted into HEVC with ffmpeg (either with libx265 or hevc_amf) into an mp4 container will turn into a black screen on LosslessCut. They play fine everywhere else including chrome.

I've attached a problematic mp4 file so you can play around with it:

2023-06-30.18-30-01_hevc.mp4

A workaround for now is converting to HEVC into an mkv container instead then remuxing into an mp4, or if I already have a problematic mp4, remux into mkv then back into mp4.

@mifi
Copy link
Owner Author

mifi commented Jul 2, 2023

hmm, this video doesn't play in chrome for me. audio only

@Spaarpott
Copy link

@mifi In my chrome version the file of Delphox plays fine. Chrome version: 114.0.5735.199
However, i don't hear any audio, nor in Chrome, nor in VLC, but it has a audio track.
It shows indeed a black screen in LosslessCut v3.54.
When I multiplex the file to MKV with mkvtoolnix, it opens in LosslessCut fine.

Screenshot of Chrome:
image

@Delphox
Copy link

Delphox commented Jul 2, 2023

It has an empty audio track yea, as I recorded it in OBS with no audio playing (the sample video had no audio track at all). Removing the audio track makes it play on LosslessCut, which is strange, and why I left the audio track on.

@mifi
Copy link
Owner Author

mifi commented Jul 2, 2023

Ok I just upgraded my chrome from 111 to 114 and now I can also play the video. So it seems like it was a bug in chrome(chromium). Some time in the future once we upgrade electron to the latest version in LosslessCut, the video will probably just start working in losslesscut too.

@mifi
Copy link
Owner Author

mifi commented Jan 4, 2024

coming up in a pr #1844 an improved playback of unsupported files, using the MediaSource API. this allows playback of virtually all formats/codecs with audio as well

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

Successfully merging a pull request may close this issue.