Skip to content

Add FFmpeg support to open video files - #30

Merged
yongtang merged 19 commits into
tensorflow:masterfrom
yongtang:ffmpeg
Jan 13, 2019
Merged

Add FFmpeg support to open video files#30
yongtang merged 19 commits into
tensorflow:masterfrom
yongtang:ffmpeg

Conversation

@yongtang

@yongtangyongtang commented Dec 16, 2018

Copy link
Copy Markdown
Member

This fix adds a preliminary video file support (VideoDataset) by linking and using FFmpeg's libraries.

The video.VideoDataset takes input of filename list, and generates outputs of RGB24 images (uint8) in (height, width, 3).

The reason to link against FFmpeg's libraries is because FFmpeg has a LGPL 2.1+ license.

On Ubuntu 18.04, FFmpeg libraries consists of:

  • libavformat.so.57
  • libavcodec.so.57
  • libavutil.so.55
  • libswscale.so.4

Because FFmpeg only guarantee's major version conpatibility, linking to a lower version (e.g., libavformat.so.54 on Ubuntu 14.04) may not work.

To support multiple versions of Ubuntu, multiple copies of header file combined with linking to different versions of .so might be needed.

It needs to be fully tested though and only limited major version should be supported.

At the moment, only ffmpeg libraries in Ubuntu 18.04 are used.
UPDATE:
At the moment, Ubuntu 14.04, 16.04, and 18.04 are all supported. We build 3 .so files and distributed at the same time:

  • _video_ops_ffmpeg_3.4.so (Ubuntu 18.04)
  • _video_ops_ffmpeg_2.8.so (Ubuntu 16.04)
  • _video_ops_libav_9.20.so (Ubuntu 14.04)

Additional platform could be added if there is enough need from the community.

To install required libraries on Ubuntu 18.04:

apt-get -y -qq install libavformat57 libavcodec57 libavutil55 libswscale4

To build the pip package:

bazel build -s --verbose_failures build_pip_pkg

NOTE: This PR fixed#11

Signed-off-by: Yong Tang yong.tang.github@outlook.com

@yongtang
yongtangforce-pushed the ffmpeg branch 2 times, most recently from 7c8fc9c to 66df035CompareDecember 17, 2018 01:04
@googlebot

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

