Author Topic: [ SOLVED ] Kill a Process ... some help needed  (Read 5034 times)

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10633
  • MLUs Forever!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #30 on: January 28, 2012, 03:34:15 PM »
Quote
this is, why i switch all my scripts to yad...

This is a known problem?

Thanks for any info you may be able to give me.  ;)
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #31 on: January 28, 2012, 03:35:49 PM »

Selecting "Cancel" on the Zenity window has no effect on anything .....  the recording continues as does the zenity progress window.

Can someone explain to me what the difference is and how it is affecting the ending of the Zenity window, and thus the recording?

Not 100% sure as I don't use mencoder .... may be mencoder is implementing code to ignore SIGTERM, the signal used to terminate a process (think at a process wearing a bulletproof vest), if so try SIGKILL (this cannot be ignored, it's like using a missile).
Quote
kill -9 $MENCPID

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10633
  • MLUs Forever!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #32 on: January 28, 2012, 03:39:46 PM »
AS .....  nope .......  this is the actual script ....

Code: [Select]
#!/bin/bash

# Zenity Progress Window
(
        echo
mencoder tv:// -tv device=/dev/video0 -ovc lavc -ofps 25 -noautoexpand -nosound -o ~/Recordings/CamVid.mp4
) |
     zenity --window-icon=$ICON --progress --pulsate --title="   $TITLE   " --text $"  
<b>Recording</b>  

 Your webcam is being recorded to ~/Recordings/CamVid.

                  Press "Cancel" to stop recording."
MENCPID=$(pgrep mencoder); kill -9 $MENCPID

exit 0

The Zenity button is reacting visibly to the mouse click ......  but seems to be doing nothing.

The Zenity window is not dying, so the kill command is not executed.
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #33 on: January 28, 2012, 03:59:40 PM »
try this one:  ;)

Code: [Select]
#!/bin/bash

# Zenity Progress Window

mencoder tv:// -tv device=/dev/video0 -ovc lavc -ofps 25 -noautoexpand -nosound -o /tmp/CamVid.mp4 &
# try the following if you want to remove the terminal output:
# mencoder tv:// -tv device=/dev/video0 -ovc lavc -ofps 25 -noautoexpand -nosound -o /tmp/CamVid.mp4 > /dev/null 2> /dev/null &

while true
do
        echo .
        usleep 500000 # 0.5 seconds
done | zenity --window-icon=$ICON --progress --pulsate --title="   $TITLE   " --text $"
                                                <b>Recording</b>

 Your webcam is being recorded to /tmp/CamVid.

                  Press "Cancel" to stop recording."

# MENCPID=$(pgrep mencoder); kill -9 $MENCPID
                  killall -9 mencoder

exit 0

EDITED: there was a space between '2' and '>'
« Last Edit: January 28, 2012, 05:41:04 PM by AS »

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10633
  • MLUs Forever!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #34 on: January 28, 2012, 04:25:45 PM »
Thanks AS  ;)

I don't have a screen output from the command I use .....  it only records.

Nice thinking to bring the recording outside the progress window ......  I had not thought of that  :D

I still don't know why though .......  some commands work within the progress lines and others don't  :(

It is a solution to the problem for which I am grateful  ;)

regards
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #35 on: January 28, 2012, 05:02:00 PM »
I don't have a screen output from the command I use .....  it only records.

I meant terminal output, post edited.  ;)

Offline AS

  • Hero Member
  • *****
  • Posts: 4111
  • Have a nice ... night!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #36 on: January 28, 2012, 05:38:20 PM »
Important:

there is a problem here, the while loop is eating the CPU:
Quote
while true
do
        echo .
done | zenity....

please change this to:
Quote
while true
do
        echo .
        usleep 500000 # 0.5 seconds
done | zenity....

 ;)


Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10633
  • MLUs Forever!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #37 on: January 28, 2012, 06:40:56 PM »
Thanks for that addition  ;)

I have now - I hope - finished my wee project.

I had a problem recording from webcam while keeping the sync correct and not dropping too many frames and such problems.

I am now recording audio and video separately, muxing them, and then converting the result to mp4 (HQ).

Presently I am using a mix of mencoder for the recording and muxing and ffmeg for the converting.
I might sometime change to use only one of them .......  but I always have both installed so it makes little difference to me.

I doubt anyone is interested but if so here is a link to the script.

http://dl.dropbox.com/u/5838889/CamRecord-0.1.sh

Some of the settings may need to be changed depending on your webcam ......

Thanks for the help  ;)

Another wee itch scratched!  :D  :D

regards

EDIT:  Oops!   Just realised I forgot to mention Leiche ......  it was from his script for a similar purpose that I started. My apologies for not stating this earlier.  :(   Thanks Leiche  ;)

« Last Edit: January 28, 2012, 07:01:38 PM by Just18 »
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #38 on: January 28, 2012, 06:50:06 PM »
Package it and send it to me. I can put it in testing. If you want.     

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10633
  • MLUs Forever!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #39 on: January 28, 2012, 06:54:16 PM »
Package it and send it to me. I can put it in testing. If you want.     

Neal, it is not universal enough .......   alterations may have to be made for different webcams and other things I did not bother with.

Some file locations are hard coded.

Also, there would be no point in have both ffmpeg and mencoder as dependencies ......  it would need some work to eliminate one of them.

So, much as I appreciate your offer this script is not at the stage I believe necessary for such a move.

Regards.
« Last Edit: January 28, 2012, 07:04:37 PM by Just18 »
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: [ SOLVED ] Kill a Process ... some help needed
« Reply #40 on: January 28, 2012, 07:03:04 PM »
Okay. :D But if you ever change your mind.........