Start the video capture process. Start ffmpeg for encoding video with v3l2 than output to the web server located at localhost:_SERVER_PORT Returns: handler for the subprocess
(args)
| 44 | |
| 45 | |
| 46 | def StartCaptureProcess(args): |
| 47 | """Start the video capture process. |
| 48 | |
| 49 | Start ffmpeg for encoding video with v3l2 than output to the web server |
| 50 | located at localhost:_SERVER_PORT |
| 51 | |
| 52 | Returns: |
| 53 | handler for the subprocess |
| 54 | """ |
| 55 | system = platform.system() |
| 56 | |
| 57 | if system == 'Linux': |
| 58 | return subprocess.Popen( |
| 59 | 'sleep 1; ' |
| 60 | 'ffmpeg -an -s %s -f video4linux2 -i %s -f mpeg1video -b:v %s -r %d ' |
| 61 | 'http://localhost:%s/' % |
| 62 | (args.size, args.device, args.bitrate, args.framerate, _SERVER_PORT), |
| 63 | stdout=subprocess.PIPE, |
| 64 | stderr=subprocess.PIPE, |
| 65 | shell=True) |
| 66 | if system == 'Darwin': |
| 67 | return subprocess.Popen( |
| 68 | 'sleep 1; ' |
| 69 | 'ffmpeg -an -f avfoundation -video_size %s -framerate %d -i %s -b:v %s ' |
| 70 | '-f mpeg1video -r %d http://localhost:%s/' % |
| 71 | (args.size, args.framerate, args.device, args.bitrate, args.framerate, |
| 72 | _SERVER_PORT), |
| 73 | stdout=subprocess.PIPE, |
| 74 | stderr=subprocess.PIPE, |
| 75 | shell=True) |
| 76 | raise ValueError('Only support Linux or Darwin, found %s' % system) |
| 77 | |
| 78 | |
| 79 | def StopCaptureProcess(handler): |