好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁(yè) > 知識(shí)庫(kù) > python實(shí)現(xiàn)多個(gè)視頻文件合成畫(huà)中畫(huà)效果

python實(shí)現(xiàn)多個(gè)視頻文件合成畫(huà)中畫(huà)效果

熱門(mén)標(biāo)簽:高德地圖標(biāo)注收入咋樣 沈陽(yáng)防封電銷(xiāo)電話卡 企業(yè)微信地圖標(biāo)注 B52系統(tǒng)電梯外呼顯示E7 萊蕪電信外呼系統(tǒng) 地圖標(biāo)注多個(gè) 銀川電話機(jī)器人電話 鶴壁手機(jī)自動(dòng)外呼系統(tǒng)違法嗎 怎么辦理400客服電話

本文實(shí)例為大家分享了多個(gè)視頻文件合成畫(huà)中畫(huà)效果的python代碼,供大家參考,具體內(nèi)容如下

Step 1 從視頻中分離出音頻(MP4->mp3)

def separateMp4ToMp3(tmp):
   mp4 = tmp.replace('.tmp', '.mp4')
   print('---> Separate the video clip {0}'.format(mp4))

   mp3 = tmp.replace('.tmp', '.mp3')
   if os.path.exists(mp3):
      print '\n\t{0} is detected. Skip. \n\tPlease delete .mp3 file if you need re-separate.'.format(mp3)
      return

   cmd = 'ffmpeg -i {0} -f mp3 -vn -loglevel fatal {1}'.format(mp4, mp3)
   print '\t{0}'.format(cmd)

   x = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   
   for log in x.stdout.readlines():
      print '[ffmpeg info] {0}'.format(log)
   for log in x.stderr.readlines():
      print '[ffmpeg error] {0}'.format(log)

   print '\tSuccess! {0} -> {1}\n'.format(mp4, mp3)

Step 2 根據(jù)時(shí)間軸多個(gè)音頻合成一份音頻(MP3->mp3)

def composeMp3ToMp3(arr = []):
   if len(arr) =0 :
      print('--->Operate audio array is empty!')
      return
   
   thisDir = os.path.dirname(arr[0])
   if (os.path.exists(thisDir + "/composeAudio.mp3")):
      print('--->{0}/composeAudio.mp3 is exist, if you need re-gennerate,Please delete it!'.format(thisDir))
      return
      
   print('---> Compose the audio :')
   var = ''
   for tem in arr:
      if os.path.exists(tem) == False:
         print '\n\t{0} is not exist! \n\tPlease make sure audio file be exist if you need compose.'.format(tem)
         return
      var = var + " -i " + tem
      
   if var == '':
      print '\n\t{0} is empty. \n\tPlease check .mp3 file if you need compose.'.format(var)
      return
      
   cmd = 'ffmpeg {0} -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f mp3 -loglevel fatal {1}/composeAudio.mp3'.format(var, thisDir)
   print '\t{0}'.format(cmd)
   x = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   
   for log in x.stdout.readlines():
      print '[ffmpeg info] {0}'.format(log)
   for log in x.stderr.readlines():
      print '[ffmpeg error] {0}'.format(log)

   print '\tSuccess! {0} -> {1}\n'.format(var, thisDir + "/composeAudio.mp3")

Step 3 多個(gè)視頻合成畫(huà)中畫(huà)效果無(wú)聲>(MP4->mp4)

