Screen grab with ffmpy - python

I'm trying to screen record a section of my screen using ffmpy. But I keep getting an error.
ffmpy.FFRuntimeError: ffmpeg -f gdigrab -framerate 30 -offset_x 303 -offset_y 230 -video_size 1319x865 -i desktop -c:v libx264 -preset ultrafast output.mp4 exited with status 1 STDOUT: STDERR:
Here is my code.
from ffmpy import FFmpeg
left = 303
top = 230
width = 1319
height = 865
input_str = "-f gdigrab -framerate 30 -offset_x {} -offset_y {} -video_size {}x{}".format(left, top, width, height)
output_str = "desktop -c:v libx264 -preset ultrafast output.mp4"
ff = FFmpeg("ffmpeg", "{} -i {}".format(input_str, output_str))
ff.run()
Not sure why it's complaining, the output command listed in the error, works if I copy paste it into a cmd, I'm looking at ffmpy because later I'm going to get left,top,width,height calculated as the script starts.

Related

FFMPEG Frame-exact Video Cropping

Goal: To crop a video at a specific frame using FFMPEG
Problem: Video freezes at the end for ~1s
I'm new to FFMPEG, so not sure if any other details are needed to debug this.
import subprocess
import datetime
# Calculate start and end times in hh:mm:ss.ms
start_frame, end_frame = (9553, 10181)
start_time = str(datetime.timedelta(seconds=start_frame/fps))
end_time = str(datetime.timedelta(seconds=end_frame/fps))
cmd = ['ffmpeg', '-y', '-ss', start_time, '-to', end_time, '-i', input_path, '-c', 'copy', clip_path]
subprocess.call(cmd)
Values:
Start Frame: 9553
End Frame: 10181
Start Time: 0:06:22.120000
End Time: 0:06:47.240000
You will have to cut on key frames only or remove -c copy and re-encode.

How to preview the ffmpeg command line while using ffmpeg-python

Let's say I implement the following python script that uses ffmpeg-python:
# facetime.py
import ffmpeg
ffmpeg \
.input(
'FaceTime',
format='avfoundation',
pix_fmt='uyvy422',
framerate=30
) \
.output(
'out.mp4',
pix_fmt='yuv420p',
vframes=100
) \
.run()
Is there a mechanism to print to the stdout the corresponding ffmpeg command that will be executed?
Found it:
cmd = ffmpeg \
.input(
'FaceTime',
format='avfoundation',
pix_fmt='uyvy422',
framerate=30
) \
.output(
'out.mp4',
pix_fmt='yuv420p',
vframes=100
)
args = cmd.get_args()
print(f'Args: {args}')
Output:
Args: ['-f', 'avfoundation', '-framerate', '30', '-pix_fmt', 'uyvy422', '-i', 'FaceTime', '-pix_fmt', 'yuv420p', '-vframes', '100', 'out.mp4']

python ffmpeg moov atom not found Invalid data when processing input

I have a progress that records the screen, and audio from a microphone, and then combines the video and audio recording (.mp4 and .wav) into one mkv file.
I am using python 3.6 and ffmpeg to achieve this aim. For short videos (<20 sec.) it works, but for longer recordings it presents the following error message:
[mov,mp4,m4a,3gp,3g2,mj2 # 0x55abb3a52540] moov atom not found
tmp/tmp_0.mp4: Invalid data found when processing input
Full output:
ffmpeg version 3.3.7 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --
datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --
incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --
arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,
-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-
buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-
hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables' --extra-
ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --
extra-cflags='-I/usr/include/nvenc ' --enable-libopencore-amrnb --
enable-
libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib
--disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --
enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-
libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --
enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-
opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-
libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --
enable-libtheora --enable-libvorbis --enable-libv4l2 --enable- libvidstab -
-enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --
enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --
disable-static --enable-shared --enable-gpl --disable-debug --disable-
stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
[wav # 0x55abb3a0b880] Ignoring maximum wav data size, file may be invalid
[wav # 0x55abb3a0b880] Estimating duration from bitrate, this may be
inaccurate
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'tmp/tmp_0.wav':
Metadata:
encoder : Lavf57.71.100
Duration: 00:00:21.97, bitrate: 768 kb/s
Stream #0:0: Audio: pcm_mulaw ([7][0][0][0] / 0x0007), 48000 Hz,
stereo, s16, 768 kb/s
[mov,mp4,m4a,3gp,3g2,mj2 # 0x55abb3a52540] moov atom not found
tmp/tmp_0.mp4: Invalid data found when processing input
The python file (ffmpeg.py) is as follows. The class, AV_COMPILE, is not yet complete, held up by the aforementioned error, and therefore still uses the initial test files as defaults. But otherwise it ought to work:
import os, time, glob
TMP_DIR = "tmp"
DISPLAY = os.environ['DISPLAY']
EXT = {
'Video':'mp4',
'Audio':'wav',
'AV':'mkv',
}
class ffmpegVideo:
FFMPEG_BIN = "ffmpeg"
AUDIO = False
def __init__(self, fps = 30, audio = True):
global TMP_DIR, DISPLAY, EXT
self.fps = fps
if audio:
self.AUDIO = True
self.video_filename = self.unique_filename()
self.command = [ self.FFMPEG_BIN,
'-video_size', '1920x1080',
'-framerate', str(fps),
'-f', 'x11grab',
'-i', DISPLAY,
'-vcodec', 'libx264',
'-qp', '0',
'-preset', 'ultrafast',
'-y', TMP_DIR + '/' + self.video_filename
]
def start(self):
import threading as th
thread = th.Thread(target=self.record)
thread.start()
def record(self):
import subprocess as sp
self.pipe = sp.Popen(self.command, stderr=sp.PIPE)
if self.AUDIO:
ffmpegAudio().start()
def stop(self):
self.pipe.terminate()
def unique_filename(self):
global TMP_DIR, EXT
i = 0
while os.path.exists((TMP_DIR + '/' + 'tmp_%s.%s') % (i, EXT['Video'])):
i += 1
return ('tmp_%s.%s') % (i, EXT['Video'])
class ffmpegAudio:
FFMPEG_BIN = "ffmpeg"
def __init__(self):
self.audio_filename = self.unique_filename()
self.command = [ self.FFMPEG_BIN,
'-f', 'pulse',
'-ac', '2',
'-ar', '48000',
'-i', 'default',
'-acodec', 'pcm_mulaw',
'-y', TMP_DIR + '/' + self.audio_filename
]
def start(self):
import threading as th
au_thread = th.Thread(target=self.record)
au_thread.start()
def record(self):
import subprocess as sp
self.pipe = sp.Popen(self.command, stderr=sp.PIPE)
def stop(self):
self.pipe.terminate()
def unique_filename(self):
global TMP_DIR, EXT
i = 0
while os.path.exists((TMP_DIR + '/' + 'tmp_%s.%s') % (i, EXT['Audio'])):
i += 1
return ('tmp_%s.%s') % (i, EXT['Audio'])
class AV_COMPILE:
def __init__(self, au_in = TMP_DIR + '/' + 'out1.wav', vd_in =
TMP_DIR + '/' + 'test4.mp4', out = TMP_DIR + '/' + 'av.mkv'):
import subprocess as sp
au_in = min(glob.iglob(TMP_DIR + '/*.wav'), key=os.path.getctime)
vd_in = min(glob.iglob(TMP_DIR + '/*.mp4'), key=os.path.getctime)
self.command = ('ffmpeg -i %s -r 30 -i %s -shortest -c:a aac -c:v copy %s') % (au_in, vd_in, out)
sp.call(self.command, shell=True)
I would be grateful for any assistance you could provide in understanding why this happens and how to solve the error. Also, I am happy to receive any other tips on how to improve this code, or any other problems anyone might notice.
EDIT:
I now believe that the reason for this error in longer videos, and occasionally shorter, is that the program is proceeding to attempt to compile the av output whether or not it has finished compiling the original video file. I tested a time.sleep(10) function to delay AV_COMPILE, and this seems to work.
However, as video files get larger, obviously the delay needs to be adjusted. So I should like to know how I can separately check the integrity of the video file and determine that it is safe to proceed to the next step.
Regarding moov atom not found well I checked your file and the atom is there, but at the back-end of your file (but it needs to be available first before the rest of the MP4 data can be processed).
MP4 containers are structured in such a way that the a/v data is stored without frame headers and the Moov atom is a table, listing the byte positions and byte lengths for each a/v frame. The Moov atom can only exist after recording is complete when the relevant metadata can now be created for the stored data.
This is why fragmented MP4 was introduced.
Solution:
Don't put your a/v data into an MP4 then transfer same a/v out of the MP4 into a MKV container. I suspect you went with MP4 container setting in order to get output (picture) encoded with H.264 video codec?
I don't use Python but try setting:
'Video':'libx264',
'Audio':'wav',
'AV':'mkv',

how to capture pexpect sendline command output and redirect it to logfile?

When i run the below command manually in shell
[root#Rhel67GA-Valencia ~]# /DPDK2/testpmd -c 3 -n 3 -d /DPDK2/librte_pmd_oce.so -w 0000:01:00.00 -w 0000:01:00.01 -- -i --nb-cores=1 --nb-ports=2
i get the below output on terminal:
COMMAND OUTPUT Beginning:
Port 0: 00:90:FA:30:97:26
Configuring Port 1 (socket 0)
librte_pmd_oce:
oce_pf_dev_rx_start hw_vlan_strip = 0x1
Port 1: 00:90:FA:30:97:2A
Checking link statuses...
Port 0 Link Up - speed 10000 Mbps - full-duplex
Port 1 Link Up - speed 10000 Mbps - full-duplex
Done
testpmd> start <=== USER INPUT ===>
io packet forwarding - CRC stripping disabled - packets/burst=32
nb forwarding cores=1 - nb forwarding ports=2
RX queues=1 - RX desc=128 - RX free threshold=0
RX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX queues=1 - TX desc=512 - TX free threshold=0
TX threshold registers: pthresh=0 hthresh=0 wthresh=0
TX RS bit threshold=0 - TXQ flags=0x0
testpmd> stop <=== USER INPUT ===>
Telling cores to stop...
Waiting for lcores to finish...
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 24 RX-dropped: 0 RX-total: 24
TX-packets: 24 TX-dropped: 0 TX-total: 24
----------------------------------------------------------------------------
---------------------- Forward statistics for port 1 ----------------------
RX-packets: 24 RX-dropped: 0 RX-total: 24
TX-packets: 24 TX-dropped: 0 TX-total: 24
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 48 RX-dropped: 0 RX-total: 48
TX-packets: 48 TX-dropped: 0 TX-total: 48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Done.
testpmd> quit <=== USER INPUT ===>
Stopping port 0...done
Stopping port 1...done
bye...
[root#Rhel67GA-Valencia ~]#
End of COMMAND OUTPUT
When i try to run the same command in python script using pexpect module i dont see any output on the terminal, but the command is executed successfully.
I need to capture the above COMMAND OUTPUT to a logfile.
below is script i am using
sample.py:
cmd = "/DPDK2/testpmd -c 3 -n 3 -d /DPDK2/librte_pmd_oce.so -w 0000:01:00.00 -w 0000:01:00.01 -- -i --nb-cores=1 --nb-ports=2"
child = pexpect.spawn(cmd)
child.expect("testpmd>")
child.sendline('start')
print "\ntestpmd> start \n"
time.sleep(30)
child.sendline('stop')
print "\ntestpmd> stop \n"
child.sendline('quit')
time.sleep(30)
Call child.expect before each call to child.sendline:
child.expect("testpmd>")
child.sendline('start')
child.expect("testpmd>")
child.sendline('stop')
child.expect("testpmd>")
child.sendline('quit')
child.interact()

avconv with subprocess

It's seems like I never really manage to wrap my head around subprocess. This commandline works in bash
avconv -i "concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts" -vcodec copy -acodec copy /tmp/test1.ts
Bu if I try this:
cmdline = ['avconv', '-i "concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts"', '-vcodec copy', '-acodec copy', '/tmp/test1.ts']
subprocess.call(cmdline)
It exit avconv with the following error:
avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:52:09 with gcc 4.6.3
Unrecognized option 'i "concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts"'
Failed to set value '-vcodec copy' for option 'i "concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts"'
1
I've tried some variants (including shell=True) but I can't figure out the problem.
Update
Cjb made an answer that really worked. But my real code is more complicated. I believe it's hard to get something out of it. But I throw it in here just in case there is an obvoius problem that I missed.
def run_avconv(output_dir, fnames):
full_fnames = [os.path.join(output_dir, fname.replace('\n', ''))
for fname in fnames]
concatted_files = '|'.join(full_fnames)
cmd_line = [AVCONV_CMD,
'-i',
'"concat:' + concatted_files + '"',
'-vcodec',
'copy',
'-acodec',
'copy',
os.path.join(output_dir, 'out.ts')]
subprocess.Popen(cmd_line)
the full_fnames variable is:
['/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment2.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment3.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment4.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment5.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment6.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment7.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment8.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment9.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment10.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment11.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment12.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment13.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment14.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment15.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment16.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment17.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment18.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment19.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment20.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment21.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment22.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment23.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment24.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment25.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment26.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment27.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment28.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment29.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment30.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment31.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment32.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment33.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment34.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment35.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment36.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment37.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment38.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment39.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment40.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment41.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment42.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment43.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment44.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment45.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment46.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment47.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment48.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment49.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment50.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment51.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment52.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment53.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment54.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment55.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment56.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment57.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment58.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment59.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment60.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment61.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment62.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment63.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment64.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment65.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment66.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment67.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment68.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment69.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment70.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment71.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment72.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment73.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment74.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment75.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment76.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment77.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment78.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment79.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment80.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment81.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment82.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment83.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment84.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment85.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment86.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment87.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment88.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment89.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment90.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment91.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment92.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment93.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment94.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment95.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment96.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment97.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment98.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment99.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment100.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment101.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment102.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment103.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment104.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment105.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment106.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment107.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment108.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment109.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment110.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment111.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment112.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment113.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment114.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment115.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment116.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment117.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment118.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment119.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment120.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment121.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment122.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment123.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment124.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment125.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment126.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment127.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment128.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment129.ts',
'/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment130.ts']
Try it with this:
cmdline = [
'avconv',
'-i',
'concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts',
'-vcodec',
'copy',
'-acodec',
'copy',
'/tmp/test1.ts',
]
subprocess.call(cmdline)
You really want to pass each separate part as a different item in the list.
The answer by #djc is correct, however if you wanted to work by copying and pasting a string, you can do something like this:
import shlex
from pprint import pprint
cmd = """avconv -i "concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts" -vcodec copy -acodec copy /tmp/test1.ts"""
for_subprocess = shlex.split(cmd)
pprint(for_subprocess)
['avconv',
'-i',
'concat:/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment0.ts|/tmp/BABAR_AND_THE_A-011A-hts-a-v1-cc3651d01841d748_Layer6/6148_Period1/segment1.ts',
'-vcodec',
'copy',
'-acodec',
'copy',
'/tmp/test1.ts']

Categories