Skip to content

Commit

Permalink
fix seek relative -5s,-10s;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Sep 1, 2023
1 parent 92a8fec commit 5d58002
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
2. 在WidgetRender中,尽可能使用QImage::Format_RGB32和QImage::Format_ARGB32_Premultiplied图像格式。如下原因:
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.

### ``avformat_seek_file``,当seek的时间点小于当前时间点一些时,比如-5秒、-10秒,seek不到目标时间点

#### 有一种解决方法是:先``seek``到0秒,再``seek``到目标时间点。
这个时候-5秒、-10秒的seek,效果非常好,比之前好很多,之前有时候会卡在当前时间点,无法seek到目标时间点。

```C++
formatCtx->seek(0);
formatCtx->seek(position);
```
### Ffmpeg(5.0)在解码字幕与4.4.3不太一样
### 解码字幕(ffmpeg-n5.0):
Expand Down
1 change: 0 additions & 1 deletion examples/player/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class MainWindow::MainWindowPrivate
playerPtr->addEvent(eventPtr);
});
new QShortcut(QKeySequence::MoveToPreviousChar, q_ptr, q_ptr, [this] {
// Todo : seek 不准确
Ffmpeg::EventPtr eventPtr(new Ffmpeg::SeekRelativeEvent(-5));
playerPtr->addEvent(eventPtr);
});
Expand Down
4 changes: 3 additions & 1 deletion ffmpeg/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ class Player::PlayerPrivate
subtitleDecoder->addEvent(eventPtr);
auto position = seekEvent->position();
seekEvent->wait();

// before add this line, seek position less than current position, it wiil not accurate,
// and now first seek to 0, then seek to position, it will be very good
formatCtx->seek(0);
formatCtx->seek(position);
if (audioInfo->isIndexVaild()) {
audioInfo->codecCtx()->flush();
Expand Down

0 comments on commit 5d58002

Please sign in to comment.