# License for the specific language governing permissions and limitations under
# the License.
# ==============================================================================
"""Tests for SequenceFileDataset."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to VideoDataset instead of SequenceFileDataset? Same for other places

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @terrytangyuan, the PR has been updated.

@yongtang
yongtangforce-pushed the ffmpeg branch 11 times, most recently from 272d247 to abadf38CompareDecember 18, 2018 14:14
@yongtangyongtang changed the title [WIP] Add FFmpeg support to open video filesAdd FFmpeg support to open video filesDec 18, 2018
@yongtang

Copy link
Copy Markdown
MemberAuthor

I think this PR is almost ready. I am working on adding Ubuntu 16.04 and 14.04 support (on top of 18.04 support that is already in place). Will update the PR shortly to completion.

@yongtang
yongtangforce-pushed the ffmpeg branch 2 times, most recently from a6c0ae3 to a928008CompareDecember 18, 2018 23:10
@yongtang

Copy link
Copy Markdown
MemberAuthor

I think this PR is ready. We support Ubuntu 14.04, 16.04, and 18.04 at the moment, with one distributed package in pip. Tests also pass on those platforms.

@martinwicke

Copy link
Copy Markdown
Member

This is a thing of beauty. I especially appreciate the multi-version tooling.

Since these are LGPL, we have to make sure to only release dynamically linked versions. Can we make sure (with a test/scripting) that this is always going ot be the case?

@yongtang

Copy link
Copy Markdown
MemberAuthor

@martinwicke The library only uses header files from ffmpeg to compile and build. In Bazel there is a check-license option though I don't know how reliable it is. I think some additional tooling might be possible (maybe a module in bazel) to enforce only header files are included for LGPL types of libraries .

I will take a look at the license tooling issue.

@martinwicke

Copy link
Copy Markdown
Member

I think as long as we make sure all releases are built with dynamic linking, we should be ok.

This fix adds a preliminary video file support (`VideoDataset`)
by linking and using FFmpeg's libraries.
The `video.VideoDataset` takes input of filename list, and
generates outputs of RGB24 images (`uint8`) in `(height, width, 3)`.
The reason to link against FFmpeg's libraries is because
FFmpeg has a LGPL 2.1+ license.
On Ubuntu 18.04, FFmpeg libraries consists of:
```
libavformat.so.57
libavcodec.so.57
libavutil.so.55
libswscale.so.4
```
Because FFmpeg only guarantee's major version conpatibility,
linking to a lower version (e.g., libavformat.so.54 on Ubuntu 14.04)
may not work.
To support multiple versions of Ubuntu, multiple copies of header file
combined with linking to different versions of .so might be needed.
It needs to be fully tested though and only limited major version should
be supported.
At the moment, only ffmpeg libraries in Ubuntu 18.04 are used.
To install required libraries on Ubuntu 18.04:
```
apt-get -y -qq install libavformat57 libavcodec57 libavutil55 libswscale4
```
To build the pip package:
```
bazel build -s --verbose_failures build_pip_pkg
```
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
So that build could always succeed. In runtime system .so files will be used.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…ave Ubuntu 18.04 support directly.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Encountered quite some issues with
```
Use --sandbox_debug to see verbose messages from the sandbox
/usr/bin/ld.gold: error: cannot find libavformat.so.57
/usr/bin/ld.gold: error: cannot find libavcodec.so.57
/usr/bin/ld.gold: error: cannot find libavutil.so.55
/usr/bin/ld.gold: error: cannot find libswscale.so.4
collect2: error: ld returned 1 exit status
Target //tensorflow_io/video:video_py_test failed to build
```
Believe it is related to (or similiar):
https://stackoverflow.com/questions/52386530/linker-fails-in-sandbox-when-running-through-bazel-but-works-when-sandboxed-comm?rq=1
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
(By default Travis CI uses Ruby)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…ainer
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…nore error
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…brary
and use `cc_import_library` rule to prevent including GPL code.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang

Copy link
Copy Markdown
MemberAuthor

@terrytangyuan@martinwicke The PR has been updated.

I added a customized implementation of bazel rule def (cc_import_library) which controls the dependency so that library will only be linked to, and no source files (like GPL) are included or compiled.

It is pretty much similar to cc_import in Bazel's standard rule, except that cc_import does not support .so with soname. I created an issue in bazel repo: bazelbuild/bazel#7059

I think this FFmpeg PR is ready, please take a look and let me know if there are any issues.

@terrytangyuanterrytangyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yongtang

Copy link
Copy Markdown
MemberAuthor

Thanks. Will merge this PR in, and have a follow up PR with an example.

@yongtang
yongtang merged commit 5fac290 into tensorflow:masterJan 13, 2019
@yongtang
yongtang deleted the ffmpeg branch January 13, 2019 17:49
yongtang pushed a commit that referenced this pull request Jan 27, 2022
* feat: reading from bigtable (#2)
Implements reading from bigtable in a synchronous manner.
* feat: RowRange and RowSet API.
* feat: parallel read (#4)
In this pr we make the read methods accept a row_set reading only rows specified by the user.
We also add a parallel read, that leverages the sample_row_keys method to split work among workers.
* feat: version filters (#6)
This PR adds support for Bigtable version filters.
* feat: support for other data types (#5)
* fix: linter fixes (#8)
* feat docs (#9)
* fix: building on windows (#12)
* fix: refactor bigtable package to api folder (#14)
moved bigtable to tfensorflow_io.python.api
* fix: tests hanging (#30)
changed path to bigtable emulator and cbt in tests
moved arguments' initializations to the body of the function in bigtable_ops.py
fixed interleaveFromRange of column filters when using only one column
* fix: temporarily disable macos tests (#32)
* disable tests on macos
Co-authored-by: Kajetan Boroszko <kajetan@unoperate.com>
Co-authored-by: Kajetan Boroszko <kajetan.boroszko@gmail.com>
zheolong pushed a commit to zheolong/io-1 that referenced this pull request Jul 24, 2025
* feat: reading from bigtable (tensorflow#2)
Implements reading from bigtable in a synchronous manner.
* feat: RowRange and RowSet API.
* feat: parallel read (tensorflow#4)
In this pr we make the read methods accept a row_set reading only rows specified by the user.
We also add a parallel read, that leverages the sample_row_keys method to split work among workers.
* feat: version filters (tensorflow#6)
This PR adds support for Bigtable version filters.
* feat: support for other data types (tensorflow#5)
* fix: linter fixes (tensorflow#8)
* feat docs (tensorflow#9)
* fix: building on windows (tensorflow#12)
* fix: refactor bigtable package to api folder (tensorflow#14)
moved bigtable to tfensorflow_io.python.api
* fix: tests hanging (tensorflow#30)
changed path to bigtable emulator and cbt in tests
moved arguments' initializations to the body of the function in bigtable_ops.py
fixed interleaveFromRange of column filters when using only one column
* fix: temporarily disable macos tests (tensorflow#32)
* disable tests on macos
Co-authored-by: Kajetan Boroszko <kajetan@unoperate.com>
Co-authored-by: Kajetan Boroszko <kajetan.boroszko@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support video format for tensorflow-io

4 participants

@yongtang@googlebot@martinwicke@terrytangyuan