Skip to content

Commit

Permalink
docs: Added README."en".md translation via https://github.com/dephrai…
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 16, 2023
1 parent 8822623 commit e7e7bbd
Showing 1 changed file with 90 additions and 25 deletions.
115 changes: 90 additions & 25 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,121 @@

<div align=center><img src="doc/player.jpeg"></div>

### Need a powerful opengl and vulkan yuv rendering module!
### Requires a powerful opengl and vulkan yuv rendering module

1. There are too many if else in the shader in Opengl, causing the GPU to run empty, affecting GPU decoding and av_hwframe_transfer_data speed, this phenomenon is especially obvious on 4K video images;
2. In WidgetRender, use QImage::Format_RGB32 and QImage::Format_ARGB32_Premultiplied image formats as much as possible. The following reasons:
1. Opengl's fragment shader currently supports limited image formats;
2. In WidgetRender, use the QImage::Format_RGB32 and QImage::Format_ARGB32_Premultiplied image formats whenever possible. The following reasons:
1. Avoid most rendering directly to most of these formats using QPainter. Rendering is best optimized to the Format_RGB32 and Format_ARGB32_Premultiplied formats, and secondarily for rendering to the Format_RGB16, Format_RGBX8888, Format_RGBA8888_Premultiplied, Format_RGBX64 and Format_RGBA64_Premultiplied formats.

### Ffmpeg (5.0) is not the same as 4.4.3 in decoding subtitles
### How to adjust image based on AVColorTransferCharacteristic?

### Decoding subtitles (ffmpeg-n5.0):
#### 1. How to modify the shader when rendering with opengl?

0,,en,,0000,0000,0000,,Peek-a-boo!
#### 2. In the case of non-opengl rendering, how to add a filter to achieve image compensation?

you must use`ass_process_chunk`And set pts and duration as in libavfilter/vf_subtitles.c.
1. reference[MPV video_shaders](https://github.com/mpv-player/mpv/blob/master/video/out/gpu/video_shaders.c#L341), the effect is not very good; there should be something missing.

ASS standard format should be (ffmpeg-n4.4.3):
2. MPV shader generation method:

Dialogue: 0,0:01:06.77,0:01:08.00,en,,0000,0000,0000,,Peek-a-boo!\r\n
1. according to`AVColorTransferCharacteristic`Adjust gamma, PQ or HLG, etc., OETF;

```cpp
void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc);
```

```glsl
color.rgb = clamp(color.rgb, 0.0, 1.0);
color.rgb = pow(color.rgb, vec3(1.0 / PQ_M2));
color.rgb = max(color.rgb - vec3(PQ_C1), vec3(0.0)) / (vec3(PQ_C2) - vec3(PQ_C3) * color.rgb);
color.rgb = pow(color.rgb, vec3(1.0 / PQ_M1));
```

2. Tone mapping; tone mapping;

```cpp
static void pass_tone_map(struct gl_shader_cache *sc,
float src_peak, float dst_peak,
const struct gl_tone_map_opts*opts);
```

3. according to`AVColorTransferCharacteristic`Adjust gamma, PQ or HLG, etc., EOTF;

```cpp
void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc);
```

```glsl
color.rgb = clamp(color.rgb, 0.0, 1.0);
color.rgb = pow(color.rgb, vec3(PQ_M1));
color.rgb = (vec3(PQ_C1) + vec3(PQ_C2) * color.rgb) / (vec3(1.0) + vec3(PQ_C3) * color.rgb);
color.rgb = pow(color.rgb, vec3(PQ_M2));
```

3. MPV generates the coefficients of yuv -> RGB conversion matrix;

```cpp
void mp_get_csp_matrix(struct mp_csp_params *params, struct mp_cmat *m);
```

4. HDR metadata acquisition

```cpp
AVFrameSideData *mdm = av_frame_get_side_data(src, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
AVFrameSideData *clm = av_frame_get_side_data(src, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
AVFrameSideData *dhp = av_frame_get_side_data(src, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
pl_map_hdr_metadata(&dst->params.color.hdr, &(struct pl_av_hdr_metadata) {
.mdm = (void *)(mdm ? mdm->data : NULL),
.clm = (void *)(clm ? clm->data : NULL),
.dhp = (void *)(dhp ? dhp->data : NULL),
});
```

### How to achieve image quality enhancement when rendering images with OpenGL?

### Ffmpeg (5.0) decodes subtitles differently from 4.4.3

#### Decode subtitles (ffmpeg-n5.0)

```bash
0,,en,,0000,0000,0000,,Peek-a-boo!
```

you have to use`ass_process_chunk`and set pts and duration as in libavfilter/vf_subtitles.c.

#### The ASS standard format should be (ffmpeg-n4.4.3)

```bash
Dialogue: 0,0:01:06.77,0:01:08.00,en,,0000,0000,0000,,Peek-a-boo!\r\n
```

use`ass_process_data`;

### Issue with subtitle display timing when using subtitle filter

subtitles=filename='%1':original_size=%2x%3
```bash
subtitles=filename='%1':original_size=%2x%3
```

## QFfmpegTranscoder

How to set encoding parameters to get smaller files and better video quality?

1. set a very high bitrate;
2. set encoder`global_quality`invalid. code show as below:
1. Set a very high bitrate;

2. Set up the encoder`global_quality`invalid. code show as below:

```C++
d_ptr->codecCtx->flags |= AV_CODEC_FLAG_QSCALE;
d_ptr->codecCtx->global_quality = FF_QP2LAMBDA * quailty;
```

3. set up`crf`invalid. code show as below:

```C++
av_opt_set_int(d_ptr->codecCtx, "crf", crf, AV_OPT_SEARCH_CHILDREN);
```

### How to calculate pts from frames acquired by AVAudioFifo?
### How to calculate pts from frames obtained by AVAudioFifo?

```C++
// fix me?
Expand All @@ -57,23 +130,15 @@ frame->pts = transcodeCtx->audioPts / av_q2d(transcodeCtx->decContextInfoPtr->ti
transcodeCtx->audioPts += frame->nb_samples;
```

### [New BING's Video Transcoding Recommendations](./doc/bing_transcode.md)
### [New BING的视频转码建议](./doc/bing_transcode.md)

## SwsContext is great! Compared to QImage converted to and scaled.
## SwsContext is great! Compared to QImage convert to and scale

## QT-BUG

### Failed to set up resampler

[it's a bug in Qt 6.4.1 on Windows](https://forum.qt.io/topic/140523/qt-6-x-error-message-qt-multimedia-audiooutput-failed-to-setup-resampler)<https://bugreports.qt.io/browse/QTBUG-108383>(johnco3's bug report)<https://bugreports.qt.io/browse/QTBUG-108669>(a duplicate bug report; I filed it before I found any of this)

#### solution:

<https://stackoverflow.com/questions/74500509/failed-to-setup-resampler-when-starting-qaudiosink>

#### Dynamically switch Video Render, switch from opengl to widget, there is still GPU 0-3D occupation, and the usage is twice that of opengl! ! ! QT-BUG?
#### Dynamically switching Video Render, switching from opengl to widget, still consumes GPU 0-3D, and the usage is twice that of opengl! ! ! QT-BUG?

### QOpenGLWidget memory leak, moving zoom in and out of the window, the code is as follows:
### QOpenGLWidget memory leaks, moves to zoom in and out the window, the code is as follows

```C++
int main(int argc, char *argv[])
Expand Down

0 comments on commit e7e7bbd

Please sign in to comment.