Permalink
Browse files

add functions about audio

  • Loading branch information...
sdpython committed Dec 30, 2017
1 parent d3f2ffa commit 608d5491dbf5f1481ae10775551653d40fb32530
@@ -214,8 +214,8 @@
"metadata": {},
"outputs": [],
"source": [
"from code_beatrix.faq.faq_video import extract_video, save_video\n",
"vid = extract_video(name, '00:00:32', '00:00:45')\n",
"from code_beatrix.faq.faq_video import video_extract_video, save_video\n",
"vid = video_extract_video(name, '00:00:32', '00:00:45')\n",
"save_video(vid, \"mpoppins.mp4\")"
]
},
@@ -1,17 +1,33 @@
Vidéos
======
Vidéos et Sons
==============
.. contents::
:local:
Download
++++++++
Audio
+++++
.. autosignature:: code_beatrix.faq.faq_video.download_youtube_video
.. autosignature:: code_beatrix.faq.faq_video.audio_compose
.. autosignature:: code_beatrix.faq.faq_video.extract_video
.. autosignature:: code_beatrix.faq.faq_video.audio_modification
.. autosignature:: code_beatrix.faq.faq_video.video_enumerate_frames
.. autosignature:: code_beatrix.faq.faq_video.save_audio
Video
+++++
.. autosignature:: code_beatrix.faq.faq_video.save_video
.. autosignature:: code_beatrix.faq.faq_video.video_extract_video
.. autosignature:: code_beatrix.faq.faq_video.video_enumerate_frames
.. autosignature:: code_beatrix.faq.faq_video.video_extract_audio
.. autosignature:: code_beatrix.faq.faq_video.video_replace_sound
YouTube
+++++++
.. autosignature:: code_beatrix.faq.faq_video.download_youtube_video
@@ -72,6 +72,7 @@
latex_elements['preamble'] += custom_preamble
mathdef_link_only = True
epkg_dictionary['AutioClip'] = 'https://zulko.github.io/moviepy/ref/AudioClip/AudioClip.html'
epkg_dictionary['deep learning'] = 'https://en.wikipedia.org/wiki/Deep_learning'
epkg_dictionary['fcn'] = 'https://github.com/wkentaro/fcn'
epkg_dictionary['pytube'] = 'https://github.com/nficano/pytube'
@@ -48,7 +48,7 @@ class TestNotebookExample (unittest.TestCase):
def setUp(self):
add_missing_development_version(
["pyensae", "jyquickhelper"], __file__)
["pyensae", "jyquickhelper", "ensae_projects"], __file__)
def test_notebook_example(self):
fLOG(
@@ -0,0 +1 @@
cartoon11.wav - source: http://www.grsites.com/
Binary file not shown.
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""
@brief test log(time=1000s)
Duraction is around a few seconds but the test needs to be run
at the end of the series of unitests as it interferes
with the notebook unittesting (it uses Popen too).
"""
import sys
import os
import unittest
try:
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from src.code_beatrix.faq.faq_video import audio_compose, save_audio
class TestAudio(ExtTestCase):
def test_extract_audio(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_audio")
aud = os.path.join(temp, '..', 'data', 'cartoon011.wav')
aud2 = audio_compose(aud, aud, 1, 3)
exp = os.path.join(temp, "courte_audio.wav")
save_audio(aud2, exp)
self.assertExists(exp)
if __name__ == "__main__":
unittest.main()
@@ -46,7 +46,7 @@
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from src.code_beatrix.faq.faq_video import save_video, extract_video
from src.code_beatrix.faq.faq_video import save_video, video_extract_video
class TestVideo(ExtTestCase):
@@ -58,7 +58,7 @@ def test_extract_avideo(self):
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_video_extract")
vid = os.path.join(temp, '..', 'data', 'videxa.mp4')
vid2 = extract_video(vid, '00:00:01', '00:00:04')
vid2 = video_extract_video(vid, '00:00:01', '00:00:04')
exp = os.path.join(temp, "courte.mp4")
save_video(vid2, exp)
self.assertExists(exp)
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
"""
@brief test log(time=1000s)
Duraction is around a few seconds but the test needs to be run
at the end of the series of unitests as it interferes
with the notebook unittesting (it uses Popen too).
"""
import sys
import os
import unittest
try:
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import pyquickhelper
try:
import src
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
import src
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from src.code_beatrix.faq.faq_video import save_video, video_replace_sound, video_extract_audio
class TestAudioVideo(ExtTestCase):
def test_extract_audio_video(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
temp = get_temp_folder(__file__, "temp_video_audio")
vid = os.path.join(temp, '..', 'data', 'videxa.mp4')
aud = os.path.join(temp, '..', 'data', 'cartoon011.wav')
vid2 = video_replace_sound(vid, aud, loop=True, volumex=5.5, fadein=True,
t_end='00:00:05', speed=2.)
self.assertTrue(video_extract_audio(vid2) is not None)
exp = os.path.join(temp, "courte_audio.mp4")
save_video(vid2, exp, verbose=False)
self.assertExists(exp)
if __name__ == "__main__":
unittest.main()
Oops, something went wrong.

0 comments on commit 608d549

Please sign in to comment.