English 中文(简体)
灰尘处理或os。 收养制度
原标题:Python subprocess or os.system not working with ffmpeg

我正试图从昨天晚上开始这一收入方案,似乎无法得到任何工作。 我想首先播放录像,然后转播录像。 我读了哪部录像和什么从文字档案中给出最后名字,180多条线长,几部录像。

迄今为止,与太阳下的每一想法一样,我尝试过、分处理和系统,我只能收到错误陈述,或者说,现在我拿不出任何档案。 我如何正确工作?

import ffmpeg
import subprocess
import os

os.chdir( /home/Downloads/SRs/ )
a = open( SRt.txt ,  r )
b = a.readlines()
a.close()
for c in range(0, len(b)-1):
    words = list(b[c].split(" "))
    d = len(words)
    e = words[d-1]
    f = b[c].replace(e,  FR  + str(c) +  .mp4 )
    words[d-1] =  FR  + str(c) +  .mp4 
    print(f)
    subprocess.call(f, shell=True)
    subprocess.call([
         ffmpeg ,
         -i ,
        " FR  + str(c) +  .mp4 ",
         -vf scale=320:240 ,
        words[d-1],
        ])

下面是原始档案所想的例子:

 ffmpeg -i SR.mp4 -ss 00:00:00 -to 00:01:22 -c:v copy -a copy CPH.mp4
 ffmpeg -i SR.mp4 -ss 00:01:24 -to 00:02:58 -c:v copy -a copy CG.mp4
 ffmpeg -i SR.mp4 -ss 00:02:59 -to 00:05:41 -c:v copy -a copy CSGP.mp4

没有什么东西只是把视频分开,然后在转播之前加以挽救。

我尝试:

z=subprocess.call(f, shell=True, stdout=subprocess.PIPE)
print(z)

但我得到的是1人。

当我改为:

z=subprocess.call(f, shell=True, stderr=subprocess.PIPE)
print(z)

我得到的是1人。

也许我做的是错事。

问题回答

根据我如何理解你的问题,我在这里提出什么。 我的系统没有安装刺.,我也没有任何录像来测试,因此我评论了<条码>分程序.run(<>。 所有这一切都是为了将文字档案中的界线从<代码>SRtxt变成你可以援引的指令。

with open("SRt.txt") as stream:
    for line_number, line in enumerate(stream):
        # line_number=0 for line 1,
        # line_number=1 for line 2, ...

        command = line.split()

        # Last file name is tokens[-1]
        command[-1] = f"SR{line_number}.mp4"

        # Insert -vf scale=320:240
        command[-2:-1] = ["-vf", "scale=320:240"]

        print(line, end="")
        print(command)
        print()
        # subprocess.run(command, shell=True)

我的样本内容

ffmpeg -i SR.mp4 -ss 00:00:00 -to 00:01:22 -c:v copy -a copy CPH.mp4
ffmpeg -i foo.mp4 -ss 00:01:24 -to 00:02:58 -c:v copy -a copy CG.mp4
ffmpeg -i bar.mp4 -ss 00:02:59 -to 00:05:41 -c:v copy -a copy CSGP.mp4

Output:

ffmpeg -i SR.mp4 -ss 00:00:00 -to 00:01:22 -c:v copy -a copy CPH.mp4
[ ffmpeg ,  -i ,  SR.mp4 ,  -ss ,  00:00:00 ,  -to ,  00:01:22 ,  -c:v ,  copy ,  -a ,  -vf ,  scale=320:240 ,  SR0.mp4 ]

ffmpeg -i foo.mp4 -ss 00:01:24 -to 00:02:58 -c:v copy -a copy CG.mp4
[ ffmpeg ,  -i ,  foo.mp4 ,  -ss ,  00:01:24 ,  -to ,  00:02:58 ,  -c:v ,  copy ,  -a ,  -vf ,  scale=320:240 ,  SR1.mp4 ]

ffmpeg -i bar.mp4 -ss 00:02:59 -to 00:05:41 -c:v copy -a copy CSGP.mp4
[ ffmpeg ,  -i ,  bar.mp4 ,  -ss ,  00:02:59 ,  -to ,  00:05:41 ,  -c:v ,  copy ,  -a ,  -vf ,  scale=320:240 ,  SR2.mp4 ]

注:如果您不希望-vf比 =320:240,则部分评论





相关问题
Encode an Array of Images into a movie file? (iPhone)

My app takes time-lapse photos, and also records audio to go with it. The problem is, I have absolutely no idea how to go about turning it into a .mov/.mpeg file (I am new to this type of iPhone ...

How to use FFmpeg

I m trying to extract frames from a video and I ve picked ffmpeg ( tell me if you know something better ) for this task. I ve downloaded its source and don t know how to use it ?? how can I compile it?...

stitching videos together using ffmpeg on the command line

Does anybody know how to stitch two (or more) videos together using ffmpeg (or another cli)? This is assuming that all the videos are in the same format and the video format being used allows for ...

Using FFmpeg or wrapper to get mp3 from mp4 in C#

I m trying to extract an mp3 from a flash compatible mp4 file and have so far found FFMpeg and a bunch of different wrappers that all claim to be able to do the job. Ideally, I d like to not have to ...

Convert a video to MP4 (H.264/AAC) with ffmpeg

If I don t make a mistake, Safari currently need MP4 (H.264/AAC) video encoded for the HTML5 <video> element. So I tried to convert a video to this format with ffmpeg. However when I enter the ...

calculating filesize of a response?

im tryingto code a script to do dynamic transcoding of video and audio (likely just audio for now) and streaming to mobile devices, currently im using the script posted elsewhere on here (How do you ...

C# and FFmpeg preferably without shell commands?

I d like to be able to use FFmpeg to convert a video file from within my C# program. I know I can just call a shell command, but is there a better way? The issue with invoking a command via the ...

convert movie file to bitmap files with DirectShow

I want to convert movie files like AVI, MOV etc. to Bitmap-Files, like JPEG, JPEG2000, TIFF etc. Is it possible to realize that with DirectX / DirectShow? Is AVCodec from ffmpeg the much more better ...

热门标签