Ejemplo n.º 1
1
 def to_audiofile(self, filename, fps=44100, nbytes = 2,
                codec ='libvorbis', bitrate=None,
                   buffersize=60000, verbose=True):
     """ Writes the soundclip to a file using FFMPEG """
     
     ffmpeg_audiowrite(clip, filename, fps, nbytes=nbytes,
           buffersize=buffersize, codec=codec, bitrate=bitrate, verbose=True)
Ejemplo n.º 2
1
    def write_audiofile(self,filename, fps=44100, nbytes=2,
                        buffersize=2000, codec=None,
                        bitrate=None, ffmpeg_params=None,
                        write_logfile=False, verbose=True,
                        progress_bar=True):
        """ Writes an audio file from the AudioClip.


        Parameters
        -----------

        filename
          Name of the output file

        fps
          Frames per second

        nbyte
          Sample width (set to 2 for 16-bit sound, 4 for 32-bit sound)

        codec
          Which audio codec should be used. If None provided, the codec is
          determined based on the extension of the filename. Choose
          'pcm_s16le' for 16-bit wav and 'pcm_s32le' for 32-bit wav.

        bitrate
          Audio bitrate, given as a string like '50k', '500k', '3000k'.
          Will determine the size and quality of the output file.
          Note that it mainly an indicative goal, the bitrate won't
          necessarily be the this in the output file.

        ffmpeg_params
          Any additional parameters you would like to pass, as a list
          of terms, like ['-option1', 'value1', '-option2', 'value2']

        write_logfile
          If true, produces a detailed logfile named filename + '.log'
          when writing the file

        verbose
          Boolean indicating whether to print infomation
          
        progress_bar
          Boolean indicating whether to show the progress bar.

        """

        if codec is None:
            name, ext = os.path.splitext(os.path.basename(filename))
            try:
                codec = extensions_dict[ext[1:]]['codec'][0]
            except KeyError:
                raise ValueError("MoviePy couldn't find the codec associated "
                       "with the filename. Provide the 'codec' parameter in "
                       "write_videofile.")

        return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
                                 codec=codec, bitrate=bitrate, write_logfile=write_logfile,
                                 verbose=verbose, ffmpeg_params=ffmpeg_params,
                                 progress_bar=progress_bar)
Ejemplo n.º 3
1
    def to_audiofile(self,filename, fps=44100, nbytes=2,
                     buffersize=2000, codec='libvorbis',
                     bitrate=None, write_logfile=False, verbose=True):
        """ Writes an audio file from the AudioClip.


        Parameters
        -----------

        filename
          Name of the output file

        fps
          Frames per second

        nbyte
          Sample width (set to 2 for 16-bit sound, 4 for 32-bit sound)

        codec
          Which audio codec should be used. Examples are 'libmp3lame'
          for '.mp3', 'libvorbis' for 'ogg', 'libfdk_aac':'m4a',
          'pcm_s16le' for 16-bit wav and 'pcm_s32le' for 32-bit wav.

        bitrate
          Audio bitrate, given as a string like '50k', '500k', '3000k'.
          Will determine the size and quality of the output file.
          Note that it mainly an indicative goal, the bitrate won't
          necessarily be the this in the output file.

        write_logfile
          If true, produces a detailed logfile named filename + '.log'
          when writing the file

        verbose
          If True, displays informations

        """
                         
        return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
                      codec=codec, bitrate=bitrate, write_logfile=write_logfile,
                      verbose=verbose)
Ejemplo n.º 4
0
 def to_audiofile(self, filename, fps=44100, nbytes = 2,
                codec ='libvorbis', bitrate=None,
                   buffersize=60000, verbose=True):
     """ Writes the soundclip to a file using FFMPEG """
     
     ffmpeg_audiowrite(clip, filename, fps, nbytes=nbytes,
           buffersize=buffersize, codec=codec, bitrate=bitrate, verbose=True)
