手册上说am5728的IVAHD支持H264编解码,我想用它做两路视频编解码,需要如何配置呢?
abayyy:
你好,请问一下 5728的 IVA HD 模块应该怎么使用呢?我没有找到demo, 也不知道它的 API在什么地方 ,能告知一下吗? 方便的话 加个 qq 吧 164422340 谢谢
Yaoming Qin:
回复 abayyy:
您可以先熟悉下gstreamer。
abayyy:
回复 Yaoming Qin:
你好,我熟悉了一下 gstreamer 下面是我的代码 我是用这个代码 而且 也是使用的交叉编译编译工具链编译的:
#include <stdio.h> #include <string.h> #include <gst/gst.h> #include <glib.h>GstElement *pipeline,*source,*demuxer,*Videoqueue,*h264par,*Videodecoder,*Videosink,*Audioqueue,*Audiodecoder,*Audiosink;static gboolean bus_call(GstBus *bus,GstMessage *msg,gpointer data){GMainLoop *loop = (GMainLoop *)data;switch(GST_MESSAGE_TYPE(msg)){case GST_MESSAGE_EOS:g_print("play ending!\n");break;case GST_MESSAGE_ERROR: {gchar*debug;GError*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); }static void on_pad_added(GstElement *element,GstPad *pad,gpointer data){char video[12]="video_0"; //char audio[9]="audio_00";gchar *new_pad_name = GST_PAD_NAME(pad);g_print("recvfrom '%s' new pad' %s' \n",GST_ELEMENT_NAME (element),new_pad_name);GstPad *audio_sink_pad ,*video_sink_pad;video_sink_pad = gst_element_get_static_pad(Videoqueue,"sink");audio_sink_pad = gst_element_get_static_pad(Audioqueue,"sink");if(!strcmp(new_pad_name,video)){g_print("link %s pad\n",new_pad_name);gst_pad_link(pad,video_sink_pad);}else{g_print("link %s pad\n",new_pad_name);gst_pad_link(pad,audio_sink_pad);}gst_object_unref(video_sink_pad);gst_object_unref(audio_sink_pad); }int main(int argc,char *argv[]){GMainLoop *loop;GstBus *bus;gst_init(&argc,&argv);loop = g_main_loop_new(NULL,FALSE);if (argc != 2){g_printerr("You need file : %s <.moc filename>\n",argv[0]);return(-1);}//创建用来容纳元件的新管道pipeline = gst_pipeline_new("test-pipeline");if (!pipeline){g_printerr("pipeline creat failure,quit!\n");return(-1);}//生成用于读取硬盘数据的元件source= gst_element_factory_make("filesrc","file-source");if (!source){g_printerr("source creat failure,quit!\n");return(-1);}//流分离器demuxer= gst_element_factory_make("qtdemux","demuxer");if (!demuxer){g_printerr("demuxer creat failure,quit!\n");return(-1);}//队列元件 同步输出设备,播放视频、音频流,双线程可以独立运行并达到更好的同步效果。Videoqueue = gst_element_factory_make("queue","videoqueue");if (!Videoqueue){g_printerr("Videoqueue creat failure,quit!\n");return(-1);}//h264parseh264par = gst_element_factory_make("h264parse","h264par");if (!h264par){g_printerr("h264par creat failure,quit!\n");return(-1);}//视频解码器Videodecoder= gst_element_factory_make("ducatih264dec","video-decoder");if (!Videodecoder){g_printerr("Videodecoder creat failure,quit!\n");return(-1);}//视频回放元件Videosink = gst_element_factory_make("kmssink","video-output");if (!Videosink){g_printerr("Videosink creat failure,quit!\n");return(-1);}//队列元件Audioqueue = gst_element_factory_make("queue","audioqueue");if (!Audioqueue){g_printerr("Audioqueue creat failure,quit!\n");return(-1);}//音频解码器Audiodecoder = gst_element_factory_make("decodebin","audio-decoder");if (!Audiodecoder){g_printerr("Audiodecoder creat failure,quit!\n");return(-1);}//音频回放元件Audiosink = gst_element_factory_make("fakesink","audio-output");if (!Audiosink){g_printerr("Audiosink creat failure,quit!\n");return(-1);}//|| !h264par/*if (!pipeline || !source || !demuxer || !queue || !decoder|| !textoverlay|| !sink || !Audioqueue || !Audiodecoder|| !Audiosink){g_printerr("element creat failure,quit!\n");return(-1);}*///设置 source的location 参数 文件地址g_object_set(G_OBJECT(source),"location",argv[1],NULL);//g_object_set(G_OBJECT(Videosink),"scale",1,NULL);//得到 管道的消息总线bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));gst_bus_add_watch(bus,bus_call,loop); //添加消息监视器gst_object_unref(bus);//添加元件gst_bin_add_many(GST_BIN(pipeline),source,demuxer,Videoqueue,h264par,Videodecoder,Videosink,Audioqueue,Audiodecoder,Audiosink,NULL);//分别链接元件gst_element_link(source,demuxer);gst_element_link_many(Videoqueue,h264par,Videodecoder,Videosink,NULL);gst_element_link_many(Audioqueue,Audiodecoder,Audiosink,NULL);//按照不同的流,动态链接不同的接收衬垫 sink padg_signal_connect(demuxer,"pad-added",G_CALLBACK(on_pad_added),NULL);//开始播放g_print("start playing %s\n",argv[1]);gst_element_set_state(pipeline,GST_STATE_PLAYING);g_main_loop_run(loop);//停止管道处理流程gst_element_set_state(pipeline,GST_STATE_NULL);//释放占用的资源gst_object_unref(GST_OBJECT(pipeline));return(0); }
编译命令:/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-gcc -pthread gst_mov.c -o gst_mov -I/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/targetNFS/usr/include/gstreamer-1.0/ -I/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/targetNFS/usr/include/glib-2.0/ -I/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/targetNFS/usr/lib/glib-2.0/include/ -I/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/targetNFS/usr/include/glib-2.0/glib/ -L/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/targetNFS/usr/lib -L/home/aba/ti-processor-sdk-linux-am57xx-evm-03.00.00.04/targetNFS/lib -lgstreamer-1.0 -lgobject-2.0 -lgmodule-2.0 -lpthread -lxml2 -lglib-2.0
//板子接上键盘 ctrl+Backspace ctrl+F2 模式
runing: ./gst_mov /usr/share/ti/video/TearOfSteel-Short-1920×800.mov
//上面这的程序运行没有错误 可是并没有出现视频画面 谢谢
//下面这个命令是可以执行的
gst-launch-1.0 filesrc location=b.mov ! qtdemux name=demux demux.audio_0 ! queue ! decodebin ! fakesink demux.video_0 ! queue ! h264parse ! ducatih264dec ! kmssink scale=true
Yaoming Qin:
回复 abayyy:
请问您是在哪个板子上做的实验,另外,请您参考 http://processors.wiki.ti.com/index.php/Processor_Training:_Multimedia
abayyy:
回复 Yaoming Qin:
我的板子是 AM5728
abayyy:
回复 abayyy:
板子上提供的demo 使用 gst-launch 来运行的 你发的那个网址也是使用 gst-launch 来做的 现在需要 c 语言来实现 而且要使用 内存地址来代替 源文件。谢谢
Yaoming Qin:
回复 abayyy:
命令行就是给出了需要用的plugin以及连接方式,如果要写成代码,请您自行研究gstreamer的文档写代码了,其实网上的资源很多。
对于应用层,我们支持有限。
abayyy:
回复 Yaoming Qin:
嗯 谢谢,只要方向正确就好了。
shengang han:
回复 Yaoming Qin:
请问我发现打不份的管道在长时间运行都会出现这个问题,你知道怎么解决么?
(gst-launch-1.0:1355): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
** (gst-launch-1.0:1355): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
** (gst-launch-1.0:1355): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
** (gst-launch-1.0:1355): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
** (gst-launch-1.0:1355): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
** (gst-launch-1.0:1355): CRITICAL **: gst_fd_memory_get_fd: assertion 'GST_IS_FD_ALLOCATOR (mem->allocator)' failed
详细请看我发的帖子:e2e.ti.com/…/656704