Changes between Version 18 and Version 19 of Concatenate
- Timestamp:
- Mar 25, 2014, 1:38:36 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Concatenate
v18 v19 12 12 === Concat demuxer ===#demuxer 13 13 14 The concat demuxer was added to ffmpeg 1.1 . You can read about it in the [http://ffmpeg.org/ffmpeg-formats.html#concat documentation].15 16 ==== Instructions ==== 17 18 Create a file "mylist.txt" with all the files you want to have concatenated in the following form ( Lines starting with a dash are ignored ):14 The concat demuxer was added to FFmpeg 1.1. You can read about it in the [https://ffmpeg.org/ffmpeg-formats.html#concat documentation]. 15 16 ==== Instructions ==== 17 18 Create a file `mylist.txt` with all the files you want to have concatenated in the following form (lines starting with a `#` are ignored): 19 19 {{{ 20 20 # this is a comment … … 24 24 }}} 25 25 26 Note that these can be either relative or absolute paths. Then you can encode your files with:26 Note that these can be either relative or absolute paths. Then you can [https://ffmpeg.org/ffmpeg.html#Stream-copy stream copy] or re-encode your files: 27 27 {{{ 28 28 ffmpeg -f concat -i mylist.txt -c copy output 29 29 }}} 30 30 31 It is possible to generate this list file with a bash for loop, or using printf. Either one of the following would generate a list file containing every *.wav in the working directory: 32 33 {{{ 31 It is possible to generate this list file with a bash for loop, or using `printf`. '''Either''' of the following would generate a list file containing every *.wav in the working directory: 32 33 {{{ 34 # with a bash for loop 34 35 for f in ./*.wav; do echo "file '$f'" >> mylist.txt; done 36 # or with printf 35 37 printf "file '%s'\n" ./*.wav > mylist.txt 36 38 }}} … … 42 44 ffmpeg -f concat -i <(printf "file '%s'\n" ./*.wav) -c copy output.wav 43 45 ffmpeg -f concat -i <(find . -name '*.wav' -printf "file '%p'\n") -c copy output.wav 46 }}} 47 48 You can also loop a video. This example will loop `input.mkv` 10 times: 49 50 {{{ 51 for i in {1..10}; do printf "file '%s'\n" input.mkv >> mylist.txt; done 52 ffmpeg -f concat -i mylist.txt -c copy output.mkv 44 53 }}} 45 54 … … 71 80 }}} 72 81 73 All MPEG codecs ( h.264, MPEG4/divx/xvid, MPEG2; MP2, MP3, AAC) are supported in the mpegts container format, though the commands above would require some alteration (the -bsfbitstream filters will have to be changed).82 All MPEG codecs (H.264, MPEG4/divx/xvid, MPEG2; MP2, MP3, AAC) are supported in the mpegts container format, though the commands above would require some alteration (the `-bsf` bitstream filters will have to be changed). 74 83 75 84 == Concatenation of files with different codecs ==#differentcodec … … 77 86 === Concat filter ===#filter 78 87 79 The concat filter is available in recent versions of ffmpeg. [http://ffmpeg.org/ffmpeg-filters.html#concat Here] is the official documentation.88 The concat filter is available in recent versions of ffmpeg. See the [https://ffmpeg.org/ffmpeg-filters.html#concat concat filter documentation] for more info. 80 89 81 90 ==== Instructions ==== … … 89 98 }}} 90 99 91 On the -filter_complexline, the following:100 On the `-filter_complex` line, the following: 92 101 93 102 {{{ … … 95 104 }}} 96 105 97 tells ffmpeg what streams to send to the concat filter; in this case, streams 0 and 1 from input 0 ( input1.mp4 in this example), and streams 0 and 1 from input 1 (input2.webm).106 tells ffmpeg what streams to send to the concat filter; in this case, streams 0 and 1 from input 0 (`input1.mp4` in this example), and streams 0 and 1 from input 1 (`input2.webm`). 98 107 99 108 {{{ … … 101 110 }}} 102 111 103 This is the concat filter itself. n=2 is telling the filter that there are two input files; v=1 is telling it that there will be one video stream; a=1 is telling it that there will be one audio stream. [v] and [a] are names for the output streams,to allow the rest of the ffmpeg line to use the output of the concat filter.104 105 Note that the single quotes ' 'around the whole filter section are required.112 This is the concat filter itself. `n=2` is telling the filter that there are two input files; `v=1` is telling it that there will be one video stream; `a=1` is telling it that there will be one audio stream. `[v]` and `[a]` are names for the output streams to allow the rest of the ffmpeg line to use the output of the concat filter. 113 114 Note that the single quotes around the whole filter section are required. 106 115 107 116 {{{ … … 111 120 This tells ffmpeg to use the results of the concat filter rather than the streams directly from the input files. 112 121 113 Note that filters are incompatible with stream copying; you can't use -c copywith this method. Also, I'm not sure whether softsubs are supported.114 115 As you can infer from this example, multiple types of input are supported, an ything readable by ffmpeg should work. The inputs have to be of the same frame size, and a handful of other attributes have to match.122 Note that filters are incompatible with [https://ffmpeg.org/ffmpeg.html#Stream-copy stream copying]; you can't use `-c copy` with this method. Also, I'm not sure whether softsubs are supported. 123 124 As you can infer from this example, multiple types of input are supported, and anything readable by ffmpeg should work. The inputs have to be of the same frame size, and a handful of other attributes have to match. 116 125 117 126 === Using an external script ===#extscript 118 127 119 The following script can be used to concatenate multiple input media files (containing audio/video streams) into one output file (just like as if all the inputs were played in a playlist, one after another). It is based on this FAQ item: [http ://ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f How can I join video files], which also contains other useful information.128 The following script can be used to concatenate multiple input media files (containing audio/video streams) into one output file (just like as if all the inputs were played in a playlist, one after another). It is based on this FAQ item: [https://ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f How can I join video files], which also contains other useful information. 120 129 121 130 If you find any bugs, feel free to correct the script, add yourself to the list of contributors and change the version string to reflect your change(s) or email the author with your patch, whatever you find more convenient. … … 123 132 ==== Instructions ==== 124 133 125 Save the script in a file named "mmcat" (or some other name), make it executable (chmod +x mmcat) and run it, using the syntax:134 Save the script in a file named `mmcat` (or some other name), make it executable (`chmod +x mmcat`) and run it, using the syntax: 126 135 {{{ 127 136 ./mmcat <input1> <input2> <input3> ... <output> … … 132 141 #/tmp/mcs_v_all: Operation not permitted 133 142 }}} 134 that could mean that you don't have correct permissions set on /tmp directory (or whatever you set in TMP variable) or that decoding of your input media has failed for some reason. In this case, it would be the best to turn on the logging (described in the script's comments)143 that could mean that you don't have correct permissions set on `/tmp` directory (or whatever you set in TMP variable) or that decoding of your input media has failed for some reason. In this case it would be the best to turn on the logging (as described in the script's comments) 135 144 136 145 ==== Script ====
