基于CSDN完成TEASOFT的MOOC编辑整理

举报
tsinghuazhuoqing 发表于 2022/03/14 00:22:37 2022/03/14
【摘要】 简 介: CSDN平台中的Markdown编辑器具有多媒体(很可惜没有音频,视频存储)的存储编辑能力。这样对于TEASOFT软件制作视频所需要的文字、图片、多媒体等文件,在CSDN的Markdo...

简 介: CSDN平台中的Markdown编辑器具有多媒体(很可惜没有音频,视频存储)的存储编辑能力。这样对于TEASOFT软件制作视频所需要的文字、图片、多媒体等文件,在CSDN的Markdown文件以及Nutdisk中的MicroVideo目录的联合存储。便可以对视频文档的准备进行网络联合制作,加速制作过程。

关键词 csdnteasoftmooc

背景介绍
目 录
Contents
录制所需要的资源
资源存储于应用
资源汇总
文字资源
动图资源
多媒体资源
相关命令
gif2mpg
mpeg2gif
dopaste
总 结

 

§00 景介绍

  利用TEASOFT教学软件可以进行MOOC课程视频拍摄资源整理。一方面可以利用CSDN的Markdown编辑将所需要制作视频的脚本资源进行规划,同时也将所需要的资源进行汇总存储。

  下面就利用CSDN文档完成TEASOFT 慕课视频拍摄资源汇总相关的方法进行整理。

0.1 录制所需要的资源

  根据 微视频制作方法与要素 对于需要准备的资料包括有以下种类:

  • 内容的逻辑层,显示了内部逻辑关联 与 因果关系;
  • 文字和语言:除了多数的标题之外,就是视频中的Caption。
  • 用于细节展示所使用到的多媒体资源:
    • 图片;
    • 动图;
    • 视频;
    • 音效;

0.2 资源存储于应用

0.2.1 资源的存储

  关于内容的逻辑,通过利用关系图、思维导图、表格、图形、公式以及标题文字组成。这部分内容主要承载在TEASOFT的DOP文件中。最终在Markdown中进行集中展示;

  对于文字和解说语言则使用Markdown内的注释语言进行。

这是用于视频内语言文本对应的存在的格式。

  关于图片、动图(尺寸小于5M字节)可以存储于Markdown文档中。关于视频、音效等则存储在:

  • D盘下的Nutdisk的 MicroVideo子目录

  除此之外,可以将搜索到的所用的资源在网络上的连接进行存储。在正式合成的过程中再进行下载。

0.2.2 资源的导入

  文件的导数包括:

  • 将文本设置TEASOFT的每一步的解说备注中;
  • 将图片、动图、AVI导入TEASOFT的背景图片和动图;
  • 将音乐盗图TEASOFT的音乐打开指令中。

 

§01 源汇总


  源汇总包括有如何将资源进行存储以及如何将存储资源导入TEASOFT两方面内容。

1.1 文字资源

1.1.1 文本存储

  文本,作为解说词的文本存储在Markdown文档中,与正常的编辑过程是一致的。

这是一个测试的解说词的文本,存储于一个Action中的解说词。
产生一个新的NULLAction,完成解说词的定义。

可能带来的问题是什么? 这应该是自然过渡到下一个Action的解说磁。

1.1.2 文本的使用

  也就是将编辑CSDN中的文档添加到Action的注解中。使用MemoForm中的命令:

  • Record - PasteClipboard - WMF-PY-HELP
  • 使用 dopaste命令

  修改:现在TEASOFT软件还存在一定的问题:

  • 自动过滤">"
  • 按照相邻 > 产生NULL, 不相邻的 > 则自动过渡到下一个HELP中。
  • 当第一个ActionPoint==-1的时候,好像是增加的NULL,

1.1.3 清除所有帮助信息

  利用AcitonForm中的 Help按钮,使用 CONTROL+SHIFT 点击HELP 按钮(右上角第二个),便可以清除所有帮助信息以及NULLAction。

1.2 图片、动图资源

1.2.1 图片、动图存储

  将所需要的图片存储在Markdown只要使用正常的 cdpp,csdnpp指令即可,便可以将图片存储Markdown中。

  注意: 在粘贴这在图片的过程中不能够添加图片注释。也就是只能够添加图片的尺寸。

1.2.2 图片、动图使用

  这里有三种方法,分别如下。

(1)图片、动图拷贝

  使用鼠标右键,获得图片拷贝,然后TEASOFT粘贴剪切板最终加入Action的背景图片。

(2)图片地址拷贝

  使用鼠标右键,获得图片的地址。然后使用命令csdnpp * ,便可以将图片加入Action背景图片。

(3)利用dopaste粘贴

  这个命令可以将文字、图片,动图,视频都进行粘贴。这是一个直接从Markdown编辑器中将资源粘贴到TEASOFT中的Action方法。

1.3 多媒体资源

1.3.1 多媒体存储

  多媒体资源包括有:MPEG(相当于GIF),AVI,MP3,WAV,它们无法直接存储在

  利用指令: gif2mpg 将录制的GIF转换成MPEG,并拷贝到 MicroVideo中备用。

  • gif2mpg * : 转换完之后,将第一张图片添加到 Markdown中;
  • gif2mpg + : 只是将MicroVideo中的文件名称添加到Markdown中;
  • gif2mpg . : 将 d:\temp中的 1.avi, 1.MP3, 2.wav 移动到 MicroVideo中,并将文件名称添加到Markdown中。

(1)按照文字截取动图

  根据解说词语的长度,截取对应的动图。通过以下两步:

  • 将解说文字拷贝到剪切板;或者拷贝到ClearClipboardBackupString中。
  • 利用Record命令中的 GIF-》Freeze完成图片的截取。

  或者利用 Screen 中的 Capture GIF 命令。

  • 直接执行:采集GIF;
  • CONTROL: 采集GIF,并运行 gif2mpeg
  • MENU:copy CSDN中的选择字符,采集GIF 并运行 gif2mpeg.

  修改:在CaptureGIF中,对于Shift 命令,直接返回。

1.3.2 多媒体使用

(1)形成Action

  将Markdown中的资源进行拷贝。利用 dopaste 命令完成资源到TEASOFT的转换。

GM1646997029_972_607.MPG
  将Markdown中的资源进行拷贝。利用 dopaste 命令完成资源到TEASOFT的转换。

(2)解压缩MPEG

  对于所有的MPEG文件,在使用前利用 mpeg2gif 进行解压缩,生成BMP文件,便可以在播放的时候形成快速播放。

 

§02 关命令


  面给出进行整理和编辑过程中所用到一些命令。

2.1 gif2mpg

  将采集到的gif2文件转换成mpeg,并进行存储。

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# GIF2MPG.PY                     -- by Dr. ZhuoQing 2020-02-21
#
#   gif2mpg *                       # Change to microvideo
#   gif2mgp +                       # 
#   gif2mpg .                       # Move d:\temp\1.avi to MicroVideo
#                                   # move 1.wav, 1.mp3 to MicroVideo
#
#
# Note:
#============================================================

from head import *
import shutil

import cv2
import numpy as np
import glob

from io import BytesIO
import win32clipboard
#------------------------------------------------------------

csdn_title = '写文章-CSDN博客'
#------------------------------------------------------------
microvideo_dir = r'd:\Nutdisk\MicroVideo'
microvideo_flag = 0
numstr = 'GM%d'%(int(time.time()))

#------------------------------------------------------------
def send_to_clipboard(clip_type, data):
    win32clipboard.OpenClipboard()
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardData(clip_type, data)
    win32clipboard.CloseClipboard()

#------------------------------------------------------------
img_array = []
size = (100, 100)
mpegfile = []
microvideo_flag = 0
avimove_flag = 0

#------------------------------------------------------------
if len(sys.argv) > 1:
    if sys.argv[1] == '*':
        microvideo_flag = 1
    if sys.argv[1] == '+':
        microvideo_flag = 2
    if sys.argv[1] == '.':
        avimove_flag = 1

#------------------------------------------------------------
if microvideo_flag > 0:
    gifiddim = tspgetgifid()
    if len(gifiddim) == 0:
        printf('DOP has no GIF dop .\a')
        exit()

    #------------------------------------------------------------
    outfile = numstr

    frameps = 25
    #------------------------------------------------------------
    for gifid in gifiddim:
        filedir = tspgetdoppath(gifid)
        gifpage = tspgetgifpage(gifid)
        filename = tspgetdopfile(gifid)
        nameonly, ext = os.path.splitext(filename)

        for i in range(gifpage):
            filename = os.path.join(filedir, '%04d%s'%(i, ext))
            img = cv2.imread(filename)
            mpegfile.append(filename)

            height,width,layers=img.shape
            size = (width, height)
            img_array.append(img)


    tspdeletedop(gifiddim)
    tsprv(-1)

    #--------------------------------------------------------
    filename = '%s_%d_%d.MPG'%(outfile, width, height)
    outfilename = os.path.join(microvideo_dir, filename)

    out = cv2.VideoWriter(outfilename, cv2.VideoWriter_fourcc(*'MPEG'), frameps, size, True)
    for id,img in enumerate(img_array):
        out.write(img)
        tspshowinfor('%d '%id)

    out.release()

    if microvideo_flag == 2:
        clipboard.copy(filename + '\n')
        tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)
    else:

        tspsendwindowkey(csdn_title,"c", control=1, noreturn=1)
        originstr = clipboard.paste()
        if len(originstr) > 0:
            tspsendwindowkey(csdn_title, " ")

        #----------------------------------------------------
        image = Image.open(mpegfile[0])
        output = BytesIO()
        image.convert('RGB').save(output, 'BMP')
        data = output.getvalue()[14:]
        output.close()
        send_to_clipboard(win32clipboard.CF_DIB, data)

        tspsendwindowkey(csdn_title, 'v', control=1, noreturn=1)

        for i in range(40):
            time.sleep(.5)
            readdata = tspread()

            if readdata[2] == 1: break
            if readdata[7] != 0: break
            if readdata[8] != 0: exit()
            if readdata[9] != 0: exit()

            tspsendwindowkey(csdn_title, 'c', control=1, noreturn=1)
            if clipboard.paste().find('在这里插入图片描述') >= 0:
                tspbeep(1500, 200)
                time.sleep(.25)
                break


            printf('\a')

        for i in range(20):
            readdata = tspread()

            if readdata[7] == 0 and readdata[8] == 0 and readdata[9] == 0: break

            tspbeep(2500, 15)
            time.sleep(.25)


        tspsendwindowkey(csdn_title, 'ac', control=1, noreturn=1)

        pastestr = clipboard.paste().split('![在这里插入图片描述](')

        if len(pastestr) < 2:
            printf("Can not find the ![Insert picture] discriptor !\a")
            exit()

        tspsendwindowkey(csdn_title, 'z', control=1)
        pastestr = pastestr[1].split(')')[0]
        pastestr = pastestr.split('?')[0]

        insertstr = '![%s](%s#pic_center =320x)'%(filename,pastestr)
        clipboard.copy(insertstr+'\n'+originstr)
        tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)

#        printf(pastestr)
        clipboard.copy("")

    exit()


#------------------------------------------------------------
def avi2csdn(filename, newfile):
    cam = cv2.VideoCapture(filename)
    ret, frame = cam.read()
    cv2.imwrite(r'd:\temp\1.bmp', frame)
    image = Image.open(r'd:\temp\1.bmp')

    output = BytesIO()
    image.convert('RGB').save(output, 'BMP')
    data = output.getvalue()[14:]
    output.close()
    send_to_clipboard(win32clipboard.CF_DIB, data)

    tspsendwindowkey(csdn_title, 'v', control=1)
    cam.release()

    for i in range(40):
        time.sleep(.5)
        readdata = tspread()

        if readdata[2] == 1: break
        if readdata[7] != 0: break
        if readdata[8] != 0: exit()
        if readdata[9] != 0: exit()

        tspsendwindowkey(csdn_title, 'c', control=1, noreturn=1)
        if clipboard.paste().find('在这里插入图片描述') >= 0:
            tspbeep(1500, 200)
            time.sleep(.25)
            break


        printf('\a')

    for i in range(20):
        readdata = tspread()

        if readdata[7] == 0 and readdata[8] == 0 and readdata[9] == 0: break

        tspbeep(2500, 15)
        time.sleep(.25)


    tspsendwindowkey(csdn_title, 'ac', control=1, noreturn=1)

    pastestr = clipboard.paste().split('![在这里插入图片描述](')

    if len(pastestr) < 2:
        printf("Can not find the ![Insert picture] discriptor !\a")
        exit()

    tspsendwindowkey(csdn_title, 'z', control=1)
    pastestr = pastestr[1].split(')')[0]
    pastestr = pastestr.split('?')[0]

    insertstr = '![%s](%s#pic_center =200x)\n'%(newfile, pastestr)
    clipboard.copy(insertstr)
    tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)

    os.remove(r'd:\temp\1.bmp')

#------------------------------------------------------------
avifile = r'd:\temp\1.avi'
wavfile = r'd:\temp\1.wav'
mp3file = r'd:\temp\1.mp3'

avinumstr = 'AV%d'%(int(time.time()))
wavnumstr = 'WA%d'%(int(time.time()))
mp3numstr = 'MP%d'%(int(time.time()))

if avimove_flag > 0:
    if os.path.isfile(avifile):
        newfile = os.path.join(microvideo_dir, '%s.AVI'%avinumstr)
        shutil.copy(avifile, newfile)
        avi2csdn(avifile, '%s.AVI'%avinumstr)
        os.remove(avifile)

    if os.path.isfile(wavfile):
        filename = '%s.WAV'%wavnumstr
        newfile = os.path.join(microvideo_dir, filename)
        shutil.copy(wavfile, newfile)
        clipboard.copy(filename + '\n')
        printf("Copy file : %s"%filename)
        tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)
        os.remove(wavfile)

    if os.path.isfile(mp3file):
        filename = '%s.MP3'%mp3numstr
        newfile = os.path.join(microvideo_dir, filename)
        shutil.copy(mp3file, newfile)
        clipboard.copy(filename + '\n')
        printf("Copy file : %s"%filename)
        tspsendwindowkey(csdn_title, "v", control=1, noreturn=1)
        os.remove(mp3file)


    printf('\a')

    exit()

#------------------------------------------------------------
if len(sys.argv) == 7:
    filename, ext = os.path.splitext(sys.argv[1])
    filedir = os.path.dirname(sys.argv[1])
    gifpage = int(sys.argv[2])

    outfile = r'd:\temp\%s_%s_%s'%(sys.argv[5], sys.argv[3], sys.argv[4])

    framems = int(sys.argv[6])
    frameps = int(1000 / framems)

    printff(filedir, ext, outfile, gifpage, frameps)

    for i in range(gifpage):
        filename = os.path.join(filedir, '%04d%s'%(i, ext))
        img = cv2.imread(filename)
        mpegfile.append(filename)

        height,width,layers=img.shape
        size = (width, height)
        img_array.append(img)


else:
    gifiddim = tspgetgifid()
    if len(gifiddim) == 0:
        printf('DOP has no GIF dop .\a')
        exit()

    #------------------------------------------------------------
    outfile = 'GM'
    if len(sys.argv) > 1:
        outfile = sys.argv[1]

    frameps = 25
    if len(sys.argv) > 2:
        framems = int(sys.argv[2])
        frameps = int(1000 / framems)


    #------------------------------------------------------------
    for gifid in gifiddim:
        filedir = tspgetdoppath(gifid)
        gifpage = tspgetgifpage(gifid)
        filename = tspgetdopfile(gifid)
        nameonly, ext = os.path.splitext(filename)

        for i in range(gifpage):
            filename = os.path.join(filedir, '%04d%s'%(i, ext))
            img = cv2.imread(filename)
            mpegfile.append(filename)

            height,width,layers=img.shape
            size = (width, height)
            img_array.append(img)


#------------------------------------------------------------
#printf(filedir)

#img_array = []
#for i in range(gifpage):
#    filename = os.path.join(filedir, '%04d%s'%(i, ext))
#    img = cv2.imread(filename)

#    height,width,layers=img.shape
#    size = (width, height)
#    img_array.append(img)

#------------------------------------------------------------

outfilename = r'd:\temp\%s_%d_%d.MPG'%(outfile, width, height)
if outfile.find(':') > 0:
    outfilename = r'%s.MPG'%(outfile)

out = cv2.VideoWriter(outfilename, cv2.VideoWriter_fourcc(*'MPEG'), frameps, size, True)

#------------------------------------------------------------
if not os.path.isdir(r'd:\temp'):
    os.mkdir(r'd:\temp')

if not os.path.isdir(r'd:\temp\GIF'):
    os.mkdir(r'd:\temp\GIF')

if not os.path.isdir(r'd:\temp\GIF\MPEG'):
    os.mkdir(r'd:\temp\GIF\MPEG')

mpegdir = r'd:\temp\GIF\MPEG'
mpegfiledim = os.listdir(mpegdir)
for f in mpegfiledim:
    os.remove(os.path.join(mpegdir, f))


#------------------------------------------------------------
#for i in range(gifpage):
#    out.write(img_array[i])
#    tspshowinfor('%d '%i)

for id,img in enumerate(img_array):
    out.write(img)
    tspshowinfor('%d '%id)

    newfile = os.path.join(mpegdir, os.path.basename(mpegfile[id]))
