Skip to content

Commit b5227b8

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 1b28043 + 301768d commit b5227b8

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
## RecSync Android: Sub-millisecond Video Synchronization of Multiple Android Smartphones
2-
3-
Andrioid application which allows you to record synchronized smarpthone videos with sub-millisecond accuracy.
1+
![Logo](https://imgur.com/YtJA0E2.png)
42

53
### Usage:
64

@@ -21,6 +19,22 @@ Andrioid application which allows you to record synchronized smarpthone videos w
2119
3. Adjust exposure and ISO to your needs.
2220
4. Press the ```record video``` button to start synchronized video recording.
2321

22+
#### Extraction and matching of the frames
23+
24+
```
25+
Requirements:
26+
27+
- Python
28+
- ffmpeg
29+
```
30+
31+
1. Navigate to ```utils``` directory in the repository.
32+
2. Run ```./match.sh <VIDEO_1> <VIDEO_2>```.
33+
3. Frames will be extracted to directories ```output/1``` and ```output/2``` with timestamps in filenames, output directory will also contain ```match.csv``` file in the following format:
34+
```
35+
timestamp_1(ns) timestamp_2(ns)
36+
```
37+
2438
### Our contribution:
2539
2640
- Integrated **synchronized video recording**

app/src/main/java/com/googleresearch/capturesync/ImageMetadataSynchronizer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import androidx.annotation.NonNull;
3232

33+
import java.io.File;
3334
import java.util.ArrayList;
3435
import java.util.LinkedList;
3536
import java.util.List;
@@ -392,13 +393,18 @@ public void onCaptureCompleted(
392393
@Override
393394
public void onCaptureSequenceCompleted(@NonNull CameraCaptureSession session, int sequenceId, long frameNumber) {
394395
super.onCaptureSequenceCompleted(session, sequenceId, frameNumber);
395-
Log.v(TAG, "YAAAY I've completed succesfully");
396396
if (context.getLastVideoSeqId() != null && sequenceId == context.getLastVideoSeqId() && context.getLogger() != null) {
397397
context.getMediaRecorder().stop();
398-
// mLogger.close();
399-
// mLogger = null;
398+
399+
if (context.isVideoRecording()) {
400+
context.setVideoRecording(false);
401+
} else {
402+
// MediaRecorder created an empty video on preview, should perform a cleanup
403+
context.deleteUnusedVideo();
404+
}
405+
400406
context.getMediaRecorder().reset();
401-
context.setVideoRecording(false);
407+
402408
context.getLogger().close();
403409
context.setLogger(null);
404410
}

app/src/main/java/com/googleresearch/capturesync/MainActivity.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
import java.util.Date;
8080
import java.util.List;
8181
import java.util.Locale;
82-
import java.util.concurrent.Future;
8382
import java.util.concurrent.FutureTask;
8483
import java.util.stream.Collectors;
8584

@@ -95,6 +94,21 @@ public class MainActivity extends Activity {
9594
private String lastTimeStamp;
9695
private PeriodCalculator periodCalculator;
9796

97+
public String getLastVideoPath() {
98+
return lastVideoPath;
99+
}
100+
101+
public void deleteUnusedVideo() {
102+
String videoPath = getLastVideoPath();
103+
File videoFile = new File(videoPath);
104+
boolean result = videoFile.delete();
105+
if (!result) {
106+
Log.d(TAG, "Video file could not be deleted");
107+
}
108+
}
109+
110+
private String lastVideoPath;
111+
98112
public Integer getLastVideoSeqId() {
99113
return lastVideoSeqId;
100114
}
@@ -951,6 +965,7 @@ private void createRecorderSurface() throws IOException {
951965
MediaRecorder recorder = setUpMediaRecorder(surface, false);
952966
recorder.prepare();
953967
recorder.release();
968+
deleteUnusedVideo();
954969
}
955970

956971
private MediaRecorder setUpMediaRecorder(Surface surface) throws IOException {
@@ -968,8 +983,8 @@ private MediaRecorder setUpMediaRecorder(Surface surface, boolean specifyOutput)
968983
* set output file in media recorder
969984
*/
970985

971-
String currentPath = getOutputMediaFilePath();
972-
recorder.setOutputFile(currentPath);
986+
lastVideoPath = getOutputMediaFilePath();
987+
recorder.setOutputFile(lastVideoPath);
973988

974989
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P);
975990
recorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);

0 commit comments

Comments
 (0)