google-code-export / red5

Automatically exported from code.google.com/p/red5
0 stars 0 forks source link

Appending to a stream doesn't update the time #438

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Publish a stream for 10 seconds (0 - 10 secs)
2.Then publish again by appending to the same file (another 10 seconds)
3.When playing the flv file the timer show the file lendth is only 10 seconds 
even though the video will play past 10 seconds

What is the expected output? What do you see instead?
The timer should show that the file is 20 seconds

What version of the product are you using? On what operating system?
Red5 revision 4710

Please provide any additional information below.

In FLVWriter.java file there's a comment "update duration" with no 
implementation. Here's an implementation that do the duration update but that 
sometimes corrupt the file and I can't play it.

    File hdr = new File(filePath + ".hdr");
                RandomAccessFile hdrfile = new RandomAccessFile(hdr, "rws");                
                writeHeader(hdrfile);
                duration = FLVReader.getDuration(file);
                System.out.println("xFile: " + filePath + " - Duration: " + duration);
                writeMetadataTag(duration * 0.001d, videoCodecId, audioCodecId, hdrfile);

                if(file != null)
                {
                    file.seek(0);
                    hdrfile.seek(0);
                    file.getChannel().transferFrom(hdrfile.getChannel(), 0, hdrfile.length());
                }

                hdrfile.close();

                if (hdr.exists()) {
                    hdr.delete();
                }

Original issue reported on code.google.com by jdn...@gmail.com on 19 Sep 2013 at 11:10

GoogleCodeExporter commented 9 years ago

Original comment by mondain on 23 Sep 2013 at 5:45