#    printf(newfile)
    shutil.copyfile(mpegfile[id], newfile)


out.release()

#------------------------------------------------------------
printf('\r\nAVI:%s\a'%outfilename)
printf('\a')


#------------------------------------------------------------
#        END OF FILE : GIF2MPG.PY
#============================================================

  
 
  • 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
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382

2.2 mpeg2gif

  将所有的mpeg文件解压缩成gif

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# MPEG2GIF.PY                     -- by Dr. ZhuoQing 2021-09-16
#
#  mpeg2gif 0{1}                    # 1:JPEG, 0:BMP(default)
#  mpeg2gif c{-}                    # Clear the origin
#  mpeg2gif a,g,*                   # Convert mpeg and gif all
#
#
# Note:
#============================================================

from headm import *
import cv2
import shutil
from PIL import Image
import sys

#------------------------------------------------------------
jpegflag = 0
cleardirflag = 0
allflag = 0


#------------------------------------------------------------
if len(sys.argv) > 1:
    for a in sys.argv[1:]:
        if a.isdigit():
            jpegflag = int(a)
        elif a == 'c' or a == '-':
            cleardirflag = 1
        elif a == 'a' or a == 'g' or a == '*':
            allflag = 1

#------------------------------------------------------------
dopfile = tspgetdoppath()
allfile = list(os.walk(dopfile))

mpgfile = []
giffile = []
for a in allfile:
    if len(a[2]) > 0:
        for f in a[2]:
            ext = f.split('.')[-1]
            if ext == 'mpg' or ext == 'MPG':
                if f.count('_') == 2:
                    fname = os.path.join(a[0], f)
                    printf(fname)
                    mpgfile.append(fname)

            if ext == 'gif' or ext == 'GIF':
                fname = os.path.join(a[0], f)
                printf(fname)
                giffile.append(fname)



#------------------------------------------------------------

try:
    if not os.path.exists(r'd:\temp'):
        os.makedirs(r'd:\temp')
    if not os.path.exists(r'd:\temp\GIF'):
        os.makedirs(r'd:\temp\GIF')
except OSError:
    printf("Error :Creating directory of data.")

#------------------------------------------------------------
def mpeg2picture(mpegfile, outdir, jpegflag=0):
    cam = cv2.VideoCapture(mpegfile)
    printf(mpegfile)
    currentframe = 0
    while True:
        ret, frame = cam.read()

        tspshowinfor('%04d '%currentframe)

        if ret:
            if jpegflag == 0:
                filename = '%04d.BMP'%currentframe
            else:  filename = '%04d.JPG'%currentframe

            outfile = os.path.join(outdir, filename)

            cv2.imwrite(outfile, frame)
            currentframe += 1
        else:
            break

    cam.release()

    printf(' ')

#------------------------------------------------------------
def gif2picture(gifile, outdir, jpegflag=0):
    try:
        im = Image.open(gifile)
    except IOError:
        printf("Can not load %s ."%gifile)
        sys.exit()

    i = 0
    mypalette = im.getpalette()

    try:
        while True:
            im.putpalette(mypalette)
            new_im = Image.new("RGB", im.size)
            new_im.paste(im)

            tspshowinfor('%04d '%i)
            if jpegflag == 0:
                savefile = os.path.join(outdir, '%04d.BMP'%i)
            else: savefile = os.path.join(outdir, '%04d.JPG'%i)
            new_im.save(savefile)

#            printf(savefile)

            i += 1
            im.seek(im.tell() + 1)

    except EOFError:
        pass        # end of sequence
                    #

    printf(' ')

#------------------------------------------------------------
for f in mpgfile:
    fonly = os.path.basename(f).split('.')[0]
    printf(fonly)

    outdir = os.path.join(r'd:\temp\GIF', fonly)
    if not os.path.exists(outdir):
        os.makedirs(outdir)
        mpeg2picture(f, outdir, jpegflag)
    elif cleardirflag != 0:
        shutil.rmtree(outdir)
        printf(outdir)
        os.makedirs(outdir)
        mpeg2picture(f, outdir, jpegflag)

#------------------------------------------------------------
if allflag != 0:
    for f in giffile:
        fonly = os.path.basename(f).split('.')[0]
        printf(fonly)

        outdir = os.path.join(r'd:\temp\GIF', fonly)
        if not os.path.exists(outdir):
            os.makedirs(outdir)
            gif2picture(f, outdir, jpegflag)
        elif cleardirflag != 0:
            shutil.rmtree(outdir)
            printf(outdir)
            os.makedirs(outdir)
            gif2picture(f, outdir, jpegflag)


