I read mp4 file using filesrc, qtdemux, h264parse and appsink elements. The pipeline reads all of data from the file immediately, but I want to read it from the file as from live source based on fps. How can I do it?
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
On Mon, 2016-12-26 at 18:54 +0300, sonntex wrote:
> I read mp4 file using filesrc, qtdemux, h264parse and appsink > elements. The pipeline reads all of data from the file immediately, > but I want to read it from the file as from live source based on fps. > How can I do it? You can use appsink sync=true to make appsink sync to the pipeline clock, then you get the frames in "real time" according to the timestamps in the file. In C code: g_object_set (appsink, "sync", TRUE, NULL); Cheers -Tim -- Tim Müller, Centricular Ltd - http://www.centricular.com _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by sonntex
On Mon, 26 Dec 2016 16:22:05 +0000, Tim wrote: Thanks, Tim.> You can use appsink sync=true to make appsink sync to the pipeline > clock, then you get the frames in "real time" according to the > timestamps in the file. > In C code: g_object_set (appsink, "sync", TRUE, NULL); I have already set sync parameter to appsink and it still not works. So, I wrote small example to reproduce this behavior and noticed that timestamps are very strange. #include <gst/gst.h> #include <gst/app/gstappsink.h> ... GstFlowReturn callback_new_sample( { GstSample* sample = gst_app_sink_pull_sample(GST_ GstBuffer* buffer = gst_sample_get_buffer(sample); unsigned int pts = GST_BUFFER_PTS(buffer) / 1000000; GST_INFO("pts %u", pts); gst_sample_unref(sample); return GST_FLOW_OK; } int main(int arc, char* argv[]) { const char* filename = argv[1]; ... source_ = gst_element_factory_make(" g_object_set(G_OBJECT(source_) demux_ = gst_element_factory_make(" g_signal_connect(G_OBJECT( sink_ = gst_element_factory_make(" g_object_set(G_OBJECT(sink_), "sync", TRUE, nullptr); GstAppSinkCallbacks callbacks; callbacks.eos = callback_eos; callbacks.new_preroll = callback_new_preroll; callbacks.new_sample = callback_new_sample; gst_app_sink_set_callbacks( pipeline_ = gst_pipeline_new(nullptr); gst_bin_add_many(GST_BIN( gst_element_link_many(source_, demux_, nullptr); gst_element_set_state( ... return 0; } Log looks like: # GST_DEBUG=4 ./a.out test.mp4 ^C0:00:00.000024789 1351 0xedf600 INFO GST_INIT gst.c:511:init_pre: Initializing GStreamer Core Library version 1.8.3 0:00:00.000046383 1351 0xedf600 INFO GST_INIT gst.c:512:init_pre: Using library installed in /usr/lib64 0:00:00.000051828 1351 0xedf600 INFO GST_INIT gst.c:523:init_pre: Linux work 4.4.6-gentoo #1 SMP Mon Jun 20 21:47:25 MSK 2016 x86_64 0:00:00.000166972 1351 0xedf600 INFO GST_INIT gstmessage.c:119:_priv_gst_ 0:00:00.000382660 1351 0xedf600 INFO GST_INIT gstcontext.c:83:_priv_gst_ 0:00:00.000474209 1351 0xedf600 INFO GST_PLUGIN_LOADING gstplugin.c:316:_priv_gst_ 0:00:00.000517428 1351 0xedf600 INFO GST_PLUGIN_LOADING gstplugin.c:224:gst_plugin_ 0:00:00.000523021 1351 0xedf600 INFO GST_PLUGIN_LOADING gstplugin.c:226:gst_plugin_ 0:00:00.000533622 1351 0xedf600 INFO GST_REGISTRY gstregistry.c:1723:ensure_ 0:00:00.006085663 1351 0xedf600 INFO GST_REGISTRY gstregistrybinary.c:619:priv_ 0:00:00.006109244 1351 0xedf600 INFO GST_REGISTRY gstregistry.c:1579:scan_and_ 0:00:00.006453591 1351 0xedf600 INFO GST_REGISTRY gstregistry.c:1681:scan_and_ 0:00:00.006459902 1351 0xedf600 INFO GST_REGISTRY gstregistry.c:1758:ensure_ 0:00:00.006463467 1351 0xedf600 INFO GST_INIT gst.c:724:init_post: GLib runtime version: 2.48.2 0:00:00.006467367 1351 0xedf600 INFO GST_INIT gst.c:726:init_post: GLib headers version: 2.48.2 0:00:00.006470279 1351 0xedf600 INFO GST_INIT gst.c:727:init_post: initialized GStreamer successfully 0:00:00.006688576 1351 0xedf600 INFO GST_PLUGIN_LOADING gstplugin.c:842:_priv_gst_ 0:00:00.006696099 1351 0xedf600 INFO GST_ELEMENT_FACTORY gstelementfactory.c:364:gst_ 0:00:00.006751118 1351 0xedf600 INFO GST_ELEMENT_PADS gstelement.c:659:gst_element_ 0:00:00.006767442 1351 0xedf600 INFO filesrc gstfilesrc.c:262:gst_file_src_ 0:00:00.006771123 1351 0xedf600 INFO filesrc gstfilesrc.c:263:gst_file_src_ 0:00:00.007559798 1351 0xedf600 INFO GST_PLUGIN_LOADING gstplugin.c:842:_priv_gst_ 0:00:00.007568188 1351 0xedf600 INFO GST_ELEMENT_FACTORY gstelementfactory.c:364:gst_ 0:00:00.007619874 1351 0xedf600 INFO GST_ELEMENT_PADS gstelement.c:659:gst_element_ 0:00:00.007698294 1351 0xedf600 INFO GST_PLUGIN_LOADING gstplugin.c:842:_priv_gst_ 0:00:00.007704788 1351 0xedf600 INFO GST_ELEMENT_FACTORY gstelementfactory.c:364:gst_ 0:00:00.007763602 1351 0xedf600 INFO GST_ELEMENT_PADS gstelement.c:659:gst_element_ 0:00:00.007775545 1351 0xedf600 INFO GST_ELEMENT_FACTORY gstelementfactory.c:364:gst_ 0:00:00.007807031 1351 0xedf600 INFO GST_ELEMENT_PADS gstutils.c:1573:gst_element_ 0:00:00.007813983 1351 0xedf600 INFO GST_PADS gstutils.c:932:gst_pad_check_ 0:00:00.007825108 1351 0xedf600 INFO GST_PADS gstutils.c:1446:prepare_link_ 0:00:00.007831980 1351 0xedf600 INFO GST_PADS gstpad.c:2315:gst_pad_link_ 0:00:00.007837913 1351 0xedf600 INFO GST_PADS gstpad.c:2521:gst_pad_link_ 0:00:00.007841939 1351 0xedf600 INFO GST_EVENT gstevent.c:1382:gst_event_new_ 0:00:00.007845735 1351 0xedf600 INFO GST_EVENT gstpad.c:5634:gst_pad_send_ 0:00:00.007856986 1351 0xedf600 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.007863943 1351 0xedf600 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.007867942 1351 0xedf600 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.007876749 1351 0xedf600 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.007882375 1351 0xedf600 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.007886530 1351 0xedf600 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.007889458 1351 0xedf600 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.007894090 1351 0xedf600 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.007898132 1351 0xedf600 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.007906107 1351 0xedf600 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.007910314 1351 0xedf600 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.007915219 1351 0xedf600 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.007921417 1351 0xedf600 INFO GST_STATES gstelement.c:2347:gst_element_ 0:00:00.007925725 1351 0xedf600 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.007929851 1351 0xedf600 INFO GST_STATES gstelement.c:2354:gst_element_ 0:00:00.007935450 1351 0xedf600 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.007942516 1351 0xedf600 INFO GST_STATES gstbin.c:2770:gst_bin_change_ 0:00:00.007947776 1351 0xedf600 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.007953441 1351 0xedf600 INFO filesrc gstfilesrc.c:465:gst_file_src_ 0:00:00.007964619 1351 0xedf600 WARN basesrc gstbasesrc.c:3489:gst_base_ 0:00:00.007975058 1351 0xedf600 INFO filesrc gstfilesrc.c:465:gst_file_src_ 0:00:00.007991495 1351 0xedf600 INFO task gsttask.c:451:gst_task_set_ 0:00:00.007996993 1351 0xedf600 INFO GST_PADS gstpad.c:5980:gst_pad_start_ 0:00:00.008024612 1351 0xedf600 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.008030469 1351 0xedf600 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.008037059 1351 0xedf600 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.008042842 1351 0xedf600 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.008049092 1351 0xedf600 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.008053129 1351 0xedf600 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.008058672 1351 0xedf600 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.008089488 1351 0x104c2d0 INFO qtdemux qtdemux.c:12065:qtdemux_parse_ 0:00:00.008099620 1351 0x104c2d0 INFO qtdemux qtdemux.c:12066:qtdemux_parse_ 0:00:00.008105428 1351 0x104c2d0 WARN qtdemux qtdemux.c:2651:qtdemux_parse_ 0:00:00.008125053 1351 0x104c2d0 INFO qtdemux qtdemux.c:9770:qtdemux_parse_ 0:00:00.008165490 1351 0x104c2d0 WARN basesrc gstbasesrc.c:2396:gst_base_ 0:00:00.008170281 1351 0x104c2d0 INFO GST_SCHEDULING gstpad.c:4757:gst_pad_get_ 0:00:00.008175076 1351 0x104c2d0 INFO GST_SCHEDULING gstpad.c:4972:gst_pad_pull_ 0:00:00.008195578 1351 0x104c2d0 INFO GST_ELEMENT_PADS gstelement.c:907:gst_element_ 0:00:00.008214760 1351 0x104c2d0 INFO GST_EVENT gstevent.c:679:gst_event_new_ 0:00:00.008230859 1351 0x104c2d0 INFO GST_ELEMENT_PADS gstelement.c:659:gst_element_ 0:00:00.008243006 1351 0x104c2d0 INFO default main.cpp:42:callback_pad_ 0:00:00.008249071 1351 0x104c2d0 INFO default main.cpp:46:callback_pad_ 0:00:00.008252887 1351 0x104c2d0 INFO GST_ELEMENT_PADS gstutils.c:1573:gst_element_ 0:00:00.008258225 1351 0x104c2d0 INFO GST_ELEMENT_PADS gstelement.c:907:gst_element_ 0:00:00.008262557 1351 0x104c2d0 INFO GST_ELEMENT_PADS gstelement.c:907:gst_element_ 0:00:00.008266602 1351 0x104c2d0 INFO GST_PADS gstutils.c:1446:prepare_link_ 0:00:00.008272895 1351 0x104c2d0 INFO GST_PADS gstpad.c:2315:gst_pad_link_ 0:00:00.008281034 1351 0x104c2d0 INFO GST_PADS gstpad.c:2521:gst_pad_link_ 0:00:00.008285766 1351 0x104c2d0 INFO GST_EVENT gstevent.c:1382:gst_event_new_ 0:00:00.008303260 1351 0x104c2d0 INFO GST_EVENT gstevent.c:760:gst_event_new_ 0:00:00.008322506 1351 0x104c2d0 INFO GST_EVENT gstevent.c:679:gst_event_new_ 0:00:00.008384508 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008406598 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008416023 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008424983 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008433337 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008441179 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008449325 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008457575 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008465503 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008473565 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008481699 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008489477 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.008497337 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ ... 0:00:00.023391797 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.023399748 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.023407601 1351 0x104c2d0 INFO default main.cpp:30:callback_new_ 0:00:00.023414189 1351 0x104c2d0 INFO default main.cpp:15:callback_eos: eos 0:00:00.023424894 1351 0x104c2d0 INFO GST_STATES gstbin.c:3238:bin_handle_ 0:00:00.023430630 1351 0x104c2d0 INFO GST_STATES gstbin.c:3267:bin_handle_ 0:00:00.023435062 1351 0x104c2d0 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.023471893 1351 0x7fb220009370 INFO GST_STATES gstbin.c:3061:gst_bin_ 0:00:00.023551495 1351 0x7fb220009370 INFO GST_EVENT gstevent.c:1253:gst_event_new_ 0:00:00.023567781 1351 0x7fb220009370 INFO bin gstbin.c:2593:gst_bin_do_ 0:00:00.023580785 1351 0x7fb220009370 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.023588790 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.023594097 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.023598944 1351 0x104c2d0 INFO task gsttask.c:316:gst_task_func:< 0:00:00.023600873 1351 0x7fb220009370 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.023610995 1351 0x7fb220009370 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.023616256 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.023620188 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.023625923 1351 0x7fb220009370 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.023630932 1351 0x7fb220009370 INFO GST_STATES gstbin.c:2316:gst_bin_element_ 0:00:00.023635868 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.023639614 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2277:_priv_gst_ 0:00:00.023644775 1351 0x7fb220009370 INFO GST_STATES gstbin.c:2764:gst_bin_change_ 0:00:00.023650205 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2372:gst_element_ 0:00:00.023654303 1351 0x7fb220009370 INFO GST_STATES gstelement.c:2277:_priv_gst_ As you can see all frames were read before pipeline moved to playing state and timestamps counted not from zero. Why? Is it a problem of my test.mp4 file? # gst-discoverer-1.0 -v test.mp4 Analyzing file:///home/sonntex/devel/test/test.mp4 Done discovering file:///home/sonntex/devel/test/test.mp4 Topology: container: video/quicktime, variant=(string)iso video: video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4, profile=(string)main, codec_data=(buffer)014d0028ffe1000d674d00288d8d280a00b760201001000468ee3c80, width=(int)1280, height=(int)720, framerate=(fraction)30000/1001, pixel-aspect-ratio=(fraction)1/1 Tags: video codec: H.264 / AVC bitrate: 4938555 language code: en datetime: 2016-12-26T15:02:36Z container format: ISO MP4/M4A Codec: video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)4, profile=(string)main, codec_data=(buffer)014d0028ffe1000d674d00288d8d280a00b760201001000468ee3c80, width=(int)1280, height=(int)720, framerate=(fraction)30000/1001, pixel-aspect-ratio=(fraction)1/1 Additional info: None Stream ID: d83440ba6fe683cff74bed3048a01ab4826a1e09dc9345c944fb75c69014812e/001 Width: 1280 Height: 720 Depth: 24 Frame rate: 30000/1001 Pixel aspect ratio: 1/1 Interlaced: false Bitrate: 4938555 Max bitrate: 0 Properties: Duration: 0:00:59.982777777 Seekable: yes Tags: video codec: H.264 / AVC bitrate: 4938555 language code: en datetime: 2016-12-26T15:02:36Z container format: ISO MP4/M4A _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |