Konuyu Oyla:
  • Toplam: 3 Oy - Ortalama: 3.67
  • 1
  • 2
  • 3
  • 4
  • 5
Python Dili Soru & Cevap
Ha tabi illa python olsun istiyosan django ile de bir şeyler yapabilirsin Smile Ama php ile çok daha fazla kaynak bulabilirsin, python'a göre web platformunda daha çok yaygın olduğundan Türkçe kaynak sıkıntısı da pek çekeceğini düşünmüyorum.
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
gecemor python olsun c olsun c++ olsun ayni seviyede biliyorum zaten bu dilleri de benimki dil fanatikligi degil sen biraz yanlis anladin. cross-platform icin suan en iyi secenek appcelerator titanium frameworku (js ile hem android hem ios uygulama yaziyorsun ve diger seceneklere gore hem esnek hem stabil hem estetik) ve o bile kucucuk bir is yapacak programi 10-20 mb yapiyor, ram kullanimina hic girmiyorum. o yuzden temiz bir is yapilacaksa android icin en uygun dil java yada kotlin, ios icin objective-c diyorum. diger konulardaki yorumlarinda gordum php html js falan biliyorsun gerektigi yerde onlari kullanmissin, bu da ayni oyle bisey
Ara
Cevapla
Ya tabiki de eğer android programlama ön planda olacaksa dediğin gibi bir java'dan başlamak daha mantıklı, ama ben de onun android uygulamayı siteye alternatif olsun diye yapmak istediğini düşünerek söyledim. Benim mesela C, C++ ve Java ile hiç işim olmadı, kim bilir bir gün ciddi anlamda bir proje çıkar karşıma ve ihtiyaç duyup öğrenirim, ama şu an sadece hobi veya iş görsün yeter kafasındayım Smile Yaşım 34, eğer 24 falan olupda bu şekilde işin içine girseydim o zaman tabi ciddi anlamda bunu geliştirmeyi, gittiği yere kadar gitmek isterdim, bi yerde de nasip işte Smile
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
anladim, nasip evet. bu yas durumundan haberim yoktu kusrumuz olduysa affet
Ara
Cevapla
yoo estağfurullah, sıkıntı yok Wink Bir de 2 yıl öncesine kadar programlama dili ile alakam yoktu, keşke daha erken yaşlarda imkan olsaydı da başlasaydım.
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
gec olsun guc olmasin Smile
Ara
Cevapla
Java da biliyorum c de az da assembly var ama profesyonel değilim benim de konseptlerde eksiğim var o yüzden (Computer Networks [Andrew S. Tanenbaum]) okuyorum şaka olsun diye yazdım yanlış anlaşılmasın Smile
Ara
Cevapla
Tekrar teşekkürler. Madem yaşlar ortaya çıktı benimde 37. Belli bi zamandan sonra insan ağır kodları kaldıramıyor. Bilindik tanıdık kodlar üzerinden gitmek sarıyor beni de. Yıllar önce python varmışta hiç ilgilenmemişim. C ile başladım. Bi merhaba dünya kodunda python ile farkına baktım hemen kalsın dedim C. Söylediklerinizi dikkate alarak, işler izin verirse boş vakitte halledeceğim bi şekilde Smile
Bu arada kodları mysql'e çevirip siteyi de php yapacağım. Aynı mysql veri tabanı üzerinden çalışırlar mı merak ediyorum. Aynı anda çalışınca birbirlerini kitlemezse güzel olur.
Cevapla
mysql ile php arasında bi sıkıntı olacağını sanmıyorum hocam, çünkü bu forumun mybb scripti ve php ile mysql üzerinden çalışıyor Smile Dediğim gibi eğer projeye başlamak nasip olursa çok bilmesem de ben de php üzerinden fikirler sunabilirim. Tabi daha iyi bilen arkadaşlar da yardımcı olacaktır. İyi çalışmalar dilerim...
Turbobit Premium Link Çeviri | Turbobit Link Generator | http://turbobit.qpython.club
Cevapla
Teşekkürler. Php'de tek sorunum php bölümünüzde yazdığım gibi php header yönlendirme sorunu. Php bölümünde bu sorunu bilen çıkmadı belkide. yanıtlanmadı o sorum. Smile Her hostingte çalışmıyor php header. Neyse olmadı bu sorunu çıkartmayan hostingimde kullanacağım artık.

Uygulamada video ve sesi birlikte kaydedecek bir kod arıyordum. 

Aşağıdaki bulduğum kod video ve sesi birleştirip kaydediyor.  

