Open process
Posted: Mon Sep 26, 2016 5:44 pm
Hi,
I just discovered the open process is like shell() and doesn’t block livecode. Nice!
I figured to use it to read the output of a command, for example ffmpeg. I use ffmpeg to convert videos to the new h.265 (incedible compression!), a ffmpeg output is like:
but using open process this way:
########CODE#######
on mouseUp
close process "/usr/bin/ffmpeg -i SampleVideo_1280x720_5mb.mp4 -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k filesupercompresso.MP4"
set the defaultFolder to "~/Scaricati"
put empty into field 1
delete file "filesupercompresso.MP4"
open process "/usr/bin/ffmpeg -i SampleVideo_1280x720_5mb.mp4 -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k filesupercompresso.MP4" for text read
controlla
end mouseUp
on controlla
read from process "/usr/bin/ffmpeg -i SampleVideo_1280x720_5mb.mp4 -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k filesupercompresso.MP4" until linefeed
put it after field 1
--if the result is not "eof" then
--put the result & return after field 1
send controlla to me in 1 sec
--end if
end controlla
#####END OF CODE#####
I get much more and conversion seems to me much slower:
What am I doing wrong?
And how can I know the process ended?
I just discovered the open process is like shell() and doesn’t block livecode. Nice!

I figured to use it to read the output of a command, for example ffmpeg. I use ffmpeg to convert videos to the new h.265 (incedible compression!), a ffmpeg output is like:
Code: Select all
frame= 44 fps= 11 q=-0.0 size= 91kB time=00:00:01.87 bitrate= 398.3kbits/
frame= 48 fps=9.9 q=-0.0 size= 112kB time=00:00:02.04 bitrate= 449.9kbits/
frame= 51 fps=9.2 q=-0.0 size= 117kB time=00:00:02.17 bitrate= 439.7kbits/
frame= 55 fps=9.1 q=-0.0 size= 132kB time=00:00:02.30 bitrate= 469.9kbits/
########CODE#######
on mouseUp
close process "/usr/bin/ffmpeg -i SampleVideo_1280x720_5mb.mp4 -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k filesupercompresso.MP4"
set the defaultFolder to "~/Scaricati"
put empty into field 1
delete file "filesupercompresso.MP4"
open process "/usr/bin/ffmpeg -i SampleVideo_1280x720_5mb.mp4 -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k filesupercompresso.MP4" for text read
controlla
end mouseUp
on controlla
read from process "/usr/bin/ffmpeg -i SampleVideo_1280x720_5mb.mp4 -c:v libx265 -preset medium -x265-params crf=28 -c:a aac -strict experimental -b:a 128k filesupercompresso.MP4" until linefeed
put it after field 1
--if the result is not "eof" then
--put the result & return after field 1
send controlla to me in 1 sec
--end if
end controlla
#####END OF CODE#####
I get much more and conversion seems to me much slower:
Code: Select all
frame= 44 fps=9.8 q=-0.0 size= 91kB time=00:00:01.87 bitrate= 398.3kbits/s speed=0.418x
[h264 @ 0x4b67ea0] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4b83800] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4a624a0] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4a6b0c0] nal_unit_type: 1, nal_ref_idc: 2
frame= 48 fps=9.1 q=-0.0 size= 112kB time=00:00:02.04 bitrate= 449.9kbits/s speed=0.388x
[h264 @ 0x4a5ab40] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4b67ea0] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4b83800] nal_unit_type: 1, nal_ref_idc: 2
frame= 51 fps=8.5 q=-0.0 size= 117kB time=00:00:02.17 bitrate= 439.7kbits/s speed=0.362x
[h264 @ 0x4a624a0] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4a6b0c0] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4a5ab40] nal_unit_type: 1, nal_ref_idc: 2
[h264 @ 0x4b67ea0] nal_unit_type: 1, nal_ref_idc: 2
frame= 55 fps=8.0 q=-0.0 size= 132kB time=00:00:02.32 bitrate= 465.6kbits/s speed=0.338x
And how can I know the process ended?