Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cudawarped
Copy link
Contributor

@cudawarped cudawarped commented Jul 5, 2024

Fix #25873 by modifying cv::VideoWriter to use provided presentation indices (pts).

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@cudawarped cudawarped force-pushed the videoio_ffmpeg_fix_encapsulate_ts branch from ad6229c to 63f47fd Compare July 5, 2024 11:01
@asmorkalov asmorkalov self-requested a review July 5, 2024 11:46
@asmorkalov asmorkalov added this to the 4.11.0 milestone Jul 5, 2024
@cudawarped cudawarped force-pushed the videoio_ffmpeg_fix_encapsulate_ts branch from 63f47fd to 98eaf49 Compare July 5, 2024 13:18
@cudawarped
Copy link
Contributor Author

Updated to address warnings

/home/ci/opencv/modules/videoio/test/test_ffmpeg.cpp:335:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]

/home/ci/opencv/modules/videoio/test/test_ffmpeg.cpp:352:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]

/home/ci/opencv/modules/videoio/test/test_ffmpeg.cpp:387:16: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]

@cudawarped cudawarped force-pushed the videoio_ffmpeg_fix_encapsulate_ts branch from 1ff05be to ecef325 Compare July 11, 2024 08:18
@asmorkalov
Copy link
Contributor

Linux warning:

Run cd $HOME/build && python3 $HOME/scripts/warnings-handling.py
/home/ci/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1873:9: warning: this statement may fall through [-Wimplicit-fallthrough=]

@asmorkalov asmorkalov self-assigned this Jul 11, 2024
@cudawarped cudawarped force-pushed the videoio_ffmpeg_fix_encapsulate_ts branch from ecef325 to eafbf4b Compare July 11, 2024 12:21
@cudawarped
Copy link
Contributor Author

Linux warning:

Run cd $HOME/build && python3 $HOME/scripts/warnings-handling.py
/home/ci/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:1873:9: warning: this statement may fall through [-Wimplicit-fallthrough=]

I've pushed an update which should address this.

@asmorkalov
Copy link
Contributor

@opencv-alalek @mshabunin could you take a look too?

@asmorkalov
Copy link
Contributor

Reporduced failed test with Ubuntu 16.04 locally. Will take a look, if we can handle this:

ubuntu@jetson1:~/Projects/opencv-build$ ./bin/opencv_test_videoio --gtest_filter=videoio_encapsulate.write/16
CTEST_FULL_OUTPUT
OpenCV version: 4.10.0-dev
OpenCV VCS version: 4.10.0-98-geafbf4b-dirty
Build type: Release
Compiler: /usr/bin/c++  (ver 5.4.0)
Parallel framework: pthreads (nthreads=1)
CPU features: NEON
OpenCL is disabled
TEST: Skip tests with tags: 'mem_2gb', 'verylong'
Note: Google Test filter = videoio_encapsulate.write/16
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from videoio_encapsulate
[ RUN      ] videoio_encapsulate.write/16, where GetParam() = ("video/sample_322x242_15frames.yuv420p.libx264.mp4", "mp4", 15, 15, true, true)
OpenCV: FFMPEG: tag 0x34363268/'h264' is not supported with codec id 28 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x00000021/'!???'
Checking encapsulated video container: /tmp/__opencv_temp.OzpE2c.test_encapsulated_stream.mp4
[NULL @ 0x17c550] Packet header is not contained in global extradata, corrupted stream or invalid MP4/AVCC bitstream
/home/ubuntu/Projects/opencv/modules/videoio/test/test_ffmpeg.cpp:380: Failure
Value of: capActualRaw.grab()
  Actual: false
Expected: true
[  FAILED  ] videoio_encapsulate.write/16, where GetParam() = ("video/sample_322x242_15frames.yuv420p.libx264.mp4", "mp4", 15, 15, true, true) (77 ms)
[----------] 1 test from videoio_encapsulate (78 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (80 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] videoio_encapsulate.write/16, where GetParam() = ("video/sample_322x242_15frames.yuv420p.libx264.mp4", "mp4", 15, 15, true, true)

@asmorkalov
Copy link
Contributor

Looks similar to what we discussed in #24363.

@cudawarped cudawarped force-pushed the videoio_ffmpeg_fix_encapsulate_ts branch from eafbf4b to 3baf2ec Compare July 22, 2024 09:45
@cudawarped
Copy link
Contributor Author

Looks similar to what we discussed in #24363.

Its the same issue but unfortunately can't be fixed by using a .avi container because the pts infomation is not available. Changing to .ts works for me with FFMpeg 2.8.22 (Ubuntu 16.04) and 4.2.9 (Ubuntu 20.04)

@asmorkalov asmorkalov merged commit c9b5781 into opencv:4.x Jul 22, 2024
@asmorkalov asmorkalov mentioned this pull request Jul 25, 2024
fengyuentau pushed a commit to fengyuentau/opencv that referenced this pull request Aug 15, 2024
…capsulate_ts

videoio: fix cv::VideoWriter with FFmpeg encapsulation timestamps opencv#25874

Fix opencv#25873 by modifying `cv::VideoWriter` to use provided presentation indices (pts).

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
thewoz pushed a commit to CobbsLab/OPENCV that referenced this pull request Feb 13, 2025
…capsulate_ts

videoio: fix cv::VideoWriter with FFmpeg encapsulation timestamps opencv#25874

Fix opencv#25873 by modifying `cv::VideoWriter` to use provided presentation indices (pts).

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

videoio: Incorrect pts in encapsulated video which uses B-frames

3 participants