user2019276
user2019276

Reputation: 1

Recovering recorded mpeg data through gstreamer

I have created an application that uses appsrc to record mp4/mpeg files. EOS event is sent whenever I have to stop recording and the file is created successfully. Everything goes well, my pipeline is

appsrc ! queue ! videorate ! ffmpegcolorspace ! x264enc ! mp4mux ! filesink location=video.mp4

By chance, if my application crashes (is unable to generate successful EOS ), the amount of recorded data is completely lost.

Is there a way to recover such files in gstreamer. I was thinking if I could append EOS by reading such files in gstreamer. Is there a provision to do that or something similar so that i don't loose the data.

Thanks,

Rahul

Upvotes: 0

Views: 1691

Answers (2)

ensonic
ensonic

Reputation: 3450

You can use the "moov-recovery-file" property and to be able to repair the file in the case of a crash. See atomsrecovery for details.

Upvotes: 0

Multimedia Mike
Multimedia Mike

Reputation: 13256

You may wish to mux the data into an MPEG transport stream (.ts) instead of an MP4 file. The reason that the MP4 file is unreadable after an application crash is that the mp4mux doesn't get a chance to write the file's 'moov' atom which can only be done after all the multimedia data is recorded (i.e., when EOS is processed). A .ts file is built for streaming and can still be read even if the end of the file is incomplete.

To invoke it, change the end of your pipeline to:

... ! x264enc ! mpegtsmux ! filesink location=video.ts

If MP4 is a requirement, the .ts file can easily be losslessly remuxed into an MP4 after recording.

Upvotes: 1

Related Questions