LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-16-2019, 08:53 PM   #1
bigrjsuto
LQ Newbie
 
Registered: Jun 2019
Posts: 2

Rep: Reputation: Disabled
Can you get mkvmerge to combine multiple video files while ignoring if one is missing?


I'm trying to download files daily from a list. Each day a new file is created with a date stamp in the file name.

There's a website that posts videos daily. I created a variable using the date function so I can download today's video, delete the oldest video of my choosing (31 days), and re-combine the latest 30 days using mkvmerge.

90% of the time the site puts up a new video, but every once in a while they don't.

I want to be able to get mkvmerge to combine all of the files, even if one of the files is missing, because it's not that big of a deal if it's not there.

When I use mkvmerge I'm combing the multiple files with this:
Code:
mkvmerge -o mergedvideo.mp4
day1.mp4 \+ day2.mp4 \+ day3.mp4   etc...
I've tried the following options that are supposed to ignore errors with other commands, but they don't seem to work:

--ignore-errors
-i
-mkvmerge

Any help would be greatly appreciated.

bigrjsuto
 
Old 06-16-2019, 09:57 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,815

Rep: Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837
I'd write a little script/bit that runs through all of your available vids, then adds them to an array and prints it out somehow in that line, I do completely understand the command line for that app, but the make a list of available vids to be added to it dynamically.

here are some examples I found
https://superuser.com/questions/8889...using-terminal
 
Old 06-21-2019, 02:09 PM   #3
bigrjsuto
LQ Newbie
 
Registered: Jun 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
I'd write a little script/bit that runs through all of your available vids, then adds them to an array and prints it out somehow in that line, I do completely understand the command line for that app, but the make a list of available vids to be added to it dynamically.

here are some examples I found
https://superuser.com/questions/8889...using-terminal
Alright so I went down this rabbit hole and started investigating arrays.

This definitely seems like the way to go.

Unfortunately I'm having other problems now.

The simplest array I found is this

Code:
array=(*.mp4)
This lists, sorted, all the .mp4 files in the directory.

But trying to get mkvmerge to merge all the videos together has been a pain.

In every for loop I try, mkvmerge either over-writes the file through every loop, or it spits out a generic warning, that it also outputs when it succeeds in a merge.

For example:

Code:
for i in *.mp4
do
    i="${i%.mp4}"
    mkvmerge -o arraytest.mp4 "$i.mp4"
done
...continually overwrites the arraytest.mp4 file, so at the end it's the last file.

Code:
       for (( i=1,v=0; i<${#array[@]},v<${#array[@]}; i++,v++))
               do
               mkvmerge -o arraytest$i.mp4 merge$v.mp4 ${array[$i]}
               mv arraytest$i.mp4 merge$v.mp4
               done
       mv arraytest$i.mp4 arraytest.mp4
This one above is trying to have a merge file used as a placeholder so the for loop doesn't overwrite itself every time.
Problem is this one errors out because the initial merge0.mp4 files doesn't exist.

When I run the for loop to read the array and merge all the files into arraytest.mp4, the mkvmerge command fails.
BUT! when I run the mkvmerge command and pass through specific array elements, it works. Which just doesn't make sense to me.

So right now I'm doing this
Code:
mkvmerge -o arraytest.mp4 ${array[0]} + ${array[1]} + ${array[2]} + ${array[3]} + ${array[4]}.... etc
and it works just fine.

I've done this up to 15 elements and it works.
I'm having a hard time understanding why it won't work in a for loop.

This is the generic warning I get upon failure (no other errors output in the terminal) and also on success with the above element-call-out merge:
Code:
No append mapping was given for the file no. 15 ('XXXXXXXX_XXXX_XXXX.mp4'). A default mapping of 15:0:14:0 will be used instead. Please keep that in mind if mkvmerge aborts with an error message regarding invalid '--append-to' options.
I'm not an expert by any means so there could be some easy/obvious thing I'm missing.

Thanks.
 
Old 06-21-2019, 02:43 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware 14.2 current / ArcoLinux / Void Linux
Posts: 8,815

Rep: Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837Reputation: 1837
go over this post, it looks to be something you might be looking for.

https://forums.bunsenlabs.org/viewtopic.php?id=4529

here is another one I found
https://www.linuxquestions.org/quest...to-mkv-773699/

Last edited by BW-userx; 06-22-2019 at 07:49 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] script for processing multple files with mkvmerge pajoe Programming 2 07-24-2012 03:04 AM
LXer: Creating Subtitles from SRT Sources for a Matroska Video with mkvmerge GUI LXer Syndicated Linux News 0 06-17-2011 01:40 PM
Combine multiple one column text file into one text file with multiple colum khairilthegreat Linux - Newbie 7 11-23-2007 01:31 PM
Can you combine multiple PDFs into one? Randux Linux - Software 8 11-21-2007 02:00 PM
Problems with installing/using Matroska's mkvmerge... noware Linux - Software 0 07-26-2006 05:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration