Skip to content

Add stream selection support for tf.contrib.ffmpeg.decode_audio - #16101

Merged
fredbertsch merged 3 commits into
tensorflow:masterfrom
yongtang:16073-decode_audio-streams
Jan 23, 2018
Merged

fredbertsch merged 3 commits into
tensorflow:masterfrom
yongtang:16073-decode_audio-streams

Conversation

@yongtang

Copy link
Copy Markdown
Member

This fix tries to address the issue raised in #16073 where it was not possible to selectively decode a perticular stream with tf.contrib.ffmpeg.decode_audio.
This fix adds an additional attribute stream which could be used to specify the stream to decode (e.g., stream="1"). By default stream="" which leaves the decision to ffmpeg.

This fix fixes #16073.

Signed-off-by: Yong Tang [email protected]

This fix tries to address the issue raised in 16073 where it
was not possible to selectively decode a perticular stream
with `tf.contrib.ffmpeg.decode_audio`.
This fix adds an additional attribute `stream` which could
be used to specify the stream to decode. By default stream=''
which leaves the decision to ffmpeg.

This fix fixes 16073.

Signed-off-by: Yong Tang <[email protected]>
@carlthome

Copy link
Copy Markdown
Contributor

LGTM!

@carlthome

Copy link
Copy Markdown
Contributor

Do you think it would be good for API symmetry to have the same extension for tf.contrib.ffmpeg.decode_video or is that excessive? I can't think of many video files with multiple streams but what do I know?

@yongtang

Copy link
Copy Markdown
Member Author

@carlthome I think it makes sense to have stream selection support for decode_video as well. Let me take a look.

@yongtang

Copy link
Copy Markdown
Member Author

Actually there is a bug in decode_video that causes it to not run correctly. I have created a separate PR #16105 to fix it, as it is a bug (not a feature request).

I will work on follow up PR for stream selection support for decode_video once #16105 is merged.

@caisq
caisq requested a review from fredbertsch January 13, 2018 20:25
@caisq caisq added the awaiting review Pull request awaiting review label Jan 13, 2018
@faroit

faroit commented Jan 14, 2018

Copy link
Copy Markdown

@yongtang maybe I am missing this, but is there a way to get the number of available substreams so that users can iterate over all substreams?

@carlthome

Copy link
Copy Markdown
Contributor

Similarly, being able to set a time offset and duration would be nice (i.e. ffmpeg -ss 00:03:00 and -t 60 for being able to only decode parts of longer movies and audio files, so you can work through a folder of files in reasonable segments, but maybe that is best to think about in a separate issue.

@yongtang

Copy link
Copy Markdown
Member Author

@carlthome @faroit I think it might be possible to have another op (e.g., video_info) so that any video related information (e.g., number of streams, length, etc.) is accessible. I can work on creating another PR if this PR is merged.

@rmlarsen rmlarsen added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Jan 23, 2018
@fredbertsch

Copy link
Copy Markdown
Contributor

This looks great! Thanks for doing this. Unfortunately, merging this will break our internal build. I'm going to create an internal change that we can synchronize with this one.

@fredbertsch fredbertsch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. I've got a parallel change that will happen internally, so I'll merge this PR once that's in flight.

Thank you very much for the added capability! :)

@fredbertsch
fredbertsch merged commit 3bf0933 into tensorflow:master Jan 23, 2018
@yongtang

Copy link
Copy Markdown
Member Author

@fredbertsch Thanks for the help! 👍 🎉

@yongtang
yongtang deleted the 16073-decode_audio-streams branch January 23, 2018 22:27
@rmlarsen

Copy link
Copy Markdown
Contributor

Please have a look at the test failures, e.g.

https://source.cloud.google.com/results/invocations/87ffa93c-e04d-463d-8b1d-5bd68486b076/targets/%2F%2Ftensorflow%2Fcontrib%2Flayers:layers_test/log

  File "/tmp/botexec/bazel-out/k8-py3-opt/bin/tensorflow/contrib/layers/layers_test.runfiles/org_tensorflow/tensorflow/python/framework/ops.py", line 1617, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): output_shape has incorrect number of elements: 23 should be: 3
	 [[Node: SparseToDense = SparseToDense[T=DT_INT64, Tindices=DT_INT64, validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](dense_to_sparse/Where, dense_to_sparse/GatherNd, dense_to_sparse/Shape, SparseToDense/default_value)]]

@yongtang

Copy link
Copy Markdown
Member Author

@rmlarsen I run though the test of //tensorflow/contrib/layers:layers_test but it passed. Is the failure related to another PR?

@yongtang

yongtang commented Feb 4, 2018

Copy link
Copy Markdown
Member Author

The PR #16696 adds the stream selection support for tf.contrib.ffmpeg.decode_video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review Pull request awaiting review cla: yes stat:awaiting tensorflower Status - Awaiting response from tensorflower

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: (optionally) return all audio streams in tf.contrib.ffmpeg.decode_audio

7 participants