How to append one mp4 file to another?

sonntex sonntex at gmail.com
Fri Nov 18 18:43:30 UTC 2016


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
convergence_duration_time=N/A
size=10329
pos=1866712
flags=_
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=124869
pts_time=12.486900
dts=124869
dts_time=12.486900
duration=697
duration_time=0.069700
convergence_duration=N/A
convergence_duration_time=N/A
size=10478
pos=1877041
flags=_
[/PACKET]

But result of the merge is incorrect!

sonntex at home ~/video0 $ GST_DEBUG=3 gst-launch-1.0 splitmuxsrc
location="video-chunk-*.mp4" ! splitmuxsink location="video.mp4"
Setting pipeline to PAUSED ...
0:00:00.010555250 29243      0x1a28500 WARN                 basesrc
gstbasesrc.c:3491:gst_base_src_start_complete:<filesrc0> pad not activated
yet
0:00:00.012274605 29243 0x7fc71c0200f0 WARN                 qtdemux
qtdemux.c:2886:qtdemux_parse_trex:<qtdemux0> failed to find fragment
defaults for stream 1
0:00:00.012340497 29243 0x7fc71c0200f0 WARN                 basesrc
gstbasesrc.c:2400:gst_base_src_update_length:<filesrc0> processing at or
past EOS
0:00:00.013333616 29243      0x1a28500 WARN                 basesrc
gstbasesrc.c:3491:gst_base_src_start_complete:<filesrc1> pad not activated
yet
0:00:00.014049112 29243      0x19150f0 WARN                 qtdemux
qtdemux.c:2886:qtdemux_parse_trex:<qtdemux1> failed to find fragment
defaults for stream 1
0:00:00.014108777 29243      0x19150f0 WARN                 basesrc
gstbasesrc.c:2400:gst_base_src_update_length:<filesrc1> processing at or
past EOS
Pipeline is PREROLLING ...
0:00:00.015955797 29243 0x7fc71c020370 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.016233204 29243      0x1a28500 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.006390800
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

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.

It is not a problem for VLC in some cases, but I have one usb camera for
which VLC does 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.

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 ...

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20161118/6b2f7e44/attachment.html>


More information about the gstreamer-devel mailing list