Bu kod dosyayı bulunduğu yere kaydediyor. Bu işlem bittikten sonra sunucu yazılımı çalışacak belirtilen video ismi aynı olduğundan dosyayı görüp transfere başlayacak değil mi? 
Eş zamanlı sunucuya kaydetmem gerekmez mi yoksa adam video kayıt yaptıktan sonra uygulamayı kapattığında transferde sonlanmaz mı ?  

biraz karışık geldi kodları.  Başka benzer daha basit bir kod var mı sizde ? open cv olması şart değil.

PHP Kod:
import cv2
import pyaudio
import wave
import threading
import time
import subprocess
import os

class VideoRecorder():  

    
# Video class based on openCV 
 
   def __init__(self):

 
       self.open = True
        self
.device_index = 0
        self
.fps = 6               # fps should be the minimum constant rate at which the camera can
 
       self.fourcc = "MJPG"       # capture images (with no decrease in speed over time; testing is required)
 
       self.frameSize = (640,480) # video formats and sizes also depend and vary according to the camera used
 
       self.video_filename = "temp_video.avi"
 
       self.video_cap = cv2.VideoCapture(self.device_index)
 
       self.video_writer = cv2.VideoWriter_fourcc(*self.fourcc)
 
       self.video_out = cv2.VideoWriter(self.video_filename, self.video_writer, self.fps, self.frameSize)
 
       self.frame_counts = 1
        self
.start_time = time.time()


 
   # Video starts being recorded 
 
   def record(self):

#       counter = 1
 
       timer_start = time.time()
 
       timer_current = 0


        while
(self.open==True):
 
           ret, video_frame = self.video_cap.read()
 
           if (ret==True):

 
                   self.video_out.write(video_frame)
#                   print str(counter) + " " + str(self.frame_counts) + " frames written " + str(timer_current)
 
                   self.frame_counts += 1
#                   counter += 1
#                   timer_current = time.time() - timer_start
 
                   time.sleep(0.16)
#                   gray = cv2.cvtColor(video_frame, cv2.COLOR_BGR2GRAY)
#                   cv2.imshow('video_frame', gray)
#                   cv2.waitKey(1)
 
           else:
 
               break

                
# 0.16 delay -> 6 fps
 
               # 


 
   # Finishes the video recording therefore the thread too
 
   def stop(self):

 
       if self.open==True:

 
           self.open=False
            self
.video_out.release()
 
           self.video_cap.release()
 
           cv2.destroyAllWindows()

 
       else: 
 
           pass


    
# Launches the video recording function using a thread          
 
   def start(self):
 
       video_thread = threading.Thread(target=self.record)
 
       video_thread.start()





class 
AudioRecorder():


 
   # Audio class based on pyAudio and Wave
 
   def __init__(self):

 
       self.open = True
        self
.rate = 44100
        self
.frames_per_buffer = 1024
        self
.channels = 2
        self
.format = pyaudio.paInt16
        self
.audio_filename = "temp_audio.wav"
 
       self.audio = pyaudio.PyAudio()
 
       self.stream = self.audio.open(format=self.format,
 
                                     channels=self.channels,
 
                                     rate=self.rate,
 
                                     input=True,
 
                                     frames_per_buffer = self.frames_per_buffer)
 
       self.audio_frames = []


 
   # Audio starts being recorded
 
   def record(self):

 
       self.stream.start_stream()
 
       while(self.open == True):
 
           data = self.stream.read(self.frames_per_buffer) 
 
           self.audio_frames.append(data)
 
           if self.open==False:
 
               break


    
# Finishes the audio recording therefore the thread too    
 
   def stop(self):

 
       if self.open==True:
 
           self.open = False
            self
.stream.stop_stream()
 
           self.stream.close()
 
           self.audio.terminate()

 
           waveFile = wave.open(self.audio_filename, 'wb')
 
           waveFile.setnchannels(self.channels)
 
           waveFile.setsampwidth(self.audio.get_sample_size(self.format))
 
           waveFile.setframerate(self.rate)
 
           waveFile.writeframes(b''.join(self.audio_frames))
 
           waveFile.close()

 
       pass

    
# Launches the audio recording function using a thread
 
   def start(self):
 
       audio_thread = threading.Thread(target=self.record)
 
       audio_thread.start()





def start_AVrecording(filename):

 
   global video_thread
    global audio_thread

    video_thread 
= VideoRecorder()
 
   audio_thread = AudioRecorder()

 
   audio_thread.start()
 
   video_thread.start()

 
   return filename




