Recording a segment from MP4 file.

jlancaster jeff_lancaster at msn.com
Mon Nov 12 08:33:52 PST 2012


The following pipeline successfully creates an mp4 file that is playable.

gst-launch -v -e filesrc location="sample1.mp4" ! qtdemux name=demux ! queue
!  nal2bytestream_h264  !  qtmux ! filesink location=sample2.mp4

If I create this pipeline programmatically, I can playback the output file:

    pipeline = gst_pipeline_new ("my-pipeline");
    src      = gst_element_factory_make ("filesrc", "src");
    demux    = gst_element_factory_make ("qtdemux", "demux");
    queuev   = gst_element_factory_make ("queue", "queuev");
    parse    = gst_element_factory_make ("nal2bytestream_h264", "parse");
    mux      = gst_element_factory_make ("qtmux", "mux");
    sink     = gst_element_factory_make ("filesink", "sink");
    g_object_set (G_OBJECT (src), "location", filename, NULL);
    g_object_set (G_OBJECT (demux), "name", "demux", NULL);
    g_object_set (G_OBJECT (sink), "location", fileout, NULL);
    gst_bin_add_many(GST_BIN (pipeline), src, demux, queuev, parse, mux,
sink, NULL);
    gst_check(gst_element_link(src, demux));
    gst_element_link_many(queuev, parse, mux, sink, NULL);
    gst_pad_add_event_probe(gst_element_get_static_pad(mux,"src"),
G_CALLBACK(drop_eos_probe), pipeline);
    g_signal_connect (demux, "pad-added", G_CALLBACK (on_pad_added),
queuev);
    //gst_element_set_state(pipeline, GST_STATE_PLAYING);

BUT, when I try to record a segment of the original clip using the above
pipeline and the following lines of code I cannot playback the new file:
    gst_element_seek(data.pipeline, 1.0, GST_FORMAT_TIME, 
        GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_FLUSH |
GST_SEEK_FLAG_KEY_UNIT, 
        GST_SEEK_TYPE_SET, start * GST_SECOND, GST_SEEK_TYPE_SET, (end+2) *
GST_SECOND);
    gst_element_set_state (data.pipeline, GST_STATE_PLAYING);

If I change the sink from filesink to v4l2sink, it will playback just the
segment just fine.

Question: Why can't I playback a recorded segment of an mp4 file?

If I use MediaInfo to examine the output file it only sees that it is a QT
file and not much more. So the mp4 container is somehow corrupt.






-----
Jeff Lancaster
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Recording-a-segment-from-MP4-file-tp4656876.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list