Skip to content

Commit a0ec4fd

Browse files
superandrew213Shahen Hovhannisyan
authored andcommitted
Add frameRate & bitrate (shahen94#151)
1 parent f57addf commit a0ec4fd

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class App extends Component {
144144
componentWillMount() {
145145
const { source } = this.props;
146146
ProcessingManager.getVideoInfo(source)
147-
.then(({ duration, size }) => console.log(duration, size));
147+
.then(({ duration, size, frameRate, bitrate }) => console.log(duration, size, frameRate, bitrate));
148148

149149
ProcessingManager.trim(source, options) // like VideoPlayer trim options
150150
.then((data) => console.log(data));

android/src/main/java/com/shahenlibrary/Events/Events.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ public class Events {
1212
public static final String ERROR_TRIM = "error";
1313
public static final String ORIENTATION = "orientation";
1414
public static final String SIZE = "size";
15+
public static final String FRAMERATE = "frameRate";
16+
public static final String BITRATE = "bitrate";
1517
}

android/src/main/java/com/shahenlibrary/Trimmer/Trimmer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ public static void getVideoInfo(String path, Promise promise, ReactApplicationCo
318318
int width = Integer.parseInt(mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
319319
int height = Integer.parseInt(mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
320320
int orientation = Integer.parseInt(mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION));
321+
int frameRate = Integer.parseInt(mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_FRAMERATE));
322+
int bitrate = Integer.parseInt(mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_VARIANT_BITRATE));
321323
if (orientation == 90 || orientation == 270) {
322324
width = width + height;
323325
height = width - height;
@@ -333,6 +335,8 @@ public static void getVideoInfo(String path, Promise promise, ReactApplicationCo
333335
event.putMap(Events.SIZE, size);
334336
event.putInt(Events.DURATION, duration / 1000);
335337
event.putInt(Events.ORIENTATION, orientation);
338+
event.putInt(Events.FRAMERATE, frameRate);
339+
event.putInt(Events.BITRATE, bitrate);
336340

337341
promise.resolve(event);
338342

ios/RNVideoProcessing/RNVideoTrimmer/RNVideoTrimmer.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ class RNVideoTrimmer: NSObject {
370370
"height": isPortrait ? naturalSize.width : naturalSize.height
371371
]
372372
assetInfo["size"] = size
373+
assetInfo["frameRate"] = Int(round(track.nominalFrameRate))
374+
assetInfo["bitrate"] = Int(round(track.estimatedDataRate))
373375
}
374376
callback( [NSNull(), assetInfo] )
375377
}

0 commit comments

Comments
 (0)