[FFmpeg-user] Python / Qprocess misfires commands.
Bouke
bouke at editb.nl
Mon May 17 10:19:46 EEST 2021
> On 16 May 2021, at 15:46, Moritz Barsnick <barsnick at gmx.net> wrote:
>
> On Fri, May 14, 2021 at 13:16:41 +0200, Bouke wrote:
>> Using Python to fire FFmpeg
>> cmd = ‘ffmpeg’
>> args = [‘-f’, ‘avfoundation’, ‘-i’, ‘:0’]
>>
>> with a QProcess, this returns exit code 6, exitstatus 1
>>
>>
>> ffmpeg -f avfoundation -i :0 in a Terminal works.
>> (At least one output file….)
>
> You will have to show/look at the console output of both commands.
> (It's there for a reason, and most likely says what the issue is.)
Hi Moritz,
I know, but there was ’nothing’ on stdErr / stdOut.
It turns out that FFmpeg crashes, nothing wrong with the command line.
QProcess sees an error, and either QProcess terminates FFmpeg (I don’t think so) or FFmpeg crashes by itself.
Strange thing is, the EXACT same line works from the terminal.
I’m pretty sure that it’s not something in my code. I’ve ran a gazillion decklink captures. Trouble starts when I want to use avfoundation.
in Python:
cmd = "bash"
args = ["-c", "/Applications/ffmpeg -loglevel trace -report -f avfoundation -i :0 /Volumes/Data/test.mov"]
self.proc = QProcess(self._main)
self.proc.finished.connect(self.renderdone)
self.proc.errorOccurred.connect(self.erroroccured)
self.proc.start(cmd, args)
print("cmd is now", self.proc.arguments())
self.proc.readyReadStandardOutput.connect(lambda: self.readStdOutput(self.proc))
self.proc.readyReadStandardError.connect(lambda: self.readStdErr(self.proc))
Attachments don’t seem to work for me, so I copy / paste the reports below, first the failing one from Python, then the working one from the terminal.
Anything else I can do to figure out why the same line does not work fired from Python?
ffmpeg started on 2021-05-17 at 08:40:32
Report written to "ffmpeg-20210517-084032.log"
Log level: 56
Command line:
ffmpeg -loglevel trace -report -f avfoundation -i :0 /Volumes/Data/test.mov
ffmpeg version git-2021-03-31-b3e9a84 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --enable-videotoolbox --enable-nonfree --enable-gpl --enable-lv2 --enable-openssl --enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libxvid --enable-libvidstab --enable-libaom --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libtheora --enable-libfdk-aac --enable-libwebp --enable-libsrt --disable-debug --disable-doc --disable-shared --enable-pthreads --enable-static --enable-small --enable-version3 --enable-libfreetype --enable-libfontconfig --enable-decklink --extra-cflags='-I/Users/bouke/ffmpeg-build-script/workspace/include -I/Users/bouke/ffmpeg-build-script/include' --extra-ldexeflags= --extra-ldflags='-L/Users/bouke/ffmpeg-build-script/workspace/lib -L/Users/bouke/ffmpeg-build-script/include' --extra-libs='-ldl -lpthread -lm -lz' --pkgconfigdir=/Users/bouke/ffmpeg-build-script/workspace/lib/pkgconfig --pkg-config-flags=--static --prefix=/Users/bouke/ffmpeg-build-script/workspace
libavutil 56. 63.101 / 56. 63.101
libavcodec 58.117.101 / 58.117.101
libavformat 58. 65.101 / 58. 65.101
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7. 96.100 / 7. 96.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'avfoundation'.
Reading option '-i' ... matched as input url with argument ':0'.
Reading option '/Volumes/Data/test.mov' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url :0.
Applying option f (force format) with argument avfoundation.
Successfully parsed a group of options.
Opening an input file: :0.
[avfoundation @ 0x7f905080ee00] audio device 'Built-in Microphone' opened
##############################################################
The Terminal version:
ffmpeg started on 2021-05-17 at 08:41:36
Report written to "ffmpeg-20210517-084136.log"
Log level: 56
Command line:
ffmpeg -loglevel trace -report -f avfoundation -i :0 /Volumes/Data/test.mov
ffmpeg version git-2021-03-31-b3e9a84 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.29)
configuration: --enable-videotoolbox --enable-nonfree --enable-gpl --enable-lv2 --enable-openssl --enable-libsvtav1 --enable-libx264 --enable-libx265 --enable-libvpx --enable-libxvid --enable-libvidstab --enable-libaom --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libtheora --enable-libfdk-aac --enable-libwebp --enable-libsrt --disable-debug --disable-doc --disable-shared --enable-pthreads --enable-static --enable-small --enable-version3 --enable-libfreetype --enable-libfontconfig --enable-decklink --extra-cflags='-I/Users/bouke/ffmpeg-build-script/workspace/include -I/Users/bouke/ffmpeg-build-script/include' --extra-ldexeflags= --extra-ldflags='-L/Users/bouke/ffmpeg-build-script/workspace/lib -L/Users/bouke/ffmpeg-build-script/include' --extra-libs='-ldl -lpthread -lm -lz' --pkgconfigdir=/Users/bouke/ffmpeg-build-script/workspace/lib/pkgconfig --pkg-config-flags=--static --prefix=/Users/bouke/ffmpeg-build-script/workspace
libavutil 56. 63.101 / 56. 63.101
libavcodec 58.117.101 / 58.117.101
libavformat 58. 65.101 / 58. 65.101
libavdevice 58. 11.103 / 58. 11.103
libavfilter 7. 96.100 / 7. 96.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'avfoundation'.
Reading option '-i' ... matched as input url with argument ':0'.
Reading option '/Volumes/Data/test.mov' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url :0.
Applying option f (force format) with argument avfoundation.
Successfully parsed a group of options.
Opening an input file: :0.
[avfoundation @ 0x7fdc86808a00] audio device 'Built-in Microphone' opened
[avfoundation @ 0x7fdc86808a00] All info found
[avfoundation @ 0x7fdc86808a00] stream 0: start_time: 131424 duration: NOPTS
[avfoundation @ 0x7fdc86808a00] format: start_time: 131424 duration: NOPTS (estimate from bit rate) bitrate=3072 kb/s
Input #0, avfoundation, from ':0':
Duration: N/A, start: 131424.023375, bitrate: 3072 kb/s
Stream #0:0, 1, 1/1000000: Audio: pcm_f32le, 48000 Hz, stereo, flt, 3072 kb/s
Successfully opened the file.
Parsing a group of options: output url /Volumes/Data/test.mov.
Successfully parsed a group of options.
Opening an output file: /Volumes/Data/test.mov.
[file @ 0x7fdc84d48e00] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
Stream #0:0 -> #0:0 (pcm_f32le (native) -> aac (native))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
detected 4 logical cores
[graph_0_in_0_0 @ 0x7fdc84e14780] Setting 'time_base' to value '1/48000'
[graph_0_in_0_0 @ 0x7fdc84e14780] Setting 'sample_rate' to value '48000'
[graph_0_in_0_0 @ 0x7fdc84e14780] Setting 'sample_fmt' to value 'flt'
[graph_0_in_0_0 @ 0x7fdc84e14780] Setting 'channel_layout' to value '0x3'
[graph_0_in_0_0 @ 0x7fdc84e14780] tb:1/48000 samplefmt:flt samplerate:48000 chlayout:0x3
[format_out_0_0 @ 0x7fdc84e15fc0] Setting 'sample_fmts' to value 'fltp'
[format_out_0_0 @ 0x7fdc84e15fc0] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[format_out_0_0 @ 0x7fdc84e15fc0] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_0'
[AVFilterGraph @ 0x7fdc84d4a580] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto_resampler_0 @ 0x7fdc84e16740] [SWR @ 0x7fdc87100000] Using fltp internally between filters
[auto_resampler_0 @ 0x7fdc84e16740] ch:2 chl:stereo fmt:flt r:48000Hz -> ch:2 chl:stereo fmt:fltp r:48000Hz
Output #0, mov, to '/Volumes/Data/test.mov':
Metadata:
encoder : Lavf58.65.101
Stream #0:0, 0, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, delay 1024, 128 kb/s
Metadata:
encoder : Lavc58.117.101 aac
size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
size= 0kB time=00:00:00.43 bitrate= 0.7kbits/s speed=0.857x
size= 0kB time=00:00:00.93 bitrate= 0.3kbits/s speed=0.928x
size= 0kB time=00:00:01.45 bitrate= 0.2kbits/s speed=0.959x
size= 0kB time=00:00:01.95 bitrate= 0.1kbits/s speed=0.966x
size= 0kB time=00:00:02.45 bitrate= 0.1kbits/s speed=0.971x
size= 46kB time=00:00:02.79 bitrate= 133.6kbits/s speed=0.991x
video:0kB audio:44kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.335400%
Input file #0 (:0):
Input stream #0:0 (audio): 254 packets read (1040384 bytes); 254 frames decoded (130048 samples);
Total: 254 packets (1040384 bytes) demuxed
Output file #0 (/Volumes/Data/test.mov):
Output stream #0:0 (audio): 127 frames encoded (130048 samples); 128 packets muxed (45152 bytes);
Total: 128 packets (45152 bytes) muxed
254 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7fdc84d48ec0] Statistics: 2 seeks, 4 writeouts
[aac @ 0x7fdc860c0800] Qavg: 284.039
More information about the ffmpeg-user
mailing list