Changes between Version 18 and Version 19 of Concatenate


Ignore:
Timestamp:
Mar 25, 2014, 3:38:36 AM (5 years ago)
Author:
llogan
Comment:

add looping example; nits

Legend:

Unmodified
Added
Removed
Modified
  • Concatenate

    v18 v19  
    1212=== Concat demuxer ===#demuxer
    1313
    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 ) :
     14The 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
     18Create a file `mylist.txt` with all the files you want to have concatenated in the following form (lines starting with a `#` are ignored):
    1919{{{
    2020# this is a comment
     
    2424}}}
    2525
    26 Note that these can be either relative or absolute paths. Then you can encode your files with:
     26Note 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:
    2727{{{
    2828ffmpeg -f concat -i mylist.txt -c copy output
    2929}}}
    3030
    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 {{{
     31It 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
    3435for f in ./*.wav; do echo "file '$f'" >> mylist.txt; done
     36# or with printf
    3537printf "file '%s'\n" ./*.wav > mylist.txt
    3638}}}
     
    4244ffmpeg -f concat -i <(printf "file '%s'\n" ./*.wav) -c copy output.wav
    4345ffmpeg -f concat -i <(find . -name '*.wav' -printf "file '%p'\n") -c copy output.wav
     46}}}
     47
     48You can also loop a video. This example will loop `input.mkv` 10 times:
     49
     50{{{
     51for i in {1..10}; do printf "file '%s'\n" input.mkv >> mylist.txt; done
     52ffmpeg -f concat -i mylist.txt -c copy output.mkv
    4453}}}
    4554
     
    7180}}}
    7281
    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 -bsf bitstream filters will have to be changed).
     82All 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).
    7483
    7584== Concatenation of files with different codecs ==#differentcodec
     
    7786=== Concat filter ===#filter
    7887
    79 The concat filter is available in recent versions of ffmpeg. [http://ffmpeg.org/ffmpeg-filters.html#concat Here] is the official documentation.
     88The concat filter is available in recent versions of ffmpeg. See the [https://ffmpeg.org/ffmpeg-filters.html#concat concat filter documentation] for more info.
    8089
    8190==== Instructions ====
     
    8998}}}
    9099
    91 On the -filter_complex line, the following:
     100On the `-filter_complex` line, the following:
    92101
    93102{{{
     
    95104}}}
    96105
    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).
     106tells 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`).
    98107
    99108{{{
     
    101110}}}
    102111
    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.
     112This 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
     114Note that the single quotes around the whole filter section are required.
    106115
    107116{{{
     
    111120This tells ffmpeg to use the results of the concat filter rather than the streams directly from the input files.
    112121
    113 Note that filters are incompatible with stream copying; you can't use -c copy with 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, 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.
     122Note 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
     124As 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.
    116125
    117126=== Using an external script ===#extscript
    118127
    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.
     128The 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.
    120129
    121130If 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.
     
    123132==== Instructions ====
    124133
    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:
     134Save the script in a file named `mmcat` (or some other name), make it executable (`chmod +x mmcat`) and run it, using the syntax:
    126135{{{
    127136./mmcat <input1> <input2> <input3> ... <output>
     
    132141#/tmp/mcs_v_all: Operation not permitted
    133142}}}
    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)
     143that 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)
    135144
    136145==== Script ====