Hi all,
I've been following this thread gstreamer: video fails to play when opened for second time but as I'm not sure if my problem is the same I'm opening a new one.
My problem is in a iMX28 custom board, and the code I'm running in my application is really trivial:
gst_init (NULL, NULL); |
/* Build the pipeline */
pipeline = gst_parse_launch ("playbin2 uri=file:///mnt/gonzalo/Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4", NULL);
/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
/* Free resources */
if (msg != NULL)
gst_message_unref(msg); |
gst_object_unref(bus);
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(pipeline);
gst_deinit();
First time I run this code in my application everything goes fine, the video is played nicely. Here is the log:
Aiur: 3.0.6
Core: MPEG4PARSER_06.04.27 build on Dec 20 2012 16:48:05
mime: video/quicktime; audio/x-m4a; application/x-3gp
file: /usr/lib/imx-mm/parser/lib_mp4_parser_arm9_elinux.so.3.1
Content Info:
URI:
file:///mnt/gonzalo/Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4
Idx File:
/root/.aiur/.mnt.gonzalo.Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4.ai
dx
Seekable : Yes
Size(byte): 18666817
Movie Info:
Seekable : Yes
Live : No
Duration : 0:01:41.000000000
ReadMode : File
Track : 2
Track 00 [video_000000] Enabled
Duration: 0:01:41.000000000
Language: eng
Mime:
video/x-h264, parsed=(boolean)true, width=(int)200, height=(int)120, framerate=(
fraction)15/1, codec_data=(buffer)000000016742c00ddb0d11e59610000003001000000301
e0f142ae0000000168ca8cb2
H264D_ARM9_02.06.01 build on Jul 12 2011 14:01:56.
MFW_GST_H264_DECODER_PLUGIN 3.0.6 build on Feb 5 2014 15:30:55.
Track 01 [audio_000000] Enabled
Duration: 0:01:40.850000000
Language: eng
Mime:
audio/mpeg, mpegversion=(int)1, framed=(boolean)true, channels=(int)2, rate=(int
)22050, bitrate=(int)160013
MFW_GST_V4LSINK_PLUGIN 3.0.6 build on Feb 5 2014 15:30:44.
Beep: 3.0.6
Core: MP3 decoder Wrapper build on Jan 16 2013 16:21:07
mime: audio/mpeg, mpegversion = (int)1
file: /usr/lib/imx-mm/audio-codec/wrap/lib_mp3d_wrap_arm9_elinux.so
CODEC: BLN_MAD-MMCODECS_MP3D_ARM_02.13.00_ARM9 build on Dec 5 2012 09:44:32.
>>V4L_SINK: Actually buffer status:
hardware buffer : 21
software buffer : 0
full screen size:480x272
[V4L Update Display]: left=0, top=0, width=480, height=272
Running time 0:01:40.940589569 render fps 14.157
Total rendered:1429
[--->FINALIZE aiurdemux
Second time my application runs the same code I get the following error:
(<unknown>:4591): GStreamer-CRITICAL **: gst_element_set_state: assertion `GST_IS_ELEMENT (element)' failed
(<unknown>:4591): GStreamer-CRITICAL **: gst_element_get_bus: assertion `GST_IS_ELEMENT (element)' failed
(<unknown>:4591): GStreamer-CRITICAL **: gst_bus_timed_pop_filtered: assertion `GST_IS_BUS (bus)' failed
(<unknown>:4591): GStreamer-CRITICAL **: gst_object_unref: assertion `object != NULL' failed
(<unknown>:4591): GStreamer-CRITICAL **: gst_element_set_state: assertion `GST_IS_ELEMENT (element)' failed
(<unknown>:4591): GStreamer-CRITICAL **: gst_object_unref: assertion `object != NULL' failed
If I restart my application, the previous code runs fine but once again, only the first time. I've also tried running the same code from a CHILD process. Doing it this way, the code DOESN'T FAIL, so looks something is not de-initializing properly. But in my application I don't want to run it in a child process, and would like to know what's wrong in this code.
Can someone help me?
Thanks in advance,
Gonzalo.
已解决! 转到解答。
Hi Gonzalo,
I have attached the libmfw_gst_v4lsink.so extracted from the MM codec package 3.0.11. Please use this library file to replace the one in your rootfs. After the change, the repeat mode can work for your H.264 test vectors.
Thanks,
Peter
According to Multimedia Feature Matrix, the maximum resolution of H.264 video decoding is 320 x 240 @ 30 fps in base profile.
Feature | Profile | Max Resolution | Min Resolution | Max Framerate | H/W or S/W | Comments | ||
Implementation | ||||||||
Video Decoder | MPEG4 | SP | 320*240 | 16 * 16 | 30 fps | S/W | Support H263BP | |
H.264 | BP | 320*240 | 16 * 16 | 30 fps | S/W |
Video outside this specification may have unexpected behavior. Would you please transcode the H.264 video to 320*240 base profile and try again?
Hi Peter,
yes, I already knew the video codec specs.
And I've already done tens of tests using 320x240, 240x136 and lower resolutions, and found same results: MPEG4 performs much better than H.264, and it's hard to get a file with H.264 encoding that shows the [--->FINALIZE v4l_sink message at the end of every repetition (most of them don't play the second time).
Thanks,
Gonzalo.
Hi Peter,
I've had a chance to work on this again after holidays, and it looks you found the solution !!!
Now it works fine for every repetition, using libmfw_gst_v4lsink.so from MM codec package 3.0.11 and the patched gplay. I've tried many mp4 files that previously showed this problem, and even files out of specification (> 320x240) are playing fine.
Thanks a lot for your work !!!!!!
Please, could you point me to a tarball or repository with MM codec package 3.0.11 to integrate in my current Ltib??
Thanks,
Gonzalo.
Once again, thanks a lot Peter !!!
I was getting insane looking into the Yocto recipes for a repository. But I've noticed there are 2 patches in Yocto:
- build-Fix-out-of-tree-build.patch
- Remove-use-of-obsolete-VIDIOC_DBG_G_CHIP_IDENT.patch
How do you build the MM codec package? Under Ltib? If so, could you share your spec file?
Thanks,
Gonzalo
I've found an issue while trying to compile fsl MM codec package 3.0.11:
.....
aiurdemux.c: In function 'aiurdemux_callback_getflag_pull':
aiurdemux.c:735:21: error: 'FILE_FLAG_NON_SEEKABLE' undeclared (first use in this function)
aiurdemux.c:735:21: note: each undeclared identifier is reported only once for each function it appears in
aiurdemux.c:736:21: error: 'FILE_FLAG_READ_IN_SEQUENCE' undeclared (first use in this function)
aiurdemux.c: In function 'aiurdemux_callback_getflag_push':
aiurdemux.c:893:21: error: 'FILE_FLAG_NON_SEEKABLE' undeclared (first use in this function)
aiurdemux.c:894:21: error: 'FILE_FLAG_READ_IN_SEQUENCE' undeclared (first use in this function)
aiurdemux.c: In function 'aiurdemux_loop_state_init':
aiurdemux.c:2320:14: error: 'FslFileStream' has no member named 'GetFlag'
aiurdemux.c:2330:14: error: 'FslFileStream' has no member named 'GetFlag'
aiurdemux.c: In function 'aiurdemux_parse_audio':
aiurdemux.c:3161:10: error: 'AUDIO_EC3' undeclared (first use in this function)
.......
It looks like the compiler is looking for these header files:
<ltib_dir>/rootfs/usr/include/imx-mm/parser/fsl_parser.h
<ltib_dir>/rootfs/usr/include/imx-mm/parser/fsl_media_types.h
<ltib_dir>/rootfs/usr/include/imx-mm/parser/fsl_types.h
and if they exist from a previous package (in my case, from 3.0.6) then compilation fails.
If these files are removed then compilation is succesfull but the new header files are NOT installed in <ltib_dir>/rootfs/usr/include/imx-mm/parser/ so a better workaround is to replace the OLD header files in <ltib_dir>/rootfs/usr/include/imx-mm/parser/ with the NEW header files from <ltib_dir>/rpm/BUILD/gst-fsl-plugins-3.0.11/inc/core_lib/parser
I don't know the root cause of this issue but this dirty-fix works fine. Now I have my custom board running fsl MM codec package 3.0.11 under Ltib.
It would be nice if someone could take care of this problem and find a fix because (probably) more header files should be updated in the RFS.
Thanks,
Gonzalo.
Hi Gonzalo,
The compile error is caused by the header file differences between libfslparser-3.0.6 and libfslparser-3.0.11. The proper way to resolve these errors is to get the libfslparser-3.0.11 & libfslcodec-3.0.11 and install them to the device rootfs. Unfortunately, both libraries are released in binary format (not tar.gz anymore) and there is no simple way to extract them. The method I use is to install and build the BSP L3.10.17 and locate their source from the working directory. Then, tarball the source with the appropriate filename and version and copy them to /var.tmp/pkgs. Finally,in LTIB install the libfslcodec-3.0.11, libfslparser-3.0.11 and then build the gst-fsl-plugins-3.0.11.
Hope you understand that I can't post the MM codec 3.0.11 here without license agreement/disclaimer.
Thanks,
Peter
Hi Dmitry,
when removing the Freescale's codecs I'm not able to get gplay running with the remaining ones in L2.6.35_1.1.0_130130_images_MX28.
But, please, see 9th post in this thread:
- vdqueue = gst_element_factory_make ("queue", "video-queue");
- vdsink = gst_element_factory_make ("mfw_v4lsink", "video-sink");
+ vdqueue = gst_element_factory_make ("ffmpegcolorspace", "video-queue");
+ vdsink = gst_element_factory_make ("fbdevsink", "video-sink");
If I use fbdevsink instead of mfw_v4lsink, then everything works fine (with a nearly 100% CPU load).
The probelm is that i need mfw_v4lsink, because it uses the PXP driver, and I need to use that driver to implement HW overlaying
Thanks,
Gonzalo.
try to use yocto build system instead ltib.
gstreamer-0.10 via webkit doesn't play video on i.mx6 (yocto master, webkit-5.1.1) this link may help to you.
I've been trying to dig on this issue and it looks gst_deinit(); does not rewind everything done in gst_init(NULL,NULL);
So I've modified the previous code calling only once to gst_init(NULL,NULL); and removing the call to gst_deinit(); (like in the gstreamer SDK examples)
The result is the same (1st time OK, next time KO), but the problem is different. I've been comparing logs with different gstreamer debug levels, and it looks the problem is related to mfw_v4lsink.
Attached are the logs for the first and second run, with GST_DEBUG=mfw_v4lsink:5
This is extracted from the log of the first run:
.............
H264D_ARM9_02.06.01 build on Jul 12 2011 14:01:56.
MFW_GST_H264_DECODER_PLUGIN 3.0.6 build on Feb 5 2014 15:30:55.
Track 01 [audio_000000] Enabled
Duration: 0:01:40.850000000
Language: eng
Mime:
audio/mpeg, mpegversion=(int)1, framed=(boolean)true, channels=(int)2, rate=(int
)22050, bitrate=(int)160013
0:00:01.392187502 1250 0x6eaa70 INFO mfw_v4lsink mfw_gst_v4lsink.c:262:mfw_gst_get_first_odev: Get first device:/dev/video0, capabilities 0x4000202
0:00:01.393125002 1250 0x6eaa70 INFO mfw_v4lsink mfw_gst_v4lsink.c:300:mfw_gst_v4l2sink_query_support_formats: supported format:[RGB3]24-bit RGB
0:00:01.393562502 1250 0x6eaa70 INFO mfw_v4lsink mfw_gst_v4lsink.c:300:mfw_gst_v4l2sink_query_support_formats: supported format:[RGBP]16-bit RGB 5:6:5
0:00:01.393968752 1250 0x6eaa70 INFO mfw_v4lsink mfw_gst_v4lsink.c:300:mfw_gst_v4l2sink_query_support_formats: supported format:[RGBO]16-bit RGB 5:5:5
0:00:01.394343752 1250 0x6eaa70 INFO mfw_v4lsink mfw_gst_v4lsink.c:300:mfw_gst_v4l2sink_query_support_formats: supported format:[YU12]YUV 4:2:0 Planar
0:00:01.394718752 1250 0x6eaa70 INFO mfw_v4lsink mfw_gst_v4lsink.c:300:mfw_gst_v4l2sink_query_support_formats: supported format:[422P]YUV 4:2:2 Planar
MFW_GST_V4LSINK_PLUGIN 3.0.6 build on Feb 5 2014 15:30:44.
0:00:01.404687502 1250 0x6eaa70 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:1469:mfw_gst_v4lsink_change_state:
>>V4LSINK: State: 10
0:00:01.427281251 1250 0x6eaa70 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:1469:mfw_gst_v4lsink_change_state:
>>V4LSINK: State: 19
0:00:02.205875000 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2003:mfw_gst_v4lsink_buffer_alloc: crop_left_bypixel=16
0:00:02.213250000 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2004:mfw_gst_v4lsink_buffer_alloc: crop_top_by_pixel=16
0:00:02.215937501 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2005:mfw_gst_v4lsink_buffer_alloc: crop_right_bypixel=24
0:00:02.216343751 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2006:mfw_gst_v4lsink_buffer_alloc: crop_bottom_by_pixel=24
0:00:02.216687501 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2016:mfw_gst_v4lsink_buffer_alloc: aspectratio_n=1
0:00:02.217000001 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2017:mfw_gst_v4lsink_buffer_alloc: aspectratio_d=1
0:00:02.217343751 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2019:mfw_gst_v4lsink_buffer_alloc: Decoded Width = 240, Decoded Height = 160
0:00:02.219250001 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2031:mfw_gst_v4lsink_buffer_alloc: Decoder maximal reserved 21 buffers.
0:00:02.219656251 1250 0x6ab1e8 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2065:mfw_gst_v4lsink_buffer_alloc: Decoder maximal support 127 buffers.
0:00:02.220562501 1250 0x6ab1e8 INFO mfw_v4lsink mfw_gst_v4lsink.c:262:mfw_gst_get_first_odev: Get first device:/dev/video0, capabilities 0x4000202
0:00:02.221093751 1250 0x6ab1e8 ERROR mfw_v4lsink mfw_gst_v4l.c:825:mfw_gst_v4l2_set_rotation: set ctrl failed
0:00:02.221656251 1250 0x6ab1e8 LOG mfw_v4lsink mfw_gst_v4l.c:931:mfw_gst_v4l2_output_setup: 21 hwbuffers sucessfully allocated.
0:00:02.222093751 1250 0x6ab1e8 ERROR mfw_v4lsink mfw_gst_v4l.c:1213:mfw_gst_v4l2_set_fmt: Set frame sucessfully
>>V4L_SINK: Actually buffer status:
hardware buffer : 21
software buffer : 0
Beep: 3.0.6
.............
and this is from the log of the second run:
.............
H264D_ARM9_02.06.01 build on Jul 12 2011 14:01:56.
MFW_GST_H264_DECODER_PLUGIN 3.0.6 build on Feb 5 2014 15:30:55.
Track 01 [audio_000000] Enabled
Duration: 0:01:40.850000000
Language: eng
Mime:
audio/mpeg, mpegversion=(int)1, framed=(boolean)true, channels=(int)2, rate=(int
)22050, bitrate=(int)160013
MFW_GST_V4LSINK_PLUGIN 3.0.6 build on Feb 5 2014 15:30:44.
0:01:49.693843752 1250 0x118390 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:1469:mfw_gst_v4lsink_change_state:
>>V4LSINK: State: 10
0:01:49.711218752 1250 0x118390 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:1469:mfw_gst_v4lsink_change_state:
>>V4LSINK: State: 19
0:01:50.285562501 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2003:mfw_gst_v4lsink_buffer_alloc: crop_left_bypixel=16
0:01:50.286031251 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2004:mfw_gst_v4lsink_buffer_alloc: crop_top_by_pixel=16
0:01:50.289625001 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2005:mfw_gst_v4lsink_buffer_alloc: crop_right_bypixel=24
0:01:50.291343751 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2006:mfw_gst_v4lsink_buffer_alloc: crop_bottom_by_pixel=24
0:01:50.293593751 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2016:mfw_gst_v4lsink_buffer_alloc: aspectratio_n=1
0:01:50.294812501 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2017:mfw_gst_v4lsink_buffer_alloc: aspectratio_d=1
0:01:50.296593751 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2019:mfw_gst_v4lsink_buffer_alloc: Decoded Width = 240, Decoded Height = 160
0:01:50.298562501 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2031:mfw_gst_v4lsink_buffer_alloc: Decoder maximal reserved 21 buffers.
0:01:50.298968751 1250 0x71ff38 DEBUG mfw_v4lsink mfw_gst_v4lsink.c:2065:mfw_gst_v4lsink_buffer_alloc: Decoder maximal support 127 buffers.
0:01:50.302437500 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l.c:619:mfw_gst_v4l2_open: Unable to open
0:01:50.302843750 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l.c:825:mfw_gst_v4l2_set_rotation: set ctrl failed
0:01:50.303187500 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l.c:861:mfw_gst_v4l2_pxp_set_color: set ctrl 134217729 failed
0:01:50.303500000 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l.c:869:mfw_gst_v4l2_pxp_set_color: set ctrl 134217730 failed
0:01:50.303875000 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l.c:907:mfw_gst_v4l2_output_setup: set format failed 1
0:01:50.304218750 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l.c:1197:mfw_gst_v4l2_set_fmt: Error in mfw_gst_v4lsink_output_setup
VIDIOC_S_FMT output overlay: Bad file descriptor
>>V4L_SINK: Actually buffer status:
hardware buffer : 21
software buffer : 0
0:01:50.305218750 1250 0x71ff38 ERROR mfw_v4lsink mfw_gst_v4l_buffer.c:490:mfw_gst_v4l2_new_hwbuffer: VIDIOC_QUERYBUF failed 0, device id:-1, err:Bad file descriptor
Beep: 3.0.6
.............
Major differences are marked in RED. The problem looks to be related with the second time /dev/video0 is opened.
Please, can someone point me how to continue debugging this?
Thanks,
Gonzalo.
Hi Gonzalo,
there is a long time I dont write a GST app, but at some point your code needs to run a loop:
/* Set the pipeline to "playing" state*/
g_print ("Now playing: %s\n", argv[1]);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Iterate */
g_print ("Running...\n");
g_main_loop_run (loop);
/* Out of the main loop, clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);
Do you have it this way?
Hi Leonardo, and thanks for answering !!!
You are right, there is no loop in my code.
I'm new to gstreamer and am following the examples in the SDK.
Basic tutorial 1: Hello World http://docs.gstreamer.com/pages/viewpage.action?pageId=327735
Basic tutorial 3: Dynamic pipelines http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+3%3A+Dynamic+pipelines
and neither of them perform a glib main loop. They simply block on gst_bus_timed_pop_filtered
just waiting for a message of the selected type to appear. Unfortunately, the code of both tutorials runs fine only for the first time (I haven't compared logs for tutorial #3, as I'm concentrating in tutorial #1 just for simplicity).
Thanks,
Gonzalo.
I've been trying to look for the reason of this error VIDIOC_S_FMT output overlay: Bad file descriptor in my second post.
I've added printks to the PXP driver (mxs_pxp.c) in:
This is the log I get for the first run:
Aiur: 3.0.6
Core: MPEG4PARSER_06.04.27 build on Dec 20 2012 16:48:05
mime: video/quicktime; audio/x-m4a; application/x-3gp
file: /usr/lib/imx-mm/parser/lib_mp4_parser_arm9_elinux.so.3.1
Content Info:
URI:
file:///mnt/gonzalo/Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4
Idx File:
/root/.aiur/.mnt.gonzalo.Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4.ai
dx
Seekable : Yes
Size(byte): 18666817
Movie Info:
Seekable : Yes
Live : No
Duration : 0:01:41.000000000
ReadMode : File
Track : 2
Track 00 [video_000000] Enabled
Duration: 0:01:41.000000000
Language: eng
Mime:
video/x-h264, parsed=(boolean)true, width=(int)200, height=(int)120, framerate=(
fraction)15/1, codec_data=(buffer)000000016742c00ddb0d11e59610000003001000000301
e0f142ae0000000168ca8cb2
H264D_ARM9_02.06.01 build on Jul 12 2011 14:01:56.
MFW_GST_H264_DECODER_PLUGIN 3.0.6 build on Feb 5 2014 15:30:55.
Track 01 [audio_000000] Enabled
Duration: 0:01:40.850000000
Language: eng
Mime:
audio/mpeg, mpegversion=(int)1, framed=(boolean)true, channels=(int)2, rate=(int
)22050, bitrate=(int)160013
[ 4577.800000] [pxp_open] pxp->users = 0
[ 4577.810000] [pxp_close] pxp->users = 1
MFW_GST_V4LSINK_PLUGIN 3.0.6 build on Feb 5 2014 15:30:44.
[ 4578.640000] [pxp_open] pxp->users = 0
>>V4L_SINK: Actually buffer status:
hardware buffer : 21
software buffer : 0
Beep: 3.0.6
Core: MP3 decoder Wrapper build on Jan 16 2013 16:21:07
mime: audio/mpeg, mpegversion = (int)1
file: /usr/lib/imx-mm/audio-codec/wrap/lib_mp3d_wrap_arm9_elinux.so
CODEC: BLN_MAD-MMCODECS_MP3D_ARM_02.13.00_ARM9 build on Dec 5 2012 09:44:32.
full screen size:480x272
[V4L Update Display]: left=0, top=0, width=480, height=272
Running time 0:01:40.943310657 render fps 14.226
Total rendered:1436
[--->FINALIZE aiurdemux
and this is the log for the second run:
Aiur: 3.0.6
Core: MPEG4PARSER_06.04.27 build on Dec 20 2012 16:48:05
mime: video/quicktime; audio/x-m4a; application/x-3gp
file: /usr/lib/imx-mm/parser/lib_mp4_parser_arm9_elinux.so.3.1
Content Info:
URI:
file:///mnt/gonzalo/Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4
Idx File:
/root/.aiur/.mnt.gonzalo.Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4.ai
dx
Seekable : Yes
Size(byte): 18666817
Movie Info:
Seekable : Yes
Live : No
Duration : 0:01:41.000000000
ReadMode : File
Track : 2
Track 00 [video_000000] Enabled
Duration: 0:01:41.000000000
Language: eng
Mime:
video/x-h264, parsed=(boolean)true, width=(int)200, height=(int)120, framerate=(
fraction)15/1, codec_data=(buffer)000000016742c00ddb0d11e59610000003001000000301
e0f142ae0000000168ca8cb2
H264D_ARM9_02.06.01 build on Jul 12 2011 14:01:56.
MFW_GST_H264_DECODER_PLUGIN 3.0.6 build on Feb 5 2014 15:30:55.
Track 01 [audio_000000] Enabled
Duration: 0:01:40.850000000
Language: eng
Mime:
audio/mpeg, mpegversion=(int)1, framed=(boolean)true, channels=(int)2, rate=(int
)22050, bitrate=(int)160013
MFW_GST_V4LSINK_PLUGIN 3.0.6 build on Feb 5 2014 15:30:44.
[ 4680.520000] [pxp_open] pxp->users = 1
[ 4680.520000] [pxp_open] -> Returning -EBUSY
VIDIOC_S_FMT output overlay: Bad file descriptor
>>V4L_SINK: Actually buffer status:
hardware buffer : 21
software buffer : 0
Beep: 3.0.6
Core: MP3 decoder Wrapper build on Jan 16 2013 16:21:07
mime: audio/mpeg, mpegversion = (int)1
file: /usr/lib/imx-mm/audio-codec/wrap/lib_mp3d_wrap_arm9_elinux.so
CODEC: BLN_MAD-MMCODECS_MP3D_ARM_02.13.00_ARM9 build on Dec 5 2012 09:44:32.
[ 4681.550000] [pxp_open] pxp->users = 1
[ 4681.550000] [pxp_open] -> Returning -EBUSY
After first run /dev/video0 is not closed so when /dev/video0 is re-open in the second run the driver returns EBUSY and mfw_v4lsink fails.
I don't know how to continue debugging this issue so the question is, why /dev/video0 is not closed when the pipeline is unreferenced?
Thanks,
Gonzalo.
For some reason the playbin2 elements are not de-initializing completely, so reopening a device is causing an error. You may try this hello-world app and see if you find the same issue:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-helloworld.html
Also, take at look at the gst-launch source code.
Hi Leonardo,
I don't know if you want me just to run the audio-player of the hello-world app or run my video getting rid of playbin2.
As I cannot confirm a complete de-initialisation of the audio player, I've done the second one using mfw_v4lsink, based on this code: All Boards Creating App Video
My code looks as follows:
===============================================================================================================
void on_pad_added (GstElement *element, GstPad *pad){
g_debug ("Signal: pad-added");
GstCaps *caps;
GstStructure *str;
caps = gst_pad_get_caps (pad);
g_assert (caps != NULL);
str = gst_caps_get_structure (caps, 0);
g_assert (str != NULL);
printf("STR[%s]\n", gst_structure_get_name (str));
if (g_strrstr (gst_structure_get_name (str), "video")) {
g_debug ("Linking video pad to dec_vd");
// Link it actually
GstPad *targetsink = gst_element_get_pad (decvd, "sink");
g_assert (targetsink != NULL);
gst_pad_link (pad, targetsink);
gst_object_unref (targetsink);
}
if (g_strrstr (gst_structure_get_name (str), "audio")) {
g_debug ("Linking audio pad to dec_ad");
// Link it actually
GstPad *targetsink = gst_element_get_pad (decad, "sink");
g_assert (targetsink != NULL);
gst_pad_link (pad, targetsink);
gst_object_unref (targetsink);
}
gst_caps_unref (caps);
}
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data){
GMainLoop *loop = (GMainLoop *) data;
gchar *debug;
GError *error;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End of stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &error, &debug);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
default:
break;
}
return TRUE;
}
int play_video (char* video_file){
GMainLoop *loop;
GstElement *pipeline;
GstBus *bus;
static int init = 1;
loop = g_main_loop_new (NULL, FALSE);
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("media-player");
source = gst_element_factory_make ("filesrc", "file-source");
fqueue = gst_element_factory_make ("multiqueue", "file-queue");
demuxer = gst_element_factory_make ("qtdemux", "avi-demuxer");
decvd = gst_element_factory_make ("mfw_h264decoder", "video-decoder");
vdqueue = gst_element_factory_make ("queue", "video-queue");
vdsink = gst_element_factory_make ("mfw_v4lsink", "video-sink");
decad = gst_element_factory_make ("mfw_mp3decoder", "audio-decoder");
adqueue = gst_element_factory_make ("queue", "audio-queue");
adconv = gst_element_factory_make ("audioconvert", "audio-converter");
adresamp = gst_element_factory_make ("audioresample", "audio-resampler");
adsink = gst_element_factory_make ("alsasink", "audio-sink"); // "autoaudiosink"
if (!pipeline) {g_printerr ("Error: [pipeline] could not be created. Exiting.\n"); return -1;}
if (!source) {g_printerr ("Error: [source] could not be created. Exiting.\n"); return -1;}
if (!fqueue) {g_printerr ("Error: [fqueue] could not be created. Exiting.\n"); return -1;}
if (!demuxer) {g_printerr ("Error: [demuxer] could not be created. Exiting.\n"); return -1;}
if (!decvd) {g_printerr ("Error: [decvd] could not be created. Exiting.\n"); return -1;}
if (!vdqueue) {g_printerr ("Error: [vdqueue] could not be created. Exiting.\n"); return -1;}
if (!vdsink) {g_printerr ("Error: [vdsink] could not be created. Exiting.\n"); return -1;}
if (!decad) {g_printerr ("Error: [decad] could not be created. Exiting.\n"); return -1;}
if (!adqueue) {g_printerr ("Error: [adqueue] could not be created. Exiting.\n"); return -1;}
if (!adconv) {g_printerr ("Error: [adconv] could not be created. Exiting.\n"); return -1;}
if (!adresamp) {g_printerr ("Error: [adresamp] could not be created. Exiting.\n"); return -1;}
if (!adsink) {g_printerr ("Error: [adsink] could not be created. Exiting.\n"); return -1;}
/* Set up the pipeline */
/* we set the input filename to the source element */
g_object_set (G_OBJECT (source), "location", video_file, NULL);
/* we add a message handler */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* we add all elements into the pipeline */
/* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */
gst_bin_add_many (GST_BIN (pipeline), source, fqueue, demuxer, decvd, vdqueue, vdsink, decad, adqueue, adconv, adresamp, adsink, NULL);
/* we link the elements together */
if (!gst_element_link (source, fqueue)) {g_printerr ("Error: unable to link [source <> fqueue]. Exiting.\n"); return -1;}
if (!gst_element_link (fqueue, demuxer)) {g_printerr ("Error: unable to link [fqueue <> demuxer]. Exiting.\n"); return -1;}
if (!gst_element_link (decvd, vdqueue)) {g_printerr ("Error: unable to link [decvd <> vdqueue]. Exiting.\n"); return -1;}
if (!gst_element_link (vdqueue, vdsink)) {g_printerr ("Error: unable to link [vdqueue <> vdsink]. Exiting.\n"); return -1;}
if (!gst_element_link (decad, adqueue)) {g_printerr ("Error: unable to link [decad <> adqueue]. Exiting.\n"); return -1;}
if (!gst_element_link (adqueue, adconv)) {g_printerr ("Error: unable to link [adqueue <> adconv]. Exiting.\n"); return -1;}
if (!gst_element_link (adconv, adresamp)) {g_printerr ("Error: unable to link [adconv <> adresamp]. Exiting.\n"); return -1;}
if (!gst_element_link (adresamp, adsink)) {g_printerr ("Error: unable to link [adresamp <> adsink]. Exiting.\n"); return -1;}
g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), NULL);
/* note that the demuxer will be linked to the decoder dynamically.
The reason is that Ogg may contain various streams (for example
audio and video). The source pad(s) will be created at run time,
by the demuxer when it detects the amount and nature of streams.
Therefore we connect a callback function which will be executed
when the "pad-added" is emitted.*/
/* Set the pipeline to "playing" state*/
g_print ("Now playing: %s\n", video_file);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Iterate */
g_print ("Running...\n");
g_main_loop_run (loop);
/* Out of the main loop, clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}
int main (int argc, char *argv[]){
gst_init (NULL, NULL);
while(1){
play_video("/mnt/gonzalo/Copreci-heart_x264_200x120_12000_15fps_320_22050.mp4");
}
return -1;
}
===============================================================================================================
As in my previous tests using playbin2 , this code runs fine only for the first time. /dev/video0 remains open for ever and in the second run the driver returns EBUSY and mfw_v4lsink fails.
Thanks,
Gonzalo.