Ejemplo n.º 5
0
    def write_audiofile(self,filename, fps=44100, nbytes=2,
                        buffersize=2000, codec=None,
                        bitrate=None, ffmpeg_params=None,
                        write_logfile=False, verbose=True,
                        progress_bar=True):
        """ Writes an audio file from the AudioClip.


        Parameters
        -----------

        filename
          Name of the output file

        fps
          Frames per second

        nbyte
          Sample width (set to 2 for 16-bit sound, 4 for 32-bit sound)

        codec
          Which audio codec should be used. If None provided, the codec is
          determined based on the extension of the filename. Choose
          'pcm_s16le' for 16-bit wav and 'pcm_s32le' for 32-bit wav.

        bitrate
          Audio bitrate, given as a string like '50k', '500k', '3000k'.
          Will determine the size and quality of the output file.
          Note that it mainly an indicative goal, the bitrate won't
          necessarily be the this in the output file.

        ffmpeg_params
          Any additional parameters you would like to pass, as a list
          of terms, like ['-option1', 'value1', '-option2', 'value2']

        write_logfile
          If true, produces a detailed logfile named filename + '.log'
          when writing the file

        verbose
          If True, displays informations
          
        progress_bar
          If False, will not display the red progress bar

        """

        if codec is None:
            name, ext = os.path.splitext(os.path.basename(filename))
            try:
                codec = extensions_dict[ext[1:]]['codec'][0]
            except KeyError:
                raise ValueError("MoviePy couldn't find the codec associated "
                       "with the filename. Provide the 'codec' parameter in "
                       "write_videofile.")

        return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
                                 codec=codec, bitrate=bitrate, write_logfile=write_logfile,
                                 verbose=verbose, ffmpeg_params=ffmpeg_params,
                                 progress_bar=progress_bar)
Ejemplo n.º 6
0
    def write_audiofile(self,
                        filename,
                        fps=44100,
                        nbytes=2,
                        buffersize=2000,
                        codec='libvorbis',
                        bitrate=None,
                        write_logfile=False,
                        verbose=True):
        """ Writes an audio file from the AudioClip.


        Parameters
        -----------

        filename
          Name of the output file

        fps
          Frames per second

        nbyte
          Sample width (set to 2 for 16-bit sound, 4 for 32-bit sound)

        codec
          Which audio codec should be used. Examples are 'libmp3lame'
          for '.mp3', 'libvorbis' for 'ogg', 'libfdk_aac':'m4a',
          'pcm_s16le' for 16-bit wav and 'pcm_s32le' for 32-bit wav.

        bitrate
          Audio bitrate, given as a string like '50k', '500k', '3000k'.
          Will determine the size and quality of the output file.
          Note that it mainly an indicative goal, the bitrate won't
          necessarily be the this in the output file.

        write_logfile
          If true, produces a detailed logfile named filename + '.log'
          when writing the file

        verbose
          If True, displays informations

        """

        return ffmpeg_audiowrite(self,
                                 filename,
                                 fps,
                                 nbytes,
                                 buffersize,
                                 codec=codec,
                                 bitrate=bitrate,
                                 write_logfile=write_logfile,
                                 verbose=verbose)
Ejemplo n.º 7
0
 def to_audiofile(self,filename, fps=44100, nbytes=2,
                  buffersize=2000, codec='libvorbis',
                  bitrate=None, verbose=True):
     """ 
     codecs  = {        'libmp3lame': 'mp3',
                    'libvorbis':'ogg',
                    'libfdk_aac':'m4a',
                    'pcm_s16le':'wav',
                    'pcm_s32le': 'wav'}
     """
                      
     return ffmpeg_audiowrite(self,filename, fps, nbytes, buffersize,
                   codec, bitrate, verbose)
Ejemplo n.º 8
0
    def to_audiofile(self,
                     filename,
                     fps=44100,
                     nbytes=2,
                     buffersize=2000,
                     codec='libvorbis',
                     bitrate=None,
                     verbose=True):
        """ 
        codecs  = {        'libmp3lame': 'mp3',
                       'libvorbis':'ogg',
                       'libfdk_aac':'m4a',
                       'pcm_s16le':'wav',
                       'pcm_s32le': 'wav'}
        """

        return ffmpeg_audiowrite(self, filename, fps, nbytes, buffersize,
                                 codec, bitrate, verbose)