def composeMp4ToMp4(arr = []):
   if len(arr) = 0:
      print('--->Operate video array is empty!')
      return
   
   thisDir = os.path.dirname(arr[0])
   if (os.path.exists(thisDir + "/composeVideo.mp4")):
      print('--->{0}/composeVideo.mp4 is exist, if you need re-gennerate,Please delete it!'.format(thisDir))
      return
   
   print('---> Compose the video :')
   var = ''
   temparr = []
   for tem in arr:
      if os.path.exists(tem) == False:
         print '\n\t{0} is not exist! \n\tPlease make sure video file be exist if you need compose.'.format(tem)
         return
      
      #split image
      png = tem.replace('.mp4', '.png')
      tempcmd="ffmpeg -i {0} -ss 00:00:2.435 -loglevel fatal -vframes 1 {1}".format(tem, png)
      print '\t{0}'.format(tempcmd)
      x = subprocess.Popen(tempcmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      x.wait()
      for log in x.stdout.readlines():
         print'[ffmpeg info] {0}'.format(log)
      for log in x.stderr.readlines():
         print'[ffmpeg error] {0}'.format(log)
      
      img = Image.open(png)
      imgSize = img.size
      #ipad
      if (imgSize[0] > imgSize[1]) :
         temparr.append(tem)
      #mobile
      else:
         var = var + " -i " + tem
      img.close()
      
   if (len(temparr) > 0):
      for tem in temparr:
         var = var + " -i " + tem
   
   if var == '':
      print '\n\t{0} is empty. \n\tPlease check video file if you need compose.'.format(var)
      return
   
   cmd = 'ffmpeg ' + var + ' -filter_complex "[1:v]scale=w=176:h=144:force_original_aspect_ratio=decrease[ckout];[0:v]' \

        '[ckout]overlay=x=W-w-10:y=10[out]" -map "[out]" -movflags faststart -loglevel fatal ' + thisDir + '/composeVideo.mp4'.format(var, thisDir)
   print '\t{0}'.format(cmd)
   x = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   
   for log in x.stdout.readlines():
      print '[ffmpeg info] {0}'.format(log)
   for log in x.stderr.readlines():
      print '[ffmpeg error] {0}'.format(log)
   
   print '\tSuccess!\n {0} -> {1}\n'.format(var, thisDir + "/composeVideo.mp4")

Step 4 音頻與視頻合成

def communicateAudioVideo(folder):
   if (os.path.exists(folder + "/communicateVideo.mp4")):
      print('--->{0}/communicateVideo.mp4 is exist, if you need re-gennerate,Please delete it!'.format(folder))
      return
   
   if ((os.path.exists(folder + "/composeVideo.mp4") == False) or
         (os.path.exists(folder + "/composeAudio.mp3") == False)):
      print('--->{0}/composeVideo.mp4  or composeAudio.mp3 must be exist!'.format(folder))
      return
   
   print('---> Communicate the video :')
   cmd = 'ffmpeg -i ' + folder + '/composeVideo.mp4 -i ' + folder + '/composeAudio.mp3 -f mp4 ' \

         ' -loglevel fatal ' + folder +'/communicateVideo.mp4'
   print '\t{0}'.format(cmd)
   x = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   
   for log in x.stdout.readlines():
      print '[ffmpeg info] {0}'.format(log)
   for log in x.stderr.readlines():
      print '[ffmpeg error] {0}'.format(log)
   
   print '\tSuccess!\n {0}  and {1} -> {2}\n'.format(folder + '/composeVideo.mp4', folder + '/composeAudio.mp3', folder +'/communicateVideo.mp4')

源碼下載

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • Python實(shí)現(xiàn)雙軸組合圖表柱狀圖和折線圖的具體流程
  • 用Python做個(gè)個(gè)性的動(dòng)畫(huà)掛件讓桌面不單調(diào)
  • 如何用Python寫(xiě)一個(gè)簡(jiǎn)單的通訊錄
  • 自己用python做的一款超炫酷音樂(lè)播放器
  • Python做個(gè)自定義動(dòng)態(tài)壁紙還可以放視頻
  • 分析總結(jié)Python數(shù)據(jù)化運(yùn)營(yíng)KMeans聚類(lèi)
  • python中的zip模塊
  • 總結(jié)分析python數(shù)據(jù)化運(yùn)營(yíng)關(guān)聯(lián)規(guī)則
  • python項(xiàng)目--使用Tkinter的日歷GUI應(yīng)用程序
  • 如何使用Python做個(gè)自定義動(dòng)態(tài)壁紙

標(biāo)簽:呼倫貝爾 葫蘆島 湘西 烏魯木齊 安慶 三亞 銀川 呼倫貝爾

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python實(shí)現(xiàn)多個(gè)視頻文件合成畫(huà)中畫(huà)效果》,本文關(guān)鍵詞  python,實(shí)現(xiàn),多個(gè),視頻,文件,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《python實(shí)現(xiàn)多個(gè)視頻文件合成畫(huà)中畫(huà)效果》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于python實(shí)現(xiàn)多個(gè)視頻文件合成畫(huà)中畫(huà)效果的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 国产又色又爽又黄又免费| 亚洲精品电影hhh| 亚州国产精品| 婷婷在线视频国产综合| 一级做a爱过程免费视频app| 脱了内裤一边亲一边摸欧美 | 中文字幕网站| 国产精品三级| 露屁股100℅无遮挡图片| 男人插女人网站| 最近2019mv中文字幕免费看| 136成人福利AV在线导航| 蜜臀αv| 桥本有菜在线播放| 一级做a爰片久久毛片A片冒白浆| 国产Chinese男男Gay片| 美女露100%胸无遮挡图片| 天天操天天插天天射| 国产拍揄自揄精品视频麻豆| 日韩伦理免费| 男女性行为网站| 嗯啊好爽真紧嗯啊| 征服艳岳爽| 国产超级乱淫视频播放| 扒开腿挺进肉蒂抽搐喷潮视频 | 久久久久久国模大尺度人体| 亚洲综合一区| 久久久全国免费视频| 女人夜夜春性视频| 夜夜爽爽未满十八勿进的影视播放 | 国产乱熟肥女视频网站| 午夜福利一区二区三区| 刘晓庆情史恶性事件| 最近中文字幕无| 接了一个二十厘米长的客人| 久久的精品99精品66| 国产大战开裆丝袜高跟美女| 国中精品久久久久精品综合紧| 《日本》《妻子》迷妺网| 一本一道人妻久久一区二区三区 | 十八岁毛片|