Skip to content

Commit

Permalink
* Override methods in FFmpegFrameGrabber to get all metadata from …
Browse files Browse the repository at this point in the history
…streams (issue #1180)
  • Loading branch information
saudet committed Apr 9, 2019
1 parent 5b5655a commit dd8fc3f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,4 +1,5 @@

* Override methods in `FFmpegFrameGrabber` to get all metadata from streams ([issue #1180](https://github.com/bytedeco/javacv/issues/1180))
* Fix sample rate in output of `FFmpegFrameRecorder` by setting deprecated `AVStream.codec.time_base` ([issue #1179](https://github.com/bytedeco/javacv/issues/1179))
* Add `asetpts=N` to input of `FFmpegFrameFilter` to make filters like `afade` behave as expected ([issue #1171](https://github.com/bytedeco/javacv/issues/1171))
* Use `AVFormat.format()` from `Frame.opaque` when available in `FFmpegFrameFilter` and `FFmpegFrameRecorder` ([issue #1173](https://github.com/bytedeco/javacv/issues/1173))
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Expand Up @@ -496,6 +496,42 @@ public double getVideoFrameRate() {
return sampleRate > 0 || audio_c == null ? super.getSampleRate() : audio_c.sample_rate();
}

@Override public Map<String, String> getMetadata() {
if (oc == null) {
return super.getMetadata();
}
AVDictionaryEntry entry = null;
Map<String, String> metadata = new HashMap<String, String>();
while ((entry = av_dict_get(oc.metadata(), "", entry, AV_DICT_IGNORE_SUFFIX)) != null) {
metadata.put(entry.key().getString(), entry.value().getString());
}
return metadata;
}

@Override public Map<String, String> getVideoMetadata() {
if (video_st == null) {
return super.getVideoMetadata();
}
AVDictionaryEntry entry = null;
Map<String, String> metadata = new HashMap<String, String>();
while ((entry = av_dict_get(video_st.metadata(), "", entry, AV_DICT_IGNORE_SUFFIX)) != null) {
metadata.put(entry.key().getString(), entry.value().getString());
}
return metadata;
}

@Override public Map<String, String> getAudioMetadata() {
if (audio_st == null) {
return super.getAudioMetadata();
}
AVDictionaryEntry entry = null;
Map<String, String> metadata = new HashMap<String, String>();
while ((entry = av_dict_get(audio_st.metadata(), "", entry, AV_DICT_IGNORE_SUFFIX)) != null) {
metadata.put(entry.key().getString(), entry.value().getString());
}
return metadata;
}

@Override public String getMetadata(String key) {
if (oc == null) {
return super.getMetadata(key);
Expand Down

0 comments on commit dd8fc3f

Please sign in to comment.