Skip to content

Instantly share code, notes, and snippets.

@Roninkoi
Created August 5, 2022 00:21
Show Gist options
  • Select an option

  • Save Roninkoi/0153cffc3d41d7ad80e9b02d76ddfa0b to your computer and use it in GitHub Desktop.

Select an option

Save Roninkoi/0153cffc3d41d7ad80e9b02d76ddfa0b to your computer and use it in GitHub Desktop.

Revisions

  1. Roninkoi created this gist Aug 5, 2022.
    24 changes: 24 additions & 0 deletions tsdl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/sh
    # Download series .ts files and concatenate into mp4 using ffmpeg
    # Usage: tsdl <url> <file prefix i.e. prefix_0.ts>

    if [ $# != 2 ]; then
    echo "Usage: tsdl <url> <file prefix i.e. prefix_0.ts>"
    exit
    fi

    echo "ffconcat version 1.0" > tsdl_list.txt
    i=0
    n=1000
    url=$1
    files=$2
    while [ $i -lt $n ]; do
    file=${files}_$i.ts
    wget ${url}${file} || break
    echo "file ${file}" >> tsdl_list.txt
    i=$((i+1))
    done

    ffmpeg -f concat -i tsdl_list.txt -c copy tsdl_out.mp4
    rm $(grep file tsdl_list.txt | awk '{print $2}')
    rm tsdl_list.txt