def start_video_recording
(filename):

 
   global video_thread

    video_thread 
= VideoRecorder()
 
   video_thread.start()

 
   return filename


def start_audio_recording
(filename):

 
   global audio_thread

    audio_thread 
= AudioRecorder()
 
   audio_thread.start()

 
   return filename




def stop_AVrecording
(filename):

 
   audio_thread.stop() 
 
   frame_counts = video_thread.frame_counts
    elapsed_time 
= time.time() - video_thread.start_time
    recorded_fps 
= frame_counts / elapsed_time
    print 
"total frames " + str(frame_counts)
 
   print "elapsed time " + str(elapsed_time)
 
   print "recorded fps " + str(recorded_fps)
 
   video_thread.stop() 

 
   # Makes sure the threads have finished
 
   while threading.active_count() > 1:
 
       time.sleep(1)


#    Merging audio and video signal

 
   if abs(recorded_fps - 6) >= 0.01:    # If the fps rate was higher/lower than expected, re-encode it to the expected

 
       print "Re-encoding"
 
       cmd = "ffmpeg -r " + str(recorded_fps) + " -i temp_video.avi -pix_fmt yuv420p -r 6 temp_video2.avi"
 
       subprocess.call(cmd, shell=True)

 
       print "Muxing"
 
       cmd = "ffmpeg -ac 2 -channel_layout stereo -i temp_audio.wav -i temp_video2.avi -pix_fmt yuv420p " + filename + ".avi"
 
       subprocess.call(cmd, shell=True)

 
   else:

 
       print "Normal recording\nMuxing"
 
       cmd = "ffmpeg -ac 2 -channel_layout stereo -i temp_audio.wav -i temp_video.avi -pix_fmt yuv420p " + filename + ".avi"
 
       subprocess.call(cmd, shell=True)

 
       print ".."




# Required and wanted processing of final files
def file_manager(filename):

 
   local_path = os.getcwd()

 
   if os.path.exists(str(local_path) + "/temp_audio.wav"):
 
       os.remove(str(local_path) + "/temp_audio.wav")

 
   if os.path.exists(str(local_path) + "/temp_video.avi"):
 
       os.remove(str(local_path) + "/temp_video.avi")

 
   if os.path.exists(str(local_path) + "/temp_video2.avi"):
 
       os.remove(str(local_path) + "/temp_video2.avi")

 
   if os.path.exists(str(local_path) + "/" + filename + ".avi"):
 
       os.remove(str(local_path) + "/" + filename + ".avi") 

Bu da server kodu :

PHP Kod:
#!/usr/bin/python
 
# Import all from module socket
from socket import *
#Importing all from thread
from thread import *
 
# Defining server address and port
host = 'localhost'  #'localhost' or '127.0.0.1' or '' are all same
port = 1026 #Use port > 1024, below it all are reserved
 
#Creating socket object
sock = socket()
#Binding socket to a address. bind() takes tuple of host and port.
sock.bind((host, port))
#Listening at the address
sock.listen(5) #5 denotes the number of clients can queue
 
def clientthread(conn):
#infinite loop so that function do not terminate and thread do not end.
 
  
#Sending message to connected client
 
        conn.send('Merhaba Ben Server\n') #send only takes string
#Receiving from client
 
        data = conn.recv(1024) # 1024 stands for bytes of data to be received
 
        print data
 
while True:
#Accepting incoming connections
 
   conn, addr = sock.accept()
#Creating new thread. Calling clientthread function for this function and passing conn as argument.
 
   start_new_thread(clientthread,(conn,)) #start new thread takes 1st argument as a function name to be run, second is the tuple of arguments to the function.
 
conn.close()
sock.close() 
Cevapla

{lang: 'en'}


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  15gb .myd uzantılı dosya python ile okutma perry 1 2,015 27-11-2022, Saat: 17:59
Son Yorum: perry
  GÜNCEL Python request , c# request e göre çok yavaş ne yapabilirim perry 12 5,204 28-09-2022, Saat: 20:27
Son Yorum: krast
  YENİ Python Pyqt5 memory leak sorunu perry 3 2,439 28-09-2022, Saat: 11:33
Son Yorum: gecemor
  YENİ PYTHON ads approval CaglarDevv 2 2,255 04-07-2022, Saat: 01:23
Son Yorum: CaglarDevv
  python konusunda yardıma ihtiyacım var $cr!pt HUB 3 1,679 15-06-2022, Saat: 18:11
Son Yorum: CaglarDevv

Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi
Change Theme