Ejemplo n.º 9
0
    def write_audiofile(
        self,
        filename,
        fps=None,
        nbytes=2,
        buffersize=2000,
        codec=None,
        bitrate=None,
        ffmpeg_params=None,
        write_logfile=False,
        logger="bar",
    ):
        """Writes an audio file from the AudioClip.


        Parameters
        -----------

        filename
          Name of the output file, as a string or a path-like object.

        fps
          Frames per second. If not set, it will try default to self.fps if
          already set, otherwise it will default to 44100.

        nbytes
          Sample width (set to 2 for 16-bit sound, 4 for 32-bit sound)

        codec
          Which audio codec should be used. If None provided, the codec is
          determined based on the extension of the filename. Choose
          'pcm_s16le' for 16-bit wav and 'pcm_s32le' for 32-bit wav.

        bitrate
          Audio bitrate, given as a string like '50k', '500k', '3000k'.
          Will determine the size and quality of the output file.
          Note that it mainly an indicative goal, the bitrate won't
          necessarily be the this in the output file.

        ffmpeg_params
          Any additional parameters you would like to pass, as a list
          of terms, like ['-option1', 'value1', '-option2', 'value2']

        write_logfile
          If true, produces a detailed logfile named filename + '.log'
          when writing the file

        logger
          Either 'bar' or None or any Proglog logger

        """
        if not fps:
            if not self.fps:
                fps = 44100
            else:
                fps = self.fps

        if codec is None:
            name, ext = os.path.splitext(os.path.basename(filename))
            try:
                codec = extensions_dict[ext[1:]]["codec"][0]
            except KeyError:
                raise ValueError(
                    "MoviePy couldn't find the codec associated "
                    "with the filename. Provide the 'codec' "
                    "parameter in write_audiofile."
                )

        return ffmpeg_audiowrite(
            self,
            filename,
            fps,
            nbytes,
            buffersize,
            codec=codec,
            bitrate=bitrate,
            write_logfile=write_logfile,
            ffmpeg_params=ffmpeg_params,
            logger=logger,
        )
Ejemplo n.º 10
0
        #throw an error if the file does not exist
        my_file = Path(getcwd() + '/.trash/' + vidTitle + '.mp4')
        try:
            my_abs_path = my_file.resolve(strict=True)
        except FileNotFoundError:
            # doesn't exist
            print('ERROR. \n' + ogVid.title + ' was not downloaded')
            errorList.append(ogVid.title)
        else:
            #exists
            #open the video with moviepy and save it to clip the weird silence off of the end
            clip = AudioFileClip(getcwd() + '/.trash/' + vidTitle + '.mp4')
            ffmpeg_audiowrite(clip,
                              getcwd() + '/MusicFiles/' + vidTitle + '.mp4',
                              fps=44100,
                              nbytes=4,
                              buffersize=2000,
                              codec='aac')
            clip.close()
            print(ogVid.title + ' DOWNLOADED')
file.close()
#delete all the useless files in the .trash folder
filelist = [f for f in listdir(getcwd() + '/.trash/') if f.endswith('.mp4')]
for f in filelist:
    remove(path.join(getcwd() + '/.trash/', f))
print('\nPlaylist to MP4 EXITED.')
print('Program ended: ' + datetime.now().strftime("%Y-%m-%d %H:%M:%S") + '\n')

#print out a list of videos that were not downloaded
if len(errorList) > 0:
    print('WARNING. ' + str(len(errorList)) + ' videos not downloaded.')
Ejemplo n.º 11
0
 def to_audiofile(self,filename, fps=44100, nbytes=2, buffersize=5000,
                   codec='libvorbis', bitrate=None, verbose=True):
     return ffmpeg_audiowrite(self,filename, fps, nbytes, buffersize,
                   codec, bitrate, verbose)
Ejemplo n.º 12
0
 def to_audiofile(self,filename, fps=44100, nbytes=2, buffersize=5000,
                   codec='libvorbis', bitrate=None, verbose=True):
     return ffmpeg_audiowrite(self,filename, fps, nbytes, buffersize,
                   codec, bitrate, verbose)