Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video has no duration #147

Closed
reogueone opened this issue Jul 28, 2016 · 20 comments
Closed

Video has no duration #147

reogueone opened this issue Jul 28, 2016 · 20 comments

Comments

@reogueone
Copy link

When I record a video and save it to disk as a webm or mp4 file under chrome or firefox it has no duration attribute.

This makes it difficult to play under VLC or similar media players. You cannot seek a video properly.

What can be done so that the file has a duration. To demonstrate this a video can be taken using this and saved (https://www.webrtc-experiment.com/RecordRTC/)

@CarpeNecopinum
Copy link

I think this is related to #145 and (if so) is probably caused by a browser bug.
As a (time consuming) workaround you can run it through FFMPEG to repair the files.
At https://www.webrtc-experiment.com/#ffmpeg there are some examples of how to do this inside the Browser even.

@reogueone
Copy link
Author

Does this happen non your computer with this one: https://www.webrtc-experiment.com/RecordRTC/?

I'm on the latest version of Chrome (v52) and Firefox and its present on both. I figured perhaps it is an issue with the library.

If its isolated to my computer perhaps there's not much to worry about.

@CarpeNecopinum
Copy link

Unfortunately it appears to be a general issue with both, Firefox and Chrome right now and it occurs on all machines I can test it on.

@CarpeNecopinum
Copy link

According to @ignl this should now be solved with on Firefox 48, you might want to try it there again.

@thijstriemstra
Copy link
Contributor

Some more discussion here: collab-project/videojs-record#31

Duration: N/A, start: 0.000000, bitrate: N/A

👎

@nicolasxu
Copy link

There is no duration as of today.

@thijstriemstra
Copy link
Contributor

As of today?

@nicolasxu
Copy link

yes, I am using 57.0.3 (64-bit), and it is the same on Chrome. { nb_streams: 2,
nb_programs: 0,
format_name: 'matroska,webm',
format_long_name: 'Matroska / WebM',
start_time: '-0.001000',
duration: 'N/A',
size: 981330,
bit_rate: 'N/A',
probe_score: 100 },

@vladpoltorin
Copy link

@nicolasxu can you provide part of code you get it?

@linhe3120
Copy link

how to fix it ?

@thijstriemstra
Copy link
Contributor

@linhe3120

As a (time consuming) workaround you can run it through FFMPEG to repair the files.

@imanubhardwaj
Copy link

@nicolasxu This might help.

@codeKonami
Copy link

Thanks @imanubhardwaj for your link

I've done some research and found a snippet from @thijstriemstra to make the webm blob seekable.

I've changed the code a little. Source : legokichi/ts-ebml#14 (comment)

import { Decoder, Encoder, tools, Reader } from 'ts-ebml';

const readAsArrayBuffer = (blob) => {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsArrayBuffer(blob);
    reader.onloadend = () => { resolve(reader.result); };
    reader.onerror = (ev) => { reject(ev.error); };
  });
}

const injectMetadata = blob => {
  const decoder = new Decoder();
  const reader = new Reader();
  reader.logging = false;
  reader.drop_default_duration = false;

  return readAsArrayBuffer(blob)
    .then(buffer => {
      const elms = decoder.decode(buffer);
      elms.forEach((elm) => { reader.read(elm); });
      reader.stop();

      const refinedMetadataBuf =
        tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);
      const body = buffer.slice(reader.metadataSize);

      return new Blob([ refinedMetadataBuf, body ], { type: blob.type });
    });
}


// Can be used like this

injectMetadata(blob)
  .then(seekableBlob => {
    // 
  })

@muaz-khan
Copy link
Owner

RecordRTC now exports getSeekableBlob : https://recordrtc.org/global.html#getSeekableBlob

Relevant demo: https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/seeking-workaround.html

E.g.

recorder.stopRecording(function() {
    getSeekableBlob(recorder.getBlob(), function(seekableBlob) {
        video.src = URL.createObjectURL(seekableBlob);
    });
});

@CoreyCole
Copy link

If you are getting the error when using getSeekableBlob():

https://www.webrtc-experiment.com/RecordRTC.js 1905:14 Uncaught Error: Please link: https://www.webrtc-experiment.com/EBML.js

Make sure to include EBML.js CDN:

<script src="https://www.webrtc-experiment.com/EBML.js"></script>

@diveshchakrayat
Copy link

RecordRTC now exports getSeekableBlob : https://recordrtc.org/global.html#getSeekableBlob

Relevant demo: https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/seeking-workaround.html

E.g.

recorder.stopRecording(function() {
    getSeekableBlob(recorder.getBlob(), function(seekableBlob) {
        video.src = URL.createObjectURL(seekableBlob);
    });
});

@shamseerahammedm
Copy link

shamseerahammedm commented Oct 27, 2020

@muaz-khan how to add this in react project getting --->
Uncaught Error: Please link: https://www.webrtc-experiment.com/EBML.js error

@JimNewaz
Copy link

I'm facing a problem with audio duration length, I have a chrome extension, which works properly but when I download the recorded file it shows 00.00 duration. is there anyone who can solve the bug? Please
https://github.com/JimNewaz/Record-audio-chrome-extension-

marob added a commit to marob/slidev that referenced this issue Feb 18, 2022
We could import from TypeScript instead of as a script in HTML if legokichi/ts-ebml#38 got merged
marob added a commit to marob/slidev that referenced this issue Feb 18, 2022
We're importing recordrtc dependency twice (second time from github URL instead of from npm registry) in order to have the required EBML.js file (which is not packed in the npm registry version)
marob added a commit to marob/slidev that referenced this issue Feb 18, 2022
N.B.: we're importing a JS file from a CDN in index.html, which seems not good (we depend on internet connection and CDN availability)
marob added a commit to marob/slidev that referenced this issue Feb 18, 2022
marob added a commit to marob/slidev that referenced this issue Feb 18, 2022
N.B.: adds ts-ebml dependency (from a fork as the corresponding PR is not merged yet: legokichi/ts-ebml#38)
marob added a commit to marob/slidev that referenced this issue Feb 18, 2022
N.B.: adds ts-ebml dependency (from a fork as the corresponding PR is not merged yet: legokichi/ts-ebml#38)
@buynao
Copy link

buynao commented Mar 26, 2022

RecordRTC now exports getSeekableBlob : https://recordrtc.org/global.html#getSeekableBlob

Relevant demo: https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/seeking-workaround.html

E.g.

recorder.stopRecording(function() {
    getSeekableBlob(recorder.getBlob(), function(seekableBlob) {
        video.src = URL.createObjectURL(seekableBlob);
    });
});

This solution has some problems if the video file is larger than 2GB, because it uses arrayBuffer internally, which has a size limit. Based on this, I wrapped webm-duration-fix, which uses blob.stream to solve the problem of fixing large files and memory usage.

@MarconLP
Copy link

Here is an example using fix-webm-duration

fixWebmDuration(
    recorder.getBlob(),
    duration * 1000,
    (seekableBlob) => {
        console.log(seekableBlob);
    }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests