{ "info": { "author": "Matthew Hayward", "author_email": "mjhayward@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Multimedia", "Topic :: Multimedia :: Graphics", "Topic :: Multimedia :: Graphics :: Editors", "Topic :: Multimedia :: Sound/Audio :: Mixers", "Topic :: Multimedia :: Video", "Topic :: Multimedia :: Video :: Conversion" ], "description": "vedit Overview\n================================================================================\n\nProject homepage at: https://github.com/digitalmacgyver/vedit\n\nvedit is a Python library that simplifies editing and combining video files using ``ffmpeg``.\n\nExamples of the sorts of things vedit makes easy include:\n\n- Extracting a clip from a longer video\n- Combining videos or clips together by concatenating them end to end\n- Composing videos together, for example side by side or overlayed on top of a background image\n- Changing the resolution of a video and cropping or padding a video to change its aspect ratio\n- Overlaying images onto a video\n- Adding an audio track (like a song) to a video\n\nThere are numerous stumbling blocks to these tasks - vedit makes the above things easy by automatically handling videos with:\n\n- Different resolutions\n- Different sample aspect ratios\n- Different pixel formats\n- Different frame rates\n- Different audio streams and channels\n\n----\n\nInstallation\n================================================================================\n\nAssuming you have ``pip`` installed:\n\n pip install vedit\n\nHowever, there is nothing in the package that is special. The only\ndependencies are the ``future`` module and a Python 2.7 or later\n(including Python 3) interpreter. You can just download from the\nproject GitHub repository and put the ``vedit`` directory in your\nPython path of an interpreter that also has ``future`` installed.\n\n----\n\nBefore You Begin\n================================================================================\n\nvedit depends on the ``ffmpeg`` and ``ffprobe`` programs from the FFmpeg_ project, and on the libx264 video codec and the libfdk_aac audio codec, for example by configuring ``ffmpeg`` for compilation with:\n\n ./configure --enable-gpl --enable-libx264 --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libfontconfig\n\n(``--enable-libfreetype --enable-libfontconfig`` only needed if the ``audio_desc`` option is used).\n\n.. _FFmpeg: https://ffmpeg.org/\n\n----\n\nTable of Contents\n================================================================================\n\n- `Examples`_\n\n - `Example 1: Clip 2 seconds out of the middle of a video`_\n - `Example 2: Resize a video with PAD, CROP, or PAN`_\n - `Example 3: Put two videos next to each other`_\n - `Example 4: Replace the audio track of a video`_\n - `Example 5: Overlay videos on top of other videos`_\n - `Example 6: Cascade overlayed videos and images on top of a base video or image`_\n - `Example 7: Add an overlay image, such as a watermark`_\n\n- `Module Concepts`_\n\n - `Windows`_\n - `Display Configuration`_\n - `Videos and Clips`_\n - `Watermarks`_\n - `Audio`_\n\n- `Logging Output`_\n- `Getting Help`_\n- `Contributing`_\n- `Odds and Ends`_\n\n----\n\nExamples\n================================================================================\n\nTo get an idea of the sorts of things you can do with a few lines of code, consider these examples, which can be generated from the ``examples.py`` script in the root directory of the ``vedit`` Python module.\n\nAll the examples below assume that FFmpeg_ is installed as described in `Before You Begin`_.\n\nAll the examples below begin with the following boilerplate, and assume the ``./example_output`` directory exists: ::\n\n #!/usr/bin/env python\n \n import vedit\n import logging\n logging.basicConfig()\n log = logging.getLogger()\n log.setLevel( logging.DEBUG )\n \nBack to `Table of Contents`_\n\n----\n\nExample 1: Clip 2 seconds out of the middle of a video\n--------------------------------------------------------------------------------\n\nLink to input for example: https://youtu.be/9ul6rWAewd4\n\nLink to example output: https://youtu.be/FEr6WMUx_4A\n\n::\n\n # Clipping 2 seconds out of source video from 1.5 seconds to 3.5 seconds.\n source = vedit.Video( \"./examples/testpattern.mp4\" )\n output_file = \"./example_output/example01.mp4\"\n clip = vedit.Clip( video=source, start=1.5, end=3.5 )\n window = vedit.Window( width=source.get_width(), \n height=source.get_height(),\n output_file=output_file )\n window.clips = [ clip ]\n window.render()\n log.info( \"Output file at %s\" % ( output_file ) )\n\nBack to `Table of Contents`_\n\n----\n\nExample 2: Resize a video with PAD, CROP, or PAN\n--------------------------------------------------------------------------------\n\nLink to source input: https://youtu.be/Qmbgrr6WJEY\n\nLinks to example outputs:\n\n- Padded clip: https://youtu.be/2bTdwEzraxA\n- Panned clip: https://youtu.be/lCpbnudnFyc\n- Cropped clip: https://youtu.be/96v-KVq9B-g\n\n::\n\n # Turning a 1280x720 16:9 input video into a 640x480 4:3 video.\n source = vedit.Video( \"./examples/d005.mp4\" )\n clip = vedit.Clip( video=source )\n\n #Since the input and output aspect ratios don't match, pad the input onto a blue background.\n pad_output = \"./example_output/example02-pad.mp4\"\n pad_display = vedit.Display( display_style=vedit.PAD, pad_bgcolor=\"Blue\" )\n window = vedit.Window( width=640, height=480, \n display=pad_display, \n output_file=pad_output )\n window.clips = [ clip ]\n window.render()\n log.info( \"Pad output file at: %s\" % ( pad_output ) )\n\n # Render a cropped version as well. Note the watermark is getting cropped out on the right.\n crop_output = \"./example_output/example02-crop.mp4\"\n crop_display = vedit.Display( display_style=vedit.CROP )\n window = vedit.Window( width=640, height=480, \n display=crop_display, \n output_file=crop_output )\n window.clips = [ clip ]\n window.render()\n log.info( \"Crop output file at: %s\" % ( crop_output ) )\n\n # Render a version where we pan over the input image as it plays as well. Note the watermark moves from left to right.\n pan_output = \"./example_output/example02-pan.mp4\"\n pan_display = vedit.Display( display_style=vedit.PAN )\n window = vedit.Window( width=640, height=480, \n display=pan_display, \n output_file=pan_output )\n window.clips = [ clip ]\n window.render()\n log.info( \"Pan output file at: %s\" % ( pan_output ) )\n\nBack to `Table of Contents`_\n\n----\n\nExample 3: Put two videos next to each other\n--------------------------------------------------------------------------------\n\nExample output: https://youtu.be/fsYw2jLyuQ4\n\n::\n\n # Lets set up some source videos, and some clips for use below.\n video_1 = vedit.Video( \"./examples/i030.mp4\" )\n\n # Put two clips from video 1 side by side, with audio from the\n # left clip only, ending after 8 seconds (we could also use clips\n # from different videos).\n clip_1_0_5 = vedit.Clip( video=video_1, start=0, end=5 )\n clip_1_10_20 = vedit.Clip( video=video_1, start=10, end=20,\n display=vedit.Display( include_audio=False ) )\n\n # Set up two windows, one for each clip, and one to hold the other two, and set the duration.\n #\n # Since clip 1 is 5 seconds long and we are making an 8 second\n # video, there will be time when clip 1 is not playing - set the\n # background color to green during this time.\n output_file = \"./example_output/example03.mp4\"\n base_window = vedit.Window( width=1280*2, height=720, duration=8, bgcolor='Green',\n output_file=output_file )\n # Set the x, y coordinates of this window inside its parent, as\n # measure from the top right.\n #\n # Here we are putting the videos flush side by side, but they\n # could be on top of each other, overlapping, centered in a much\n # larger base_window, etc., etc..\n clip_1_window = vedit.Window( width=1280, height=720, x=0, y=0, clips=[ clip_1_0_5 ] )\n clip_2_window = vedit.Window( width=1280, height=720, x=1280, y=0, clips=[ clip_1_10_20 ] )\n base_window.windows = [ clip_1_window, clip_2_window ]\n base_window.render()\n log.info( \"Side by side output is at: %s\" % ( output_file ) )\n\n\nBack to `Table of Contents`_\n\n----\n\nExample 4: Replace the audio track of a video\n--------------------------------------------------------------------------------\n\nExample outputs:\n \n- Not attributed: https://youtu.be/4Z2Uigssc88\n- Attributed song: https://youtu.be/ojgAs5A5bSg\n\n::\n\n source = vedit.Video( \"./examples/i010.mp4\" )\n output_file = \"./example_output/example04.mp4\"\n # Get a clip, but override any Window settings for its audio.\n clip = vedit.Clip( video=source, display=vedit.Display( include_audio=False ) )\n # Give this window it's own audio track, and set the duration to\n # 10 seconds (otherwise it will go on as long as the audio track).\n #\n # Note - if the window audio track is longer than the video\n # content, it fades out starting 5 seconds from the end.\n window = vedit.Window( audio_file=\"./examples/a2.mp4\", duration=10,\n output_file=output_file )\n window.clips = [ clip ]\n window.render()\n log.info( \"Replaced audio in output: %s\" % ( output_file ) )\n\n # Let's make a version where we attribute the audio with some text.\n song_attribution = '''This video features the song:\n Chuckie Vs Hardwell Vs Sandro Silva Vs Cedric & Quintino\n EPIC CLARITY JUMP- (NC MASHUP) LIVE\n By: NICOLE CHEN\n Available under under a Creative Commons License:\n http://creativecommons.org/licenses/by/3.0/ license'''\n\n output_file = \"./example_output/example04-attributed.mp4\"\n window = vedit.Window( audio_file=\"./examples/a2.mp4\", \n audio_desc=song_attribution,\n duration=10,\n output_file=output_file )\n window.clips = [ clip ]\n window.render()\n log.info( \"Replaced audio in output: %s\" % ( output_file ) )\n\nBack to `Table of Contents`_\n\n----\n\nExample 5: Overlay videos on top of other videos\n--------------------------------------------------------------------------------\n\nExample outputs:\n\n- All audio tracks (bleagh): https://youtu.be/lqLLlXPYg3c\n- Just one audio track: https://youtu.be/hL0t3RXHKAM\n\n::\n\n # Let's overlay two smaller windows on top of a base video.\n base_video = vedit.Video( \"./examples/i030.mp4\" )\n base_clip = vedit.Clip( video=base_video )\n output_file = \"./example_output/example05.mp4\"\n # Use the default width, height, and display parameters:\n # 1280x1024, which happens to be the size of this input.\n base_window = vedit.Window( clips = [ base_clip ],\n output_file=output_file )\n\n # We'll create two smaller windows, each 1/3 the size of the\n # base_window, and position them towards the top left, and bottom\n # right of the base window.\n overlay_window1 = vedit.Window( width=base_window.width/3, height=base_window.height/3,\n x=base_window.width/12, y=base_window.height/12 )\n overlay_window2 = vedit.Window( width=base_window.width/3, height=base_window.height/3,\n x=7*base_window.width/12, y=7*base_window.height/12 )\n \n # Now let's put some clips in each of the overlay windows.\n window_1_clips = [\n vedit.Clip( video=vedit.Video( \"./examples/d007.mp4\" ) ),\n vedit.Clip( video=vedit.Video( \"./examples/d006.mp4\" ) ),\n ]\n window_2_clips = [\n vedit.Clip( video=vedit.Video( \"./examples/p006.mp4\" ) ),\n vedit.Clip( video=vedit.Video( \"./examples/p007.mp4\" ) ),\n vedit.Clip( video=vedit.Video( \"./examples/p008.mp4\" ) ),\n ]\n\n # Now let's embed the clips in the windows, and the overlay\n # windows in our base_window and render.\n overlay_window1.clips = window_1_clips\n overlay_window2.clips = window_2_clips\n base_window.windows = [ overlay_window1, overlay_window2 ]\n base_window.render()\n log.info( \"Made multi-video composition at: %s\" % ( output_file ) )\n\n # Well - the last video looks OK, but it sounds terrible - the\n # audio from all the videos are being mixed together.\n #\n # Let's try again but exclude audio from everything but the base\n # video.\n output_file = \"./example_output/example05-single-audio.mp4\"\n no_audio_display_config = vedit.Display( include_audio=False )\n no_audio_overlay_window1 = vedit.Window( width=base_window.width/3, height=base_window.height/3,\n x=base_window.width/12, y=base_window.height/12,\n display=no_audio_display_config )\n no_audio_overlay_window2 = vedit.Window( width=base_window.width/3, height=base_window.height/3,\n x=7*base_window.width/12, y=7*base_window.height/12,\n display=no_audio_display_config )\n \n # Now let's embed the clips in the windows, and the overlay\n # windows in our base_window and render.\n no_audio_overlay_window1.clips = window_1_clips\n no_audio_overlay_window2.clips = window_2_clips\n base_window.output_file = output_file\n base_window.windows = [ no_audio_overlay_window1, no_audio_overlay_window2 ]\n base_window.render()\n log.info( \"Made multi-video composition with single audio track at: %s\" % ( output_file ) )\n\nBack to `Table of Contents`_\n\n----\n\nExample 6: Cascade overlayed videos and images on top of a base video or image\n--------------------------------------------------------------------------------\n\nExample output: https://youtu.be/K2SuPqWrG3M\n\n::\n\n import glob\n import random\n\n # The OVERLAY display_style when applied to a clip in the window\n # makes it shrink a random amount and be played while it scrolls\n # across the base window.\n #\n # Let's use that to combine several things together and make a\n # huge mess!\n output_file = \"./example_output/example06.mp4\"\n base_video = vedit.Video( \"./examples/i030.mp4\" )\n\n # Let's use a different audio track for this.\n base_clip = vedit.Clip( video=base_video, display=vedit.Display( include_audio=False ) )\n base_window = vedit.Window( clips = [ base_clip ],\n output_file=output_file,\n duration=30,\n audio_file=\"./examples/a2.mp4\" )\n\n # Turn our cat images into clips of random length between 3 and 6\n # seconds and have them cascade across the screen from left to\n # right.\n cat_display = vedit.Display( display_style=vedit.OVERLAY,\n overlay_direction=vedit.RIGHT,\n include_audio=False,\n overlay_concurrency=4,\n overlay_min_gap=0.8 )\n cat_clips = []\n for cat_pic in glob.glob( \"./examples/cat*jpg\" ):\n cat_video_file = vedit.gen_background_video( bgimage_file=cat_pic,\n duration=random.randint( 3, 6 ) )\n cat_video = vedit.Video( cat_video_file )\n cat_clips.append( vedit.Clip( video=cat_video, display=cat_display ) )\n\n # Turn our dog images into clips of random length between 2 and 5\n # seconds and have them cascade across the screen from top to\n # bottom.\n dog_display = vedit.Display( display_style=vedit.OVERLAY,\n overlay_direction=vedit.DOWN,\n include_audio=False,\n overlay_concurrency=4,\n overlay_min_gap=0.8 )\n dog_clips = []\n for dog_pic in glob.glob( \"./examples/dog*jpg\" ):\n dog_video_file = vedit.gen_background_video( bgimage_file=dog_pic,\n duration=random.randint( 3, 6 ) )\n \n dog_video = vedit.Video( dog_video_file )\n dog_clips.append( vedit.Clip( video=dog_video, display=dog_display ) )\n \n # Throw in the clips from the p series of videos of their full\n # duration cascading from bottom to top.\n pvideo_display = vedit.Display( display_style=vedit.OVERLAY,\n overlay_direction=vedit.UP,\n include_audio=False,\n overlay_concurrency=4,\n overlay_min_gap=0.8 )\n pvideo_clips = []\n for p_file in glob.glob( \"./examples/p0*mp4\" ):\n pvideo_video = vedit.Video( p_file )\n pvideo_clips.append( vedit.Clip( video=pvideo_video, display=pvideo_display ) )\n \n # Shuffle all the clips together and add them onto the existing\n # clips for the base_window.\n overlay_clips = cat_clips + dog_clips + pvideo_clips\n random.shuffle( overlay_clips )\n base_window.clips += overlay_clips\n base_window.render()\n log.info( \"Goofy mashup of cats, dogs, and drone videos over Icelandic countryside at: %s\" % ( output_file ) )\n\n\nNote: Since the composition of this video involves several random\nelements, the output you get will not be the same as the example\noutput below.\n\nBack to `Table of Contents`_\n\n----\n\nExample 7: Add an overlay image, such as a watermark\n--------------------------------------------------------------------------------\n\nExample output: https://youtu.be/1PrADMtqdRU\n\n::\n\n import glob\n\n # Let's make our background an image with a song.\n output_file = \"./example_output/example07.mp4\"\n dog_background = vedit.Window( bgimage_file=\"./examples/dog03.jpg\",\n width=960, #The dimensions of this image\n height=640,\n duration=45,\n audio_file=\"./examples/a3.mp4\",\n output_file=output_file )\n \n # Let's put two windows onto this image, one 16:9, and one 9:16.\n horizontal_window = vedit.Window( width = 214,\n height = 120,\n x = (960/2-214)/2, # Center it horizontally on the left half.\n y = 80, \n display=vedit.Display( include_audio=False, display_style=vedit.CROP ) )\n vertical_window = vedit.Window( width=120,\n height=214,\n x = 740,\n y = (640-214)/2, # Center it vertically.\n display=vedit.Display( include_audio=False, display_style=vedit.PAN ) )\n\n # Let's let the system distribute a bunch of our 3 second clips\n # among the horizontal and vertical windows automatically.\n video_clips = []\n for video_file in glob.glob( \"./examples/*00[5-9].mp4\" ):\n video_clips.append( vedit.Clip( end=3, video=vedit.Video( video_file ) ) )\n\n # With these options this will randomize the input clips among\n # the two windows, and keep recycling them until the result is 45\n # seconds long.\n vedit.distribute_clips( clips=video_clips, \n windows=[ horizontal_window, vertical_window ],\n min_duration=45,\n randomize_clips=True )\n\n # Add the overlay windows to the background.\n dog_background.windows = [ horizontal_window, vertical_window ]\n\n # Let's set up a watermark image to show over the front and end of\n # out video. The transparent01.png watermark image is 160x160\n # pixels.\n #\n # Let's put it in the top left for the first 10 seconds.\n front_watermark = vedit.Watermark( filename=\"./examples/transparent01.png\",\n x=0,\n y=0,\n fade_out_start=7,\n fade_out_duration=3 )\n # Let's put it in the bottom right for the last 15 seconds.\n back_watermark = vedit.Watermark( filename=\"./examples/transparent01.png\",\n x=dog_background.width-160,\n y=dog_background.height-160,\n fade_in_start=-15, # Negative values are times from the end of the video.\n fade_in_duration=5 )\n\n # Add watermarks to the background.\n dog_background.watermarks = [ front_watermark, back_watermark ]\n\n dog_background.render()\n log.info( \"Random clips over static image with watermarks at: %s\" % ( output_file ) )\n\n\nBack to `Table of Contents`_\n\n----\n\nModule Concepts\n================================================================================\n\nThere are four main classes in the ``vedit`` module:\n\n``Video``\n ``Video`` represents a given video or image file on the filesystem.\n\n``Clip``\n ``Clip`` represents a portion of a video with a given start and end time. When associated with a ``Window`` and a ``Display`` a ``Clip`` can be rendered into an output video.\n\n``Display``\n ``Display`` configures the properties that a given ``Clip`` has when it is rendered into a given ``Window``.\n\n``Window``\n ``Window`` objects are the building blocks that are used to compose ``Clip`` objects together. The ``width`` and ``height`` properties of a ``Window`` determine the size of a ``Clip`` when it is rendered in that ``Window``. In basic usage one or more ``Clip`` objects are associated with a ``Window`` which is then rendered. In more advanced usage a ``Window`` can include any number of child ``Window`` and ``Clip`` objects to create complex outputs where several different clips play at the same time.\n\nBack to `Table of Contents`_\n\n----\n\nDisplay Configuration\n--------------------------------------------------------------------------------\n\nThe ``Display`` object contains configuration that dictates how a given ``Clip`` appears when the ``Window`` it is in is rendered.\n\nEach ``Clip`` can its own ``Display``, and so can each ``Window``. When considering what ``Display`` settings to use for a given ``Clip`` the following selections are made:\n\n1. If the ``Clip`` has a ``Display`` object, it is used.\n2. Otherwise, if the ``Window`` has a ``Display`` object, it is used.\n3. Otherwise, the ``Default`` display elements described below are used.\n\n**Constructor arguments:**\n\n=================== ======== =============== ====\nArgument Required Default Description\n=================== ======== =============== ====\ndisplay_style No vedit.PAD One of vedit.CROP, PAD, PAN, or OVERLAY\noverlay_concurrency No 3 If display_style is OVERLAY, how many Clips may cascade at the same time\noverlay_direction No vedit.DOWN One of UP, DOWN, LEFT, or RIGHT. If display_style is OVERLAY, what direction the Clips cascade\noverlay_min_gap No 4 If display_style is OVERLAY, the shortest period of time between clips cascade\npad_bgcolor No 'Black' If display_style is PAD, what color should be on the background of the Clip in [0x|#]RRGGBB format\npan_direction No vedit.ALTERNATE One of vedit.UP, DOWN, LEFT, or RIGHT. If display_style is PAN, what direction the Window should pan over the Clip\ninclude_audio No True Should audio from this Clip be included in the output\n=================== ======== =============== ====\n\n**Public methods:** None\n\nThe ``OVERLAY`` ``display_style``\n---------------------------------\n\nThis ``display_style`` makes the ``Clip`` be rendered as a small (randomly sized between 1/2 and 1/3 of the width of its ``Window``) tile that cascades across the ``Window`` while it plays. \n\nThe idea here is to make a collage of images or clips. For a silly example see https://youtu.be/K2SuPqWrG3M - the output for `Example 6: Cascade overlayed videos and images on top of a base video or image`_.\n\nWhen a several ``Clips`` are rendered in a given ``Window`` with the ``OVERLAY`` ``display_style`` the behavior of the cascading is further controlled by:\n\n- ``overlay_concurrency`` - The number of clips that can be in the ``Window`` at once.\n- ``overlay_direction`` - One of ``vedit.UP``, ``DOWN``, ``LEFT``, or ``RIGHT``. The ``Clip`` will move across the ``Window`` in this direction as it plays.\n- ``overlay_min_gap`` - The shortest time in seconds between when two ``Clip`` objects will move across the ``Window``.\n\nCROP, PAD, and PAN\n------------------\n\n``display_style``: When the a ``Clip`` is rendered in a ``Window``, if the ``Clip`` and the ``Window`` do not have the same aspect ratio, something must be done to make the ``Clip`` fit in the ``Window``.\n\nIf the ``display_style`` is:\n\n**CROP**: The ``Clip`` will be scaled to the smallest size such that both its height and width are at least as large as the ``Window`` it is in. The ``Clip`` is then centered in the ``Window`` and any portions of the ``Clip`` that fall outside the ``Window`` are cropped away and discarded.\n\nAs in `Example 2: Resize a video with PAD, CROP, or PAN`_ when: https://youtu.be/Qmbgrr6WJEY is cropped the result is: https://youtu.be/96v-KVq9B-g \n\n**PAD**: The ``Clip`` will be scaled to the largest size such that both its height and width are no larger than the ``Window`` it is in. Then any space in the ``Window`` not covered by the clip is colored the ``pad_bgcolor`` color (defaults to black).\n\nAs in `Example 2: Resize a video with PAD, CROP, or PAN`_ when: https://youtu.be/Qmbgrr6WJEY is padded onto a blue background the result is: https://youtu.be/2bTdwEzraxA\n\n**PAN**: The ``Clip`` will be scaled to the smallest size such that both its height and width are at least as large as the ``Window`` it is in. The ``Clip`` then is scrolled through the ``Window`` in the direction specified by ``pan_direction``. ``pan_direction`` is one of ``UP``\\/``RIGHT``, ``DOWN``\\/``LEFT``, or ``ALTERNATE``.\n\nAs in `Example 2: Resize a video with PAD, CROP, or PAN`_ when: https://youtu.be/Qmbgrr6WJEY is panned with ``pan_direction`` of ``vedit.RIGHT`` the result is: https://youtu.be/lCpbnudnFyc\n\n**Display Examples:** ::\n\n # A display that will crop the input and remove the audio:\n crop_silent = Display( display_style=vedit.CROP, include_audio=False )\n\n # A display that will pad the input with a green background and include the audio from it:\n pad = Display( display_style=vedit.PAD, pad_bgcolor='Green', include_audio=True )\n # Or - more concisely relying on the defaults values for display_style and include_audio:\n pad = Display( pad_bgcolor='Green' )\n\n # A display that will have up to 5 clips cascading over the Window\n at a time, starting no more than once a second, and moving from top\n to bottom:\n cascade_5 = Display( display_style=vedit.OVERLAY, overlay_concurrency=5, overlay_min_gap=1 )\n\n # A display that will pan over the input from bottom to top or right to left (depending on whether the Clip is taller or wider than the Window it is in):\n pan_up = Display( display_style=vedit.PAN, pan_direction=vedit.UP )\n\nBack to `Table of Contents`_\n\n----\n\nWindows\n--------------------------------------------------------------------------------\n\nThe ``Window`` object is used to compose ``Clip`` objects together into a rendered video output. \n\nA ``Window`` has a background of a solid color or static image, and optionally may have:\n\n- A list of ``Clip``s that it will show in order (perhaps cascading through the ``Window`` as they play if the ``Display.display_style`` for that ``Clip`` is ``OVERLAY``). \n- A list of other ``Window`` objects that are rendered on top of it, for example several windows can be composed like: ::\n\n +------------------------------------------+\n | Window 1 |\n | +-------------------------+ |\n | | Window 2 | +---------+|\n | | | | Window 3||\n | | +------------| ||\n | +---------------| Window 4 | ||\n | | | ||\n | | +---------+| ||\n | | | Window 5|+---------+|\n | | +---------+ | |\n | +--------------+ |\n +------------------------------------------+\n\nIn the example above there are five windows:\n\n- Window 1 has child ``Window`` objects: Window 2, Window 3, and Window 4\n- Window 4 has child ``Window``: Window 5\n\nEach of these five ``Window`` objects would have it's own content of Clips, background images, and/or ``Watermark`` objects.\n\n`Example 5: Overlay videos on top of other videos`_ has an example of two Windows overlayed onto another at: https://youtu.be/hL0t3RXHKAM\n\nThe duration of a ``Window``\\'s rendered video output will be:\n\n- The ``duration`` attribute, if set during construction\n- Otherwise, if an ``audio_file`` is specified during construction, the length of that audio stream\n- Otherwise, the longest computed time it will take the clips in this or any of its child windows to play\n\n\n**Constructor arguments:** (presented in rough order of importance)\n\n========================= ======== =============== ====\nArgument Required Default Description\n========================= ======== =============== ====\nwindows No None A list of child Windows. May be set after construction by assigning to the ``.windows`` attribute\nclips No None A list of Clips to render in this Window. May be set after construction by assigning to the ``.clips`` attribute\nbgcolor No 'Black' The background color for this Window that will be shown in regions of this Window that do not otherwise have content (from a Clip, a child Window, or Watermark). May be set with a string in [0x|#]RRGGBB format.\nbgimage_file No None If provided, a background image for this Window that will be shown in regions or times where there is not otherwise content. No scaling is done to this image, so it must be sized at the desired width and height.\nduration No None If specified, the duration of this Window when rendered. Otherwise will default first to the duration of the optional audio_file for this Window, and then to the maximum duration of the Clips in this Window or any of it's child Windows.\nwidth No 1280 Width in pixels of this Window\nheight No 720 Height in pixels of this Window\noutput_file No ./output.mp4 Where to place the output video for when this Window is rendered. Not needed for Windows that are children of other Windows.\ndisplay No None An optional Display object that specifies the Display configuration for Clips in this Window. **NOTE**: If a Clip has its own Display object, it will override the Display configuration of the Window it is placed in. The default values are: ``display_style=PAD``, ``pad_bgcolor='Black'``, ``include_audio=True``.\naudio_file No None If specified the path to an audio file whose first audio stream will be added to the output of this Window.\nx No 0 If this Window is a child of another Window, the x coordinate of the top left corner of this Window, as measured from the top left of the parent Window\ny No 0 If this Window is the child of another Window, the y coordinate of the top left corner of this Window, as measured from the top left of the parent Window\nwatermarks No None A list of Watermark objects that can be used to place static images over everything else in this Window at certain times.\naudio_desc No None If a string is specified it's text will be placed at the bottom left of the window 5 seconds prior to the end of the video.\nz_index No None If not specified Windows will be placed on top of one another in the order they are created, older Windows having lower z_indexes. If specified should be a numeric value, and Windows will be placed underneath other Windows of higher z_index.\npix_fmt No None If specified the pixel format of the output video. Defaults to: yuv420p\nsample_aspect_ratio No None The SAR of a video is the aspect ratio of individual pixels. If specified must be in W:H format. The SAR tine ``Window`` should have when rendered. Defaults to the SAR of the source Video that has provided Clips to this Window. If more than one SAR is present in the inputs a WARNING is issued and 1:1 is used.\noverlay_batch_concurrency No 16 ffmpeg seems to have problems when many overlays are used, resulting in crashes or errors in the resultant video. This parameter configures the maximum number of overlays that will be composed at one time during rendering. If you are having mysterious ffmpeg errors during rendering, try lowering this.\n========================= ======== =============== ====\n\n**Public methods:** \n\n- ``.render()`` - Compose this ``Window``\\'s: ``bgcolor``, ``bgimage_file``, ``audio_file``, ``clips``, child ``windows``, ``watermarks``, and ``audio_desc`` into a video of ``width`` with and ``height`` height and place the output at ``output_file``.\n\n- ``compute_duration( clips, include_overlay_timing=False )`` - Return a float of how long the Clips in the ``clips`` list input would take to render in this ``Window``. If the optional ``include_overlay_timing`` argument is true then instead a tuple will be returned, the first element of which is the duration that would result from the ``clips``, and the second is a list of the start and end times of any ``clips`` whose ``Display.display_type`` is ``OVERLAY``.\n\n**Window Examples:** ::\n \n # Let's assume we have some existing media objects / files to work with:\n clip1 = vedit.Clip( ... )\n clip2 = vedit.Clip( ... )\n clip3 = vedit.Clip( ... )\n watermark = vedit.Watermark( ... )\n background_image = \"./media/background_01.jpg\"\n song = \"./media/song.mp3\"\n\n # A 640x480 window that uses the default Display properties (overridden on a Clip by Clip basis if they have their own Display settings):\n tv = vedit.Window( clips=[ clip1, clip2 ], width=640, height=480 )\n\n # Let's embed the tv window in a 1080x720 window near the top left\n # (50 pixels from the left, 60 from the top), with a background_image.\n #\n # We'll make the hd window 30 seconds long.\n #\n # We'll add our song to the hd window.\n #\n # Note: 1080x720 is the default resolution for a Window, so we don't have to set it.\n\n hd = vedit.Window( windows=[ tv ], bgimage_file=background_image, x=50, y=60,\n duration=30, audio_file=song )\n\n # Let's add a clips to the hd window.\n hd.clips.append( clip3 )\n\n # Let's render the result.\n # \n # Since we didn't set output_file on the hd Window, the output will\n # be placed in ./output.mp4\n hd.render()\n\n\nBack to `Table of Contents`_\n\n----\n\nVideos and Clips\n--------------------------------------------------------------------------------\n\nThe ``Video`` and ``Clip`` objects are tightly related. \n\nA ``Video`` represents a source input file. The primary use of the\n``Video`` object is as an input to the ``Clip`` object's ``video``\nconstructor argument.\n\n**Video Constructor arguments:**\n\n========================= ======== =============== ====\nArgument Required Default Description\n========================= ======== =============== ====\nfilename Yes None The path to a source input file.\n========================= ======== =============== ====\n\n**Video Public methods:** \n\n- ``get_width()`` - Return the width of this video in pixels\n- ``get_height()`` - Return the height of this video in pixels\n\n**Clip Constructor arguments:** \n\n========================= ======== =============== ====\nArgument Required Default Description\n========================= ======== =============== ====\nvideo Yes None A Video object to extract this Clip from\nstart No 0 The time in seconds from the start of the Video this Clip should begin at\nend No End of Video The time in seconds from the start of the Video this Clip should end at. **NOTE:** The end time is the absolute end time in the source Video, not relative to the start time of this Clip.\ndisplay No None If specified, a Display object that determines how this Clip should be rendered\n========================= ======== =============== ====\n\n**Clip Public methods:** \n\n- ``get_duration()`` - Return the width of this video in pixels\n- ``get_height()`` - Return the height of this video in pixels\n\n**Video and Clip Examples:** ::\n\n video1 = vedit.Video( \"./media/video01.avi\" )\n video2 = vedit.Video( \"./media/video02.wmv\" )\n\n # All of video 1\n clip1_all = vedit.Clip( video1 )\n\n # Bits of video2, with Display settings that override whatever the\n # Display settings of the Windows these are eventually included in.\n vid2_display = Display( display_style=vedit.OVERLAY, include_audio=False )\n # From second 3-8.5\n clip2_a = vedit.Clip( video2, start=3, end=8.5, display=vid2_display )\n # From second 12-40\n clip2_b = vedit.Clip( video2, start=12, end=40, display=vid2_display )\n # From second 99 to the end\n clip2_c = vedit.Clip( video2, start=99, display=vid2_display )\n\nBack to `Table of Contents`_\n\n----\n\nWatermarks\n--------------------------------------------------------------------------------\n\nThe ``Watermark`` object gives an easy way to place an image or\nrectangle of a solid color on top of a resulting Window over a certain\ntime in the video.\n\n``Watermark`` objects are applied to a Window by sending a list of\nthem to the ``watermarks`` constructor argument for the ``Window``, or\ncan be applied after construction by setting the ``.watermarks``\nattribute of a ``Window``.\n\n**NOTE:** The image file of a watermark is used as is with no scaling,\n you must ensure the size of the watermark file is appropriate to the\n size of the ``Window`` it is placed in.\n\n**Constructor arguments:** \n\n========================= ======== =============== ====\nArgument Required Default Description\n========================= ======== =============== ====\nfilename Yes None Path to an image file to use for the Watermark. Mutually exclusive with bgcolor.\nx No \"0\" Passed to the ffmpeg overlay filter's x argument to position this watermark. Can be a simple numeric value which will be interpreted as a pixel offset from the left, or something more complex like: ``\"main_w-overlay_w-10\"`` to position near the right of the screen.\ny No \"0\" Passed to the ffmpeg overlay filter's y argument to position this watermark. Can be a simple numeric value which will be interpreted as a pixel offset from the top, or something more complex like: ``\"trunc((main_h-overlay_h)/2)\"`` to position vertically center.\nfade_in_start No None If specified the watermark will begin to appear at fade_in_start seconds. Negative values are interpreted as offsets from the end of the video.\nfade_in_duration No None If specified, the watermark will fade in over this many seconds to full opacity.\nfade_out_start No None If specified, the watermark will begin to vanish at fade_out_start seconds. Negative values are interpreted as offsets from the end of the video.\nfade_out_duration No None If specified, the watermark will fade out over this many seconds to full transparency.\nbgcolor No None Mutually exclusive with filename. If specified, the width and height arguments are required, and the Watermark will take the form of a rectangle of that size and color.\n========================= ======== =============== ====\n\n**Watermark Public methods:** None\n\n**Watermark Examples:** ::\n\n # Let's assume we have an existing Window we want to apply watermarks to.\n window = vedit.Window( ... )\n \n # And a watermark image.\n watermark_file = \"./media/watermark_corner.png\"\n\n # Let's add the watermark image in the bottom right of the video.\n watermark_image = vedit.Watermark( filename=watermark_file, x=\"main_w-overlay_w-10\", y=\"main_h-overlay_h-10\" )\n\n # Let's fade in the window from white over 3 seconds.\n white_intro = vedit.Watermark( bgcolor='White', width=window.width, height=window.height, fade_out_start=0, fade_out_duration=3 )\n\n # Let's fade the window out to black over 5 seconds from the end of the video.\n black_outro = vedit.Watermark( bgcolor='Black', width=window.width, height=window.height, fade_in_start=-5, fade_in_duration=5 )\n\n window.watermarks = [ watermark_image, white_intro, black_outro ]\n\n window.render()\n\nBack to `Table of Contents`_\n\n----\n\nAudio\n--------------------------------------------------------------------------------\n\nThere are a few ways to manipulate the audio of the output:\n\n1. Each Clip can be configured to mix it's audio into the output by virtue of configuring it with a ``Display`` configuration with ``include_audio=True`` (the default).\n2. Alternatively, if the Clip has no such configuration, the Window it is in can have a ``Display`` configuration with ``include_audio=True``.\n3. Finally, each ``Window`` can have it's own audio track via the ``audio_file`` constructor argument.\n\nAll ``Clip`` and ``Window`` who have audio present will see their audio mixed together in the output.\n\nFinally, for ``Window`` objects with an ``audio_file`` argument, if the audio file is longer than the ``duration`` of the window, the volume of that ``audio_file`` stream will fade out over the last 5 seconds of the duration of the ``Window``.\n\n\nBack to `Table of Contents`_\n\n----\n\nLogging Output\n================================================================================\n\nvedit produces lots of output through Python's logging framework. Messages are at these levels:\n\ndebug\n Everything, including command output from ``ffmpeg``\n\ninfo\n Step by step notifications of commands run, but curtailing the output\n \nwarn\n Only notices where vedit is making some determination about what to do with ambiguous inputs\n\nTo enable logging output from a script using ``vedit`` do something like: ::\n\n import logging\n logging.basicConfig()\n log = logging.getLogger()\n log.setLevel( logging.DEBUG )\n\n\nBack to `Table of Contents`_\n\n----\n\nGetting Help\n================================================================================\n\nFile an issue on GitHub for this project https://github.com/digitalmacgyver/vedit/issues\n\nBack to `Table of Contents`_\n\nContributing\n================================================================================\n\nFeel free to fork and issue a pull request at: https://github.com/digitalmacgyver/vedit\n\nBack to `Table of Contents`_\n\n----\n\nOdds and Ends\n================================================================================\n\n- The first video stream encountered in a file is the one used, the rest are ignored.\n- The first audio stream encountered in a file is the one used, the rest are ignored.\n- The output Sample Aspect Ratio (SAR) for a Window can be set. All inputs and outputs are assumed to have the same SAR. If not set the SAR of the Video input will be used, or 1:1 will be used if there is no Video input.\n\n - Some video files report strange Sample Aspect Ratio (SAR) via ``ffprobe``. The nonsense SAR value of 0:1 is assumed to be 1:1. SAR ratios between 0.9 and 1.1 are assumed to be 1:1. \n\n- The pixel format of the output can be set, the default is yuv420p.\n- The output video frame rate will be set to 30000/1001\n- The output will be encoded with the H.264 codec.\n- The quality of the output video relative to the inputs is set by the ffmpeg -crf option with an argument of 16, which should be visually lossless.\n- If all input clips have the same number of audio channels, those channels are in the output. In any other scenario the resultant video will have a single channel (mono) audio stream.\n\nBack to `Table of Contents`_", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/digitalmacgyver/vedit", "keywords": "video ffmpeg", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "vedit", "package_url": "https://pypi.org/project/vedit/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/vedit/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/digitalmacgyver/vedit" }, "release_url": "https://pypi.org/project/vedit/0.0.3/", "requires_dist": null, "requires_python": null, "summary": "Library for editing video by wrapping ffmpeg.", "version": "0.0.3" }, "last_serial": 2478006, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "33a6b1c20e363020f7bbbbe2ed9ddd3c", "sha256": "4c26a78ea6d9c61d96a5ad23e12df0aac4f8ca03ed7c7f7141aa7fb0a2669e47" }, "downloads": -1, "filename": "vedit-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "33a6b1c20e363020f7bbbbe2ed9ddd3c", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 46445, "upload_time": "2016-11-23T04:28:33", "url": "https://files.pythonhosted.org/packages/c3/78/37963ce829b8dd6215d042c91ee3524628470d80cb126dd23ebd924d8619/vedit-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ed00f69a5fd8402c4cabefa41addbfd5", "sha256": "078cfc7afc72f0a3f0c398a31a342bd9d5ad1b08ae0f39f92e15b575accf8a47" }, "downloads": -1, "filename": "vedit-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ed00f69a5fd8402c4cabefa41addbfd5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55463, "upload_time": "2016-11-23T04:28:30", "url": "https://files.pythonhosted.org/packages/fc/88/e23406869fafd982b7c24cde22aac35f9571faa952bf3185c99c0340f241/vedit-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "1cf48f3d91a1f97873206a36d9898118", "sha256": "3c71e1dbefcd7f6e11da6049886da56b28957f25ad38d8fc5acbb0e7c764903c" }, "downloads": -1, "filename": "vedit-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1cf48f3d91a1f97873206a36d9898118", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 46464, "upload_time": "2016-11-23T04:43:33", "url": "https://files.pythonhosted.org/packages/52/aa/6f75e80a8d9162982bcdb722e7ec9021bcba94ec07e19949c95ab3e514ff/vedit-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d88cc7201a7fc27d44a8aab5de8b331", "sha256": "0cb82a2bfdcb958ef2e8d2b3070bd5f79dafa8f5a109bf7fa42230e84dfff8c8" }, "downloads": -1, "filename": "vedit-0.0.2.tar.gz", "has_sig": false, "md5_digest": "5d88cc7201a7fc27d44a8aab5de8b331", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55472, "upload_time": "2016-11-23T04:43:31", "url": "https://files.pythonhosted.org/packages/ec/c3/758f9ce9a892ad64af3911a535dc86722dd7fb9db859ec41f1fa2289a318/vedit-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "c65a37e638312d60dc4af18a11bcc9f4", "sha256": "b80e01347b28682cbfbdc2d77780e99c9f4a4a9ddc9e663511036eefcf280bfa" }, "downloads": -1, "filename": "vedit-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c65a37e638312d60dc4af18a11bcc9f4", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 46464, "upload_time": "2016-11-23T04:47:28", "url": "https://files.pythonhosted.org/packages/9b/b1/596478138c8b6b7ca0d7877fdd301cd769798b8f8d57d24bf296fc302e36/vedit-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7d2c6589c8f08a3ab5e157663e12f87d", "sha256": "7bacd0b64672105e5d71d1bd05f64ef80a048f4a274f754e32f51824b80c0c01" }, "downloads": -1, "filename": "vedit-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7d2c6589c8f08a3ab5e157663e12f87d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55473, "upload_time": "2016-11-23T04:47:26", "url": "https://files.pythonhosted.org/packages/77/ed/aedb1caf69c498b011576f6de7bdabd513b6c61347680d26389f5c7bb669/vedit-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c65a37e638312d60dc4af18a11bcc9f4", "sha256": "b80e01347b28682cbfbdc2d77780e99c9f4a4a9ddc9e663511036eefcf280bfa" }, "downloads": -1, "filename": "vedit-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c65a37e638312d60dc4af18a11bcc9f4", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 46464, "upload_time": "2016-11-23T04:47:28", "url": "https://files.pythonhosted.org/packages/9b/b1/596478138c8b6b7ca0d7877fdd301cd769798b8f8d57d24bf296fc302e36/vedit-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7d2c6589c8f08a3ab5e157663e12f87d", "sha256": "7bacd0b64672105e5d71d1bd05f64ef80a048f4a274f754e32f51824b80c0c01" }, "downloads": -1, "filename": "vedit-0.0.3.tar.gz", "has_sig": false, "md5_digest": "7d2c6589c8f08a3ab5e157663e12f87d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55473, "upload_time": "2016-11-23T04:47:26", "url": "https://files.pythonhosted.org/packages/77/ed/aedb1caf69c498b011576f6de7bdabd513b6c61347680d26389f5c7bb669/vedit-0.0.3.tar.gz" } ] }