How to append one mp4 file to another?

Jan Schmidt thaytan at noraisin.net
Sat Nov 19 11:38:40 UTC 2016


On 19/11/16 05:43, sonntex wrote:

Hi,

Some comments in-line below.

> on Wed, 02 Nov 2016 09:50:31 +0200, Sebastian Dröge wrote:
>> Maybe you'd like to use the splitmuxsink element (and then splitmuxsrc)
>> for generating your files? Alternatively you will have to demux them
>> (all in one pipeline) and mux them again with (the same) mp4mux.
> 
> Thank you! So, I write some chunks using splitmuxsink. Chunks are valid
> and have correct pts, pts_time, dts, dts_time, duration and
> duration_time for each packet.
> 
> sonntex at home ~/video0 $ ls -l
> total 3696
> -rw-r--r-- 1 sonntex sonntex 1890215 Nov 18 16:58 video-chunk-00.mp4
> -rw-r--r-- 1 sonntex sonntex 1891161 Nov 18 16:58 video-chunk-01.mp4
> 
> sonntex at home ~/video0 $ ffprobe -show_packets video-chunk-01.mp4 2>&1 |
> tail -n 30
> [PACKET]
> codec_type=video
> stream_index=0
> pts=124771
> pts_time=12.477100
> dts=124771
> dts_time=12.477100
> duration=98
> duration_time=0.009800
> convergence_duration=N/A

*snip*

> 
> But result of the merge is incorrect!
> 
> sonntex at home ~/video0 $ GST_DEBUG=3 gst-launch-1.0 splitmuxsrc

*snip*

> sonntex at home ~/video0 $ ls -l
> total 7372
> -rw-r--r-- 1 sonntex sonntex 1890215 Nov 18 16:58 video-chunk-00.mp4
> -rw-r--r-- 1 sonntex sonntex 1891161 Nov 18 16:58 video-chunk-01.mp4
> -rw-r--r-- 1 sonntex sonntex 3761145 Nov 18 21:20 video.mp4
> 
> sonntex at home ~/video0 $ ffprobe -show_packets video.mp4 2>&1 | tail -n 30
> [PACKET]
> codec_type=video
> stream_index=0
> pts=124416
> pts_time=24.883200
> dts=124416
> dts_time=24.883200
> duration=652
> duration_time=0.130400
> convergence_duration=N/A
> convergence_duration_time=N/A
> size=10139
> pos=3734207
> flags=_
> [/PACKET]
> [PACKET]
> codec_type=video
> stream_index=0
> pts=125068
> pts_time=25.013600
> dts=125068
> dts_time=25.013600
> duration=49
> duration_time=0.009800
> convergence_duration=N/A
> convergence_duration_time=N/A
> size=10329
> pos=3744346
> flags=_
> [/PACKET]
> 
> As you can see, pts, dts and duration do not correspond to pts_time,
> dts_time and duration_time.


What's happened here is that qtmux has used a timescale of 5000 when
muxing the 2nd time. The pts_time, dts_time and duration_time match
exactly if you divide the pts/dts/duration by 5000 instead of 10000. I
think what's happening is that you muxed the first time using caps of
fps=100/1, and so qtmux picked 10000 (100 Hz * 100) as a timescale. But,
I guess the mux only has 50Hz worth of captured frames in it - which
makes qtdemux probably output caps with fps=50/1, and the 2nd mux
therefore picks a timescale of 5000 (50Hz * 100).

> It is not a problem for VLC in some cases, but I have one usb camera for
> which VLCdoes not work. Chunks are also valid and have correct pts,
> pts_time, dts, dts_time, duration and duration_time for each packet.
> 
> sonntex at home ~/video1 $ ls -l
> total 132
> -rw-r--r-- 1 sonntex sonntex 67913 Nov 18 17:32 video-chunk-00.mp4
> -rw-r--r-- 1 sonntex sonntex 62051 Nov 18 17:32 video-chunk-01.mp4
> 
> sonntex at home ~/video1 $ ffprobe -show_packets video-chunk-01.mp4 2>&1 |
> tail -n 30
> [PACKET]
> codec_type=video
> stream_index=0
> pts=145692
> pts_time=14.569200
> dts=145692
> dts_time=14.569200
> duration=130
> duration_time=0.013000
> convergence_duration=N/A
> convergence_duration_time=N/A
> size=12
> pos=54537
> flags=_
> [/PACKET]
> [PACKET]
> codec_type=video
> stream_index=0
> pts=145822
> pts_time=14.582200
> dts=145822
> dts_time=14.582200
> duration=1
> duration_time=0.000100
> convergence_duration=N/A
> convergence_duration_time=N/A
> size=12
> pos=54549
> flags=_
> [/PACKET]
> 
> Result of the merge is incorrect too! But, probably, there are overflows
> and some of the values are negative (not for each packet). It's enough
> for VLC to not play this file.


