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….) Bouke
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.) Moritz
On 16 May 2021, at 15:46, Moritz Barsnick <barsnick@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
On Mon, May 17, 2021 at 09:19:46 +0200, Bouke wrote:
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.)
I know, but there was ’nothing’ on stdErr / stdOut.
Then you're capturing your output incorrectly.
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.
If QProcess terminates it unconditionally, there's nothing we can do(?). If ffmpeg crashes, that's bad. You would have to convince your system to create a core dump, and would have to look at a backtrace. (Or run ffmpeg within gdb.)
in Python: cmd = "bash" args = ["-c", "/Applications/ffmpeg -loglevel trace -report -f avfoundation -i :0 /Volumes/Data/test.mov"]
Do you need to run it in bash? Can you not set cmd to "ffmpeg" and properly pass the arguments? Regards, Moritz
On 18 May 2021, at 09:33, Moritz Barsnick <barsnick@gmx.net> wrote:
On Mon, May 17, 2021 at 09:19:46 +0200, Bouke wrote:
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.)
I know, but there was ’nothing’ on stdErr / stdOut.
Then you're capturing your output incorrectly.
Nah, this was an apology for an earlier message where I ment ’nothing except the banner'
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.
If QProcess terminates it unconditionally, there's nothing we can do(?).
I understand, but now it’s the blame game, what happens where / when / why?
If ffmpeg crashes, that's bad. You would have to convince your system to create a core dump, and would have to look at a backtrace. (Or run ffmpeg within gdb.)
Eeh, I’m a simple scripter, not a coder, no clue how to do that...
in Python: cmd = "bash" args = ["-c", "/Applications/ffmpeg -loglevel trace -report -f avfoundation -i :0 /Volumes/Data/test.mov"]
Do you need to run it in bash? Can you not set cmd to "ffmpeg" and properly pass the arguments?
Normally I do that, especially as that saves tons of headaches on escaping stuff. But this was a suggestion from the QT forum, hoping it would provide a bit more insight. https://forum.qt.io/topic/126674/escaping-colon-in-command-line-argument/8 <https://forum.qt.io/topic/126674/escaping-colon-in-command-line-argument/8> Trust me, it makes no difference if I use separate args or run it as bash. Bouke
Regards, Moritz _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
On Tue, May 18, 2021 at 12:05:40 +0200, Bouke wrote:
Then you're capturing your output incorrectly.
Nah, this was an apology for an earlier message where I ment ’nothing except the banner'
Hmm. Your attached reports indicate that there were more log messages. I wonder where they went...
If QProcess terminates it unconditionally, there's nothing we can do(?).
I understand, but now it’s the blame game, what happens where / when / why?
Sure. I don't understand QProcess (yet, or anymore), so I have no idea what to debug. I don't know what to make of the return code 6 either. it doesn't come from ffmpeg, as far as I can tell from the latter's source. ffmpeg isn't stuck at that point, it just terminates, right?
If ffmpeg crashes, that's bad. You would have to convince your system to create a core dump, and would have to look at a backtrace. (Or run ffmpeg within gdb.)
Eeh, I’m a simple scripter, not a coder, no clue how to do that...
(If you can operate QProcess, you're no longer a "simple" scripter.) Well, if MacOS happens to have gdb, it would work by replacing your ffmpeg command line with: $ gdb -ex r -ex bt --args ffmpeg [further command line options] i.e. prepending gdb. The ffmpeg binary should not be stripped for this to work properly. MacOS may have lldb instead of gdb, but I have no experience in operating that.
Do you need to run it in bash? Can you not set cmd to "ffmpeg" and properly pass the arguments?
Normally I do that, especially as that saves tons of headaches on escaping stuff. But this was a suggestion from the QT forum, hoping it would provide a bit more insight. https://forum.qt.io/topic/126674/escaping-colon-in-command-line-argument/8 <https://forum.qt.io/topic/126674/escaping-colon-in-command-line-argument/8>
Trust me, it makes no difference if I use separate args or run it as bash.
I trust you. I was just speculating. Moritz
Moritz Barsnick (12021-05-18):
Sure. I don't understand QProcess (yet, or anymore), so I have no idea what to debug. I don't know what to make of the return code 6 either.
That could be a signal number incorrectly interpreted as a return code. That would make the signal probably SIGABRT, and therefore probably the sign of a failed assert. It is almost certain more diagnostic appears in ffmpeg's output. I do not know if Qt allows to capture it, but it would be unforgivable not to. Anyway, the ffmpeg-user mailing list is not the place to learn Qt programming, nor generic system programming. Regards, -- Nicolas George
On 18 May 2021, at 16:28, Moritz Barsnick <barsnick@gmx.net> wrote:
Hmm. Your attached reports indicate that there were more log messages. I wonder where they went…
I found it. They went into the smelly lava / tar pit deep under Cupertino, sent there by ’Security & Privacy’. This specific demon ’should’ ask if it’s OK to use the microphone, but it does not. Curses! Two days lost on something I should have known. Thanks for all the suggestions! Bouke
participants (3)
-
Bouke -
Moritz Barsnick -
Nicolas George