Skip to content

Commit

Permalink
add unick name to init mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 committed Dec 21, 2024
1 parent 3799870 commit afcabdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/antmedia/muxer/HLSMuxer.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void init(IScope scope, String name, int resolutionHeight, String subFold
options.put("hls_segment_type", hlsSegmentType);
if (HLS_SEGMENT_TYPE_FMP4.equals(hlsSegmentType)) {

segmentInitFilename = initialResourceNameWithoutExtension + "_init.mp4";
segmentInitFilename = initialResourceNameWithoutExtension + "_" + System.currentTimeMillis() + "_init.mp4";
options.put("hls_fmp4_init_filename", segmentInitFilename);
segmentFilename += FMP4_EXTENSION;
} else { //if it's mpegts
Expand Down
14 changes: 10 additions & 4 deletions src/test/java/io/antmedia/test/MuxerUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,16 @@ public void testHEVCHLSMuxingInFMP4() {

//check the init file and m4s files there
assertTrue(hlsMuxer.getFile().exists());
assertTrue(new File(hlsMuxer.getFile().getParentFile()+ "/" + streamId + "_init.mp4").exists());
assertTrue(new File(hlsMuxer.getFile().getParentFile()+ "/" + streamId + "000000003.fmp4").exists());


String[] filesInStreams = hlsMuxer.getFile().getParentFile().list();
boolean initFileFound = false;
String regex = streamId + "_" + System.currentTimeMillis()/10000 + "\\d{4}_init.mp4";
System.out.println("regex:"+regex);

for (int i = 0; i < filesInStreams.length; i++) {
System.out.println("files:"+filesInStreams[i]);
initFileFound |= filesInStreams[i].matches(regex);
}
assertTrue(initFileFound);
assertTrue(MuxingTest.testFile(hlsMuxer.getFile().getAbsolutePath(), 107000));

assertEquals(0, hlsMuxer.getAudioNotWrittenCount());
Expand Down

0 comments on commit afcabdc

Please sign in to comment.