lossless-cut
lossless-cut copied to clipboard
Native support for codecs/formats (TS,H265,mpeg2++)
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
- https://github.com/electron/build-tools
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:
- MediaSource API & https://www.electronjs.org/docs/latest/tutorial/message-ports
- Web Audio API: https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
- https://github.com/strukturag/libde265.js
- https://stackoverflow.com/questions/55376781/seeking-with-ffmpeg-at-the-end-of-an-rtsp-stream
- https://stackoverflow.com/questions/61672575/rtsp-to-webrtc-live-video-streaming
- https://stackoverflow.com/questions/41965793/rtsp-h-264-in-google-chrome-browser
- https://github.com/Streampunk/beamcoder
- https://github.com/GleasonK/WebRTC-YouTubeTogether
Related
- https://github.com/webtorrent/webtorrent-desktop/issues/561
- https://github.com/webtorrent/webtorrent-desktop/issues/1389
~~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.
- https://stackoverflow.com/questions/36382568/h-265-hevc-web-browser-support
- https://github.com/electron/libchromiumcontent/issues/198
Update: Chromium now supports h265 (hardware decoding only)
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
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!
- https://stackoverflow.com/questions/36382568/h-265-hevc-web-browser-support
- webtorrent/webtorrent-desktop#561
- electron/libchromiumcontent#198
- https://github.com/strukturag/libde265.js
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
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.
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.
I'm seeing that too with GoPro 7 HEVC videos and fast convert. The slow one works.
You're right! It works with slow one (That quality xD). Enough for cutting no worries :) Thanks, that will do for time being.
Great! the reason for the low quality is to make it as fast as remotely possible, and only to be used as a preview.
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
Thanks for the tip! I didn't know about mpv.js, but if it's easy to integrate then that's definitely an option. https://github.com/Kagami/mpv.js/issues/27
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.
Getting this error when trying to merge 2 H.265 videos together. Is there something I can do about this?
Is it possible to add support for grabbing a frame at 4k/hevc to jpg even though the preview is not native?
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
Nice, thanks! Can't wait to test it in the next release!
Check out newest version now
Thanks, tested 3.17.9. It's working great:)
@mifi Is there any news on supporting H265 natively?
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.
This is still a problem in the current build and I was wondering if progress is being made on it as video standards move forward
AFAIK chromium/electron still doesn't support H265 and they refuse to support it due to expensive licensing: https://bugs.chromium.org/p/chromium/issues/detail?id=684382 So we still need to build a custom electron with a custom chromium to get this native support
I came across this guide "it’s not as difficult as it might sound" Electron with custom Chromium build
and then the instructions for HEVC support in chromium
Also noticed this gem from the chromium forums that is currently being implemented Issue 1286132: Implement HEVC for video playback and video conferencing on Windows
Any updates on native HEVC implementation? The solution of making a dummy proxy is pretty brilliant, but it would be nice to see my videos in full res.
@gmcmicken nice finds. I've not taken on the task of building a custom chromium. However I do have an idea with the https://developer.mozilla.org/en-US/docs/Web/API/MediaSource to hopefully allow for more smooth streaming from ffmpeg to the player. It may also allow playing audio. Note that it still needs to encode the video while playing but I think h264 encoding can be done very fast these days. Could also set the duration which would remove the need for the html5ified dummy file.
There seems to be some good news: Sida Zhu has implemented support for hw decoding for HEVC in chromium v104.0.5084.0, disabled by default and enabled with the PlatformHEVCDecoderSupport feature. (https://github.com/StaZhu/enable-chromium-hevc-hardware-decoding) . chromium 104 needs electron nighty build 21 (https://github.com/electron/releases) . Mikael, could you build losslesscut updated to this electron version and with feature enabled? Thanks a lot!
that's fantastic! Then I think once electron 20 becomes stable we can upgrade to that. Note that upgrading losslesscut to newest electron is quite a big job. But I plan on doing it soon, now that electron>v8 slowness on macos has been fixed #714
You are right, also latest electron 20 beta has chromium 104, with the 8-weeks release cycle we should hopefully have a stable 20 soon. I understand that going from electon 8 to 20 could be a big jump, I'll donate for your effort. Thanks.
Hi Mikael, do you have some progress on this improvement?
Hi. Unfortunately not, as ive been very busy with other projects. But, assuming electron now supports natively, it will be solved once Llc upgrades electron, which is one of the first next big tasks
Hi. Unfortunately not, as ive been very busy with other projects. But, assuming electron now supports natively, it will be solved once Llc upgrades electron, which is one of the first next big tasks
I will definitely buy the app store version to subsidise a couple of cups of coffee for your effort ;)
I'm testing with Electron v21 now and with app.commandLine.appendSwitch('enable-features','PlatformHEVCDecoderSupport')
h265 seems to be working! so expect an alpha release of losslesscut soon