#------------------------------------------------------------
printf('\a')

#------------------------------------------------------------
#        END OF FILE : MPEG2GIF.PY
#============================================================

  
 
  • 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
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166

2.3 dopaste

  CSDN 资源到 TEASOFT Action添加。

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# DOPASTE.PY                     -- by Dr. ZhuoQing 2021-10-07
#
# Note:
#============================================================

from head import *
import urllib.request
from PIL                    import Image

csdn_title = '写文章-CSDN博客'


#------------------------------------------------------------
outdir = r'd:\temp'
microvideo_dir = r'd:\Nutdisk\MicroVideo'


#------------------------------------------------------------
strall = clipboard.paste().split('\n')
tspsendwindowkey(csdn_title, "c", control=1, noreturn=1)

csdnall = clipboard.paste()
if len(csdnall) > 0:
    strall = csdnall.split('\n')

#------------------------------------------------------------
for s in strall:
    s = s.strip(' ')

    if s[:1] == '>':
        continue

#    if len(s) == 0: continue

    endid = s.find('#pic_center')
    startid = s.find('![](')
    mpgid = s.find('.MPG]')
    aviid = s.find('.AVI]')



    #--------------------------------------------------------
    printf(mpgid)

    if endid >= 0 and startid >= 0:
        picurl = s[startid+4:endid]

        ext = picurl.split('.')[-1]
        filename = picurl.split('/')[-1].split('.')[0]

        outfile = ''
        if ext == 'gif':
            outfile = os.path.join(outdir, '%s.gif'%filename)
            urllib.request.urlretrieve(picurl, outfile)
            tspacceptfile(outfile, 99)
            printf(outfile)
            os.remove(outfile)
        elif ext == 'png':
            outfile = os.path.join(outdir, '%s.png'%filename)
            urllib.request.urlretrieve(picurl, outfile)
            im1 = Image.open(outfile)

            if len(im1.split()) == 4:
                r,g,b,a = im1.split()
                im1 = Image.merge('RGB', (r,g,b))

            newfile = os.path.join(outdir, '%s.JPG'%filename)
            im1.save(newfile)

            os.remove(outfile)
            tspacceptfile(newfile, 0)
            os.remove(newfile)
            printf(newfile)
        else: continue

    elif s[:2] == '![' and mpgid > 0:
        s = s[2:mpgid+4]
        mpegfile = os.path.join(microvideo_dir, s)
        tspacceptfile(mpegfile, 99)
        printf(mpegfile)

    elif s[:2] == '![' and aviid > 0:
        s = s[2:aviid+4]
        avifile = os.path.join(microvideo_dir, s)
        tspacceptfile(avifile, 99)
        printf(avifile)

    else:
        if s.find('.MPG') >= 0 and s.find('#') < 0:
            mpegfile = os.path.join(microvideo_dir, s)
            tspacceptfile(mpegfile, 99)
            printf(mpegfile)
        elif s.find('.MP3') >= 0 and s.find('#') < 0:
            audiofile = os.path.join(microvideo_dir, s)
            tspacceptfile(audiofile, 99)
            printf(audiofile)
        elif s.find('.WAV') >= 0 and s.find('#') < 0:
            audiofile = os.path.join(microvideo_dir, s)
            tspacceptfile(audiofile, 99)
            printf(audiofile)
        else:
            if s.find('http:') < 0:
                tspcopystring(s)
            printf(s)


#------------------------------------------------------------
printf('\a')

#------------------------------------------------------------
#        END OF FILE : DOPASTE.PY
#============================================================

  
 
  • 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

 

  结 ※


  CSDN平台中的Markdown编辑器具有多媒体(很可惜没有音频,视频存储)的存储编辑能力。这样对于TEASOFT软件制作视频所需要的文字、图片、多媒体等文件,在CSDN的Markdown文件以及Nutdisk中的MicroVideo目录的联合存储。便可以对视频文档的准备进行网络联合制作,加速制作过程。


■ 相关文献链接:

文章来源: zhuoqing.blog.csdn.net,作者:卓晴,版权归原作者所有,如需转载,请联系作者。

原文链接:zhuoqing.blog.csdn.net/article/details/123429100

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200