dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

ffmpeg-split-README.md (3165B)


      1 # Command Line Video Splitter
      2 
      3 Simple command line Python script that splits video into multi chunks. Under the hood script uses [FFMpeg] so you will need to have that installed. No transcoding or modification of video happens, it just get's split properly.
      4 
      5 Run `python ffmpeg-split.py -h` to see the options. Here are few samples of how it could be used:
      6 
      7 ## Spliting video into equal chunks
      8 
      9 `python ffmpeg-split.py -f big_video_file.mp4 -s 10`
     10 
     11 This splits `big_video_file.mp4` into chunks, and the size of chunk is 10 seconds. Each chunk will be suffixed with numeric index, for example `big_video_file-0.mp4`, `big_video_file-1.mp4`, etc.
     12 
     13 ## Spliting video into euqal chunks with some extra options
     14 
     15 `python ffmpeg-split.py -f -i input.mp4 -s 600 -v libx264 -e '-vf "scale=320:240" -threads 8'`
     16 
     17 This splits `input.mp4` into chunks, and the size of chunk is 600 seconds. With extra option to scale output to `320:240` and use 8 threads to speed up.
     18 
     19 ## Splitting videos into unequal chunks
     20 
     21 In order to create unequal chunks of a video, you'll need to create ***manifest.json***.
     22 
     23 
     24 ***manifest.json***
     25 
     26 ```json
     27 
     28 [
     29     {
     30         "start_time": 0,
     31         "length": 34,
     32         "rename_to": "video1"
     33     },
     34     {
     35         "start_time": 35,
     36         "length": 22,
     37         "rename_to": "video2.mp4"
     38     }
     39 ]
     40 
     41 ```
     42 
     43 Afterwards run:
     44 
     45 `python ffmpeg-split.py -f big_video_file.mp4 -m manifest.json`
     46 
     47 This splits `big_video_file.mp4` into 2 video files, video1.mp4 and video2.mp4. The video1.mp4 is a 34 seconds
     48 clip, starting from 0:00 to 0:34 of the `big_video_file.mp4`.
     49 
     50 
     51 Alternatively, you can use a ***manifest.csv*** file to accomplish the task above.
     52 
     53 ***manifest.csv***:
     54 
     55 ```CSV
     56 
     57 start_time,length,rename_to
     58 0,34,video1
     59 35,22,video2
     60 
     61 ```
     62 
     63 
     64 #### Manifest Options
     65 
     66 * start_time      - number of seconds into the video or start time
     67 * length          - length of the video in seconds. The end time of the video is calculated by the start_time plus the length of the video.
     68 * rename_to       - name of the video clip to be saved
     69 * end_time        - end time of the video
     70 
     71 
     72 ## Additional Arguments
     73 
     74 * -v or --vcodec        ffmpeg video codec to be used.
     75 * -a or --acodec        ffmpeg audio codec to be used.
     76 * -m or --manifest      manifest file to control the splitting of videos.
     77 * -f or --file          video file to split.
     78 * -s or --split-size    seconds to evenly split the videos
     79 * -e or --extra         extra optional options for ffmpeg, e.g. '-e -threads 8' to use 8 threads to speed up.
     80 
     81 #### Notes:
     82 
     83 The -s and -m options should not be used together. If they are, -m option takes
     84 precedent over the -s option
     85 
     86 
     87 ## Known Issues with ffmpeg
     88 
     89 * There might be some videos that aren't showing properly after splitting the source video with ffmpeg. To resolve
     90 this, use the -v option and pass in the associated video codec for the source video or video format. For example, mp4 videos
     91 use h264 video codec. Therefore, running the command
     92 `python ffmpeg-split.py -f example.mp4 -s -v h264`, may resolve this issue.
     93 
     94 
     95 ## Installing ffmpeg
     96 
     97 See [FFmpeg installation guide](https://www.ffmpeg.org/download.html) for details.
     98 
     99 
    100 
    101 
    102 [FFMpeg]: https://www.ffmpeg.org/
    103 
    104