小编Cyp*_*ase的帖子

Python子进程中的ffmpeg - 无法为'pipe:'找到合适的输出格式

尝试通过Python使用ffmpeg将sub刻录成视频.在命令行中工作正常,但是从Python子进程调用时:

p = subprocess.Popen('cd ~/Downloads/yt/; ffmpeg -i ./{video} -vf subtitles=./{subtitles} {out}.mp4'.format(video=vid.replace(' ', '\ '), subtitles=subs, out='out.mp4'), shell=True)
Run Code Online (Sandbox Code Playgroud)

我明白了:

Unable to find a suitable output format for 'pipe:'
Run Code Online (Sandbox Code Playgroud)

完全追溯:

'ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libvpx --enable-libass --enable-libfdk-aac --enable-nonfree --enable-vda
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / …
Run Code Online (Sandbox Code Playgroud)

python subprocess ffmpeg

6
推荐指数
1
解决办法
3910
查看次数

你如何在python中将sql的输出写入csv文件

我正在尝试连接到oracle表并执行sql.我需要将结果集导出到csv文件.我的代码如下:

import pyodbc
import csv

cnxn = pyodbc.connect("DSN=11g;UID=test101;PWD=passwd")
cursor = cnxn.cursor()
cursor.execute(sql)
row = cursor.fetchall()
with open('data.csv', 'w', newline='') as fp:
    a = csv.writer(fp, delimiter=',')
    for line in row:
        a.writerows(line)

cursor.close()
Run Code Online (Sandbox Code Playgroud)

当我在for循环中打印到行时,我得到这样的东西:

('Production', 'farm1', 'dc1prb01', 'web')
('Production', 'farv2', 'dc2pr2db01', 'app.3')
('Production', 'farm5', 'dc2pr2db02', 'db.3')
Run Code Online (Sandbox Code Playgroud)

这不起作用.我可能会缺少什么想法?

python

3
推荐指数
1
解决办法
4361
查看次数

查看*any*字符是否在字符串中并删除它们

所以我在Python 3中有一个简单的程序,它只是一个基本的计算器.这是一段代码:

calculation = input("What calculation do you want to do?\n")
if "+" in calculation:
    numbers = calculation.split("+")
    answer = int(numbers[0]) + int(numbers[1])
Run Code Online (Sandbox Code Playgroud)

我下面还有其他一些操作设置.问题是如果有人要输入任何东西以及操作(例如10 ++ 2或10 + abc2),代码会抛出错误,因为它显然无法向abc2添加10.

我认为我可以通过测试每个角色来解决问题,但肯定这是一个很长的路要走.有没有办法用Python解决问题?

python string

2
推荐指数
1
解决办法
91
查看次数

标签 统计

python ×3

ffmpeg ×1

string ×1

subprocess ×1