Yuhang He's Blog

Some birds are not meant to be caged, their feathers are just too bright.

stream multiple videos into one video

Machine learning or computer vision practitioners often have to deal with videos. The prerequisite is to download video from servers, or further need to stream multiple small videos into one video, with its format changed (for instance, .flv to .mp4). Here I give a simple way to do this: First, download the video from web server with youtube-dl. Although it is initially designed for downloading videos from youtube, it covers most video servers in China, like youku, aiqiyi. It works as:

youtube --all-formats url

Assume that you have all the video downloaded, then all you have to do is to list all videos you want to stream into a file, as:

file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

Note that /path/ can be either relative or absolute paths. Then you can stream copy or re-encode your files into whatever format you want, like .mp4, with the following shell script:

ffmpeg -f concat -i test.txt -c copy kela.mp4

Of course, in order to let it work, you should pre-install FFmpeg in your OS.

Now, just enjoy this technique.