I think the overflows are the only real problem here. Would you like to
file a bug and make available a couple of input chunk files plus the
resulting broken merge and I can take more of a look at that to figure
out what calculation is overflowing where?

Cheers,
Jan.

> 
> sonntex at home ~/video1 $ GST_DEBUG=3 gst-launch-1.0 splitmuxsrc
> location="video-chunk-*.mp4" ! splitmuxsink location="video.mp4"
> Setting pipeline to PAUSED ...
> 0:00:00.010366521 29326       0xaf6500 WARN                 basesrc
> gstbasesrc.c:3491:gst_base_src_start_complete:<filesrc0> pad not
> activated yet
> 0:00:00.012163232 29326 0x7f63a00200f0 WARN                 qtdemux
> qtdemux.c:2886:qtdemux_parse_trex:<qtdemux0> failed to find fragment
> defaults for stream 1
> 0:00:00.012269707 29326 0x7f63a00200f0 WARN                 basesrc
> gstbasesrc.c:2400:gst_base_src_update_length:<filesrc0> processing at or
> past EOS
> 0:00:00.013142921 29326       0xaf6500 WARN                 basesrc
> gstbasesrc.c:3491:gst_base_src_start_complete:<filesrc1> pad not
> activated yet
> 0:00:00.013882447 29326       0x9e30f0 WARN                 qtdemux
> qtdemux.c:2886:qtdemux_parse_trex:<qtdemux1> failed to find fragment
> defaults for stream 1
> 0:00:00.013956282 29326       0x9e30f0 WARN                 basesrc
> gstbasesrc.c:2400:gst_base_src_update_length:<filesrc1> processing at or
> past EOS
> Pipeline is PREROLLING ...
> 0:00:00.015247807 29326 0x7f63a0020370 FIXME               basesink
> gstbasesink.c:3077:gst_base_sink_default_event:<sink> stream-start event
> without group-id. Consider implementing group-id handling in the
> upstream elements
> Pipeline is PREROLLED ...
> Setting pipeline to PLAYING ...
> 0:00:00.015483003 29326       0xaf6500 WARN                     bin
> gstbin.c:2796:gst_bin_do_latency_func:<pipeline0> did not really
> configure latency of 0:00:00.000000000
> New clock: GstSystemClock
> Got EOS from element "pipeline0".
> Execution ended after 0:00:00.008565126
> Setting pipeline to PAUSED ...
> Setting pipeline to READY ...
> Setting pipeline to NULL ...
> Freeing pipeline ...

There's no useful information in that log at level 3.

Regards,
Jan.

> sonntex at home ~/video1 $ ls -l
> total 260
> -rw-r--r-- 1 sonntex sonntex  67913 Nov 18 17:32 video-chunk-00.mp4
> -rw-r--r-- 1 sonntex sonntex  62051 Nov 18 17:32 video-chunk-01.mp4
> -rw-r--r-- 1 sonntex sonntex 130286 Nov 18 21:29 video.mp4
> 
> sonntex at home ~/video1 $ ffprobe -show_packets video.mp4 2>&1 | tail -n 30
> [PACKET]
> codec_type=video
> stream_index=0
> pts=-161503839
> pts_time=-140438.120870
> dts=-161503839
> dts_time=-140438.120870
> duration=1
> duration_time=0.000870
> convergence_duration=N/A
> convergence_duration_time=N/A
> size=12
> pos=114820
> flags=_
> [/PACKET]
> [PACKET]
> codec_type=video
> stream_index=0
> pts=-161503775
> pts_time=-140438.065217
> dts=-161503775
> dts_time=-140438.065217
> duration=1
> duration_time=0.000870
> convergence_duration=N/A
> convergence_duration_time=N/A
> size=12
> pos=114832
> flags=_
> [/PACKET]
> 
> I wrote you so many logs to show that the same problem can occur in very
> different ways.
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> 


More information about the gstreamer-devel mailing list