Fix timecode in live recorded files

1,076 views
Skip to first unread message

Guillaume Pellerin

unread,
Nov 19, 2012, 3:54:32 AM11/19/12
to webm-d...@webmproject.org
Hi all,

I use a Gstreamer pipeline to do live WebM streaming from a webcam and a JACK audio server to a TCP local port. A relaying app is used to record a push the stream to an external streaming server. The pb is that the timecode of the obtained file begins at the pipeline start time, not the relay/record one. Here is an example of a 1:58:14 record started 19:35:31 after the encoder start.



If there any way or tool to "trim" or make a time shift of the encoded stream so that it can be displayed correctly by players, say 0:00:00 replacing 19:35:31 in the example? The pb is not fixed when the file is remux with "ffmpeg -i in.webm -vcodec copy -acodec -copy -f webm out.webm".

Thanks
Guillaume

James Zern

unread,
Nov 19, 2012, 6:10:27 PM11/19/12
to webm-d...@webmproject.org
On Mon, Nov 19, 2012 at 12:54 AM, Guillaume Pellerin
<yomguyp...@gmail.com> wrote:
>
> Hi all,
>
> I use a Gstreamer pipeline to do live WebM streaming from a webcam and a JACK audio server to a TCP local port. A relaying app is used to record a push the stream to an external streaming server. The pb is that the timecode of the obtained file begins at the pipeline start time, not the relay/record one. Here is an example of a 1:58:14 record started 19:35:31 after the encoder start.
[...]
>
> If there any way or tool to "trim" or make a time shift of the encoded stream so that it can be displayed correctly by players, say 0:00:00 replacing 19:35:31 in the example? The pb is not fixed when the file is remux with "ffmpeg -i in.webm -vcodec copy -acodec -copy -f webm out.webm".
>

I think the setpts filter [1] will do this for you.

[1] http://www.ffmpeg.org/ffmpeg.html#asetpts_002c-setpts

Guillaume Pellerin

unread,
Nov 22, 2012, 7:22:01 AM11/22/12
to webm-d...@webmproject.org


Le mardi 20 novembre 2012 00:10:29 UTC+1, James Zern a écrit :

I think the setpts filter [1] will do this for you.

[1] http://www.ffmpeg.org/ffmpeg.html#asetpts_002c-setpts

Thanks James for the tips!

It could indeed be a PTS issue but seems not.. Tweaking some setpts parameters did not fix the pb. Thanks to ffprobe, the time of the first frame is 0.00 and a setpts=PTS-STARTPTS does not have any effect..

The only way I can fix this is to trim the file with the -ss param:

ffmpeg -ss 19:35:31 -i in.webm -vcodec copy -acodec copy -f webm out.webm

only few bytes are then removed, and it's ok. BUT, the only way I can get the *right* start time is to read the file in a HTML5 video player and copy the time value manually. I cannot get the timecode from any shell tool, and then my production system can't guess the value automatically for now.. :(

cheers,
G

James Zern

unread,
Nov 26, 2012, 2:06:26 PM11/26/12
to webm-d...@webmproject.org
I'm not sure about the rest, but I'd think mkvinfo [2] would report
the start time via the first cluster.

[2] http://www.bunkus.org/videotools/mkvtoolnix/

Guillaume Pellerin

unread,
Dec 3, 2012, 4:19:12 AM12/3/12
to webm-d...@webmproject.org
Hi James,


Le lundi 26 novembre 2012 20:06:28 UTC+1, James Zern a écrit :
I'm not sure about the rest, but I'd think mkvinfo [2] would report
the start time via the first cluster.

[2] http://www.bunkus.org/videotools/mkvtoolnix/

You are absolutely right, I can access to the start time of the first cluster with mkvtoolnix.
Thank you *very* much for your help!!

Best
Guillaume 

Guillaume Pellerin

unread,
Dec 3, 2012, 6:02:04 AM12/3/12
to webm-d...@webmproject.org
As it is difficult to parse mkvinfo strings, I've found a better approach using the python-ebml package.

G

Guillaume Pellerin

unread,
Dec 11, 2012, 11:49:57 AM12/11/12
to webm-d...@webmproject.org
Finally, I got it :


from ebml.utils.ebml_data import *
data = EBMLData(file)
data.get_first_cluster_timecode()

;)

Reply all
Reply to author
Forward
0 new messages