1.下游更改后强行恢复至上游最新状态
1 2 3 4 5 |
git remote add upstream https://github.com/poemdistance/ScreenTranslation git fetch upstream git pull upstream master |
2.Submodules, 第一次更新下载...
Continue reading...1.下游更改后强行恢复至上游最新状态
1 2 3 4 5 |
git remote add upstream https://github.com/poemdistance/ScreenTranslation git fetch upstream git pull upstream master |
2.Submodules, 第一次更新下载...
Continue reading...Python直接调用len计算出的是字符个数。如下:
1 2 3 4 5 |
>>> s = '测试' >>> len(s) 2 |
如果要得到字节长度可以编码成utf-8格式:
1 2 3 4 5 |
>>> s = '测试' >>> len(s.encode('utf8')) 6 |
...
Continue reading...exec函数簇在运行的时候是将原进程的映像替换成新的执行进程的,所以如果直接在一个进程中,即main函数中调用execl, execp等函数,主进程会被替换掉,exec簇函数后面的内容将不会被执行,所以如果要使用此函数,可以fork一个子进程来运行。 同样地,在线程中调用了此类函数,主进程的所有映像也一样会替换掉,因为线程没有独立地址空间,进程有,而exec簇函数会改变进程的映像,只能拿线程所在的进程下手。 exec类函数相关信息参照:execl(3)...
Continue reading...一: 下载数据库连接器
1 2 3 |
pip install mysql-connector-python |
参考:https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html...
Continue reading...思路: 用浏览器的F12调试功能,找到定义文章标题字体属性的class,如在写这篇文章时,本网站主题定义标题字体的class为entry-title 登录到服务器,cd到主题文件目录下,运行命令grep entry-title...
Continue reading...源代码出处: https://gstreamer.freedesktop.org/documentation/application-development/basics/helloworld.html?gi-language=c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
#include <gst/gst.h> #include <glib.h> 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 ("End of stream\n"); g_main_loop_quit (loop); 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) { GstPad *sinkpad; GstElement *decoder = (GstElement *) data; /* We can now link this pad with the vorbis-decoder sink pad */ g_print ("Dynamic pad created, linking demuxer/decoder\n"); sinkpad = gst_element_get_static_pad (decoder, "sink"); gst_pad_link (pad, sinkpad); gst_object_unref (sinkpad); } int main (int argc, char *argv[]) { GMainLoop *loop; GstElement *pipeline, *source, *demuxer, *decoder, *conv, *sink; GstBus *bus; guint bus_watch_id; /* Initialisation */ gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* Check input arguments */ if (argc != 2) { g_printerr ("Usage: %s <Ogg/Vorbis filename>\n", argv[0]); return -1; } /* Create gstreamer elements */ pipeline = gst_pipeline_new ("audio-player"); source = gst_element_factory_make ("filesrc", "file-source"); //用于连接文件 demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer"); //分离器 decoder = gst_element_factory_make ("vorbisdec", "vorbis-decoder"); //解码器 conv = gst_element_factory_make ("audioconvert", "converter"); //转换器 sink = gst_element_factory_make ("autoaudiosink", "audio-output"); //接收器 if (!pipeline || !source || !demuxer || !decoder || !conv || !sink) { g_printerr ("One element 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", argv[1], NULL); /* we add a message handler */ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); bus_watch_id = 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, demuxer, decoder, conv, sink, NULL); /* we link the elements together */ /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -> alsa-output */ gst_element_link (source, demuxer); gst_element_link_many (decoder, conv, sink, NULL); g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), decoder); /* 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", 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); return 0; } |
编译 gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-1.0),运行...
Continue reading...