Concatentating or Combining Multiple Videos into a single file

Concatentating or Combining Multiple Videos into a single file

. 1 min read

I wanted to stream an eCourse to Plex to watch while spinning! Unfortunately, the eCourse was split up (as usually the case) into multiple video files.

This is kinda painful to work with Plex. The most efficient way that I was thought was to combine all the video files into a single file and then stream that to Plex!

Here is the code that I was able to use to achieve that! Seems to work fine!

# Fix names with spaces
# Fix unsafe file name issue
# Fix Whilelist protocol issue
# https://blog.yo1.dog/fix-for-ffmpeg-protocol-not-on-whitelist-error-for-urls/

ls *.mp4 | sed -e "s/ /\\\ /g" | perl -ne 'print "file $_"' | ffmpeg -f concat -safe 0 -protocol_whitelist "file,pipe,http,https,tcp,tls" -i - -c copy Movie_Joined.mp4

Next, I had a masterclass with multiple mp4 files in subfolders. Concatenating them involved recursively finding the files and concatenating them after that using:

find . -type f -name '*.mp4' | sed -e "s/ /\\\ /g" | perl -ne 'print "file $_"' | ffmpeg -f concat -safe 0 -protocol_whitelist "file,pipe,http,https,tcp,tls" -i - -c copy Movie_Joined.mp4

Masterclass - Margaret Atwood Teaches Creative Writing

Next, I had a large udacity course and combining the whole thing was too bulky! I decided to split the course up into each module. This worked simply with a small tweak as follows and also added a fix for sorting so that order was maintained!!:

find . -type f -name '*.mp4' | sort | grep 01-Module | sed -e "s/ /\\\ /g" | perl -ne 'print "file $_"' | ffmpeg -f concat -safe 0 -protocol_whitelist "file,pipe,http,https,tcp,tls" -i - -c copy 01-Module-Movie_Joined.mp4

Credit: https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg


Tags

AWS Analytics Antifragile Apache Spark Apple Apps Arbitrage Automation Awesome BBMP Bangalore Black Swan Bonds Boonex Bootstrap Brokerage Charges CFPB CMS CSS Calypso Camelot Capital Markets Charts Chirp Choropleth Chrome Code Igniter Collections Containerization Converters Cycling DalalBeat Data Analytics Data Journalism Data Mining Data Munging Data Privacy Data Science Databases Debt Design Design Stock DesignStock Diet Django Docker Document Processing Dropbox Electron Electronics Entertainment Entrepreneurship Exercise FFMPEG Facebook Finance Fire TV Stick Fitness Forerunner From-The-News Fun Futures Gaana Garmin General Geocoding Getting Started Ghost Google APIs GraphicsMagick HHVM HTTPS Hackathon Hacks Hardware Health House Keeping Housing IBM BlueMix IBrokers IPinfo Ideas Image Conversion Image Processing Infographics Interactive Brokers Internet Investing IoT Legal Lets Encrypt Mac Machine Learning Mailbox app Mapbox Markdown Marketing Meteor Mockups MongoDB Mortgages Movies Music MyPad MySQL Nativefier Nature Netflix Newsletters Nginx Node.js Notes OCR OSX Open Source OpenCPU Options PDF PHP Pebble Peloton Personal Photography Picture Platforms Plex Portable Apps Productivity Property Tax PyroCMS Quantitative Finance R-Project Random Raspberry Pi Research Resources Reticulate Robot S3 SQLite STT Scraping Security Server Shell Shiny Side Project Sikuli Speech Recognition Spider Pro Spinning Spotify Startup Resources Startups Strategy Sublime Text System Monitoring Tax Terminal Tips To Do Tools Torrent Trading Trends Troubleshooting USElection2016 Ubuntu Unix Valuations Video Conversion Visualization Wagtail Wearables Weekend Fun WhatsApp Wordpress anaconda annie bash catalina cv2 daily coding dailycoding data.table debugging devtools downloader e-Signatures ggplot git go google maps hat-tip iOS iPad iPhone iTunes javascript jupyter logging macos numpy opencv optionality plotly python rstats videos youtube