-3

I am working on encoding a video. For that I need a thread that will encode the video while it is played and will exit when the video stops. How do I make this happen?

dano
  • 91,354
  • 19
  • 222
  • 219
  • See [here](https://docs.python.org/2/library/threading.html). Note that because of the [GIL](http://stackoverflow.com/questions/265687/why-the-global-interpreter-lock), you're probably going to want to use [`multiprocessing`](https://docs.python.org/2/library/multiprocessing.html) instead. – dano Jul 22 '14 at 04:45

1 Answers1

0

You should put encoding in main process and put playing in a thread. Here is example, you have to fulfill it with your own code.

#!/usr/bin/env python
#-*- coding:utf-8 -*-

from threading import Thread

def encode_video():

    t = Thread(target=start_play, args=[])
    t.start()
    t.join()
    # here is code for encoding
    pass

def start_play():
    # here is code for starting
    pass


if __name__ =='__main__':

    encode_video()

Hope it helps.

Stephen Lin
  • 4,852
  • 1
  • 13
  • 26