I have some video files I need to convert and join
I can do all tasks individually but I can't work out how
to get ffmpeg to do all tasks in one go.
Job example:
1 have 3 video files in MKV format H264 video and mpeg2 audio
I want to convert the audio of each to AC3 640K
And join all 3 files to make one single playable .TS file.
I know how to convert the audio and to make the result a .TS for individual files
but I can't work out how to do that and join them all in one go.
At the moment I have to convert each file and then join them in TSmuxer
which I shouldn't need to do.
Can anyone help?
+ Reply to Thread
Results 1 to 12 of 12
-
-
nope - still problems
This is what I am trying - I've based that on pandy's link "concat of files with different codecs" example:
ffmpeg -i fred.mkv -i jim.mkv -i sheila.mkv -filter_complex '[0:v:0] [0:a:0] [1:v:0] [1:a:0] [2:v:0] [2:a:0] concat=n=3:v=1:a=1 [v] [a]'
-map '[v]' -map '[a]' output.mkv
This should be a simple concat (I've removed all conversions for simplicity but I get the same message with them)
The error is "output file #0 does not contain any stream"
I can't work out why - any suggestions?
I have tried simplifying the filter to [0:0] [0:1] [1:0][1:1] ... etc with no luck
I have also tried the -c:v copy functions but the same results (I know the wiki page says copy doesnt work with concat but I'm not sure exactly how that would apply right there - it doesnt work with or without anyway...
ps - I'm using the latest ffmpeg -
OK progress...
It seems I have to use double quotes for all the filter options not single quotes
(In batch files or on the command line - command line PHP doesn't seem to care) - odd - MS again.
(No ^ escaping or quoting doesnt seem to work)
Anyway I can now merge and convert the audio to AC3 on the fly but immediately there is a problem.
I need the output in .TS format (or there is no point my trying to do this) but ffmpeg converts
the video stream to mpeg2 every time TS output is used.
I just want it to leave the video alone.
Since the copy function can't be used with filters does anyone know how I can stop it re-encoding the video.
(When output is to MKV it does leave it alone but that's no use to me)
My guess is ffmpeg has a format default and re-encodes even when not asked to.
Ideally I need a way to force the video stream to just copy. -
If they are the same characteristics, you can use concat demuxer - that allows stream copy. It looks like you are using concat filter - which means you re-encode
-filter_complex and -vf mean video is decompressed, thus no stream copy is allowed -
Ah I see - thanks poisondeathray - I didn't realise that I should be using a different filter- I'll look into it later today.
-
ok I can now complete the task but I have another issue: the concat merge filter is creating a ghost video file in mpeg2 format in addition
to the outfile.ts output
This only happens if I use a .ts extension on the output - the same command on the same files outputting to MKV does not do this
This "ghost file" has no filename except ".ts"
This is an issue as it slows everything down to 10fps instead of around 400fps
I have tried using -map to ensure I only get the streams I need without success
Simplifying the bare minimum also does this:
ie:
ffmpeg -f concat -i merge.lst outfile.ts
if outfile.mkv is used I do not get the ghost file
Does anyone have any suggestions?
thanks -
Did you use -c copy as in the example on the ffmpeg concatenate page?
If it still doesn't work you can do a 2 step batch, one to mkv, one to rewrap to .ts ; or use a batch using tsmuxer, or a combination of them because you need to re-encode the audio anyways.
If that still doesn't work, post the info requested earlier on your files. Because if there are incompatibilities , you might have to re-encode at least part of the video(s) -
Found it -
It was just an extra space in an unquoted variable causing 2 files to be output...
I'll record it here because it's a tricky one to spot being an OS dependant thing:
as a second command in a dos batch file "For " statement I had
"set variable=%%A )"
which is fixed by using
"set variable=%%A)"
The extra space is causing the output filename plus a .ts name because I was using
ffmpeg -f concat -i merge.lst %variable%.ts
Expanding a space before the .ts
I'm working up a basic batch file that does the job which I'll post later.
Be warned if you want to use it it will be designed just to do my task - you may need to add
error checking or extra quoting etc yourself
Thanks for the input though guys - it's all been helpful and I'm learning more about ffmpeg every
time something goes wrong!
P.S.
I'm doing this partly because I have some files that TSmuxer converts to .TS but also causes
them to have the dreaded "monotonous DTC" errors that didnt exist in the files before.
I'm hoping not to use TSmuxer again. -
This works for me - but it's very simple and you will probably need to adjust things:
Code:@echo off REM filename: merge.bat REM Created on windows-7 64 REM PURPOSE: Merges all MKV files in folder into 1 file converting audio REM to AC3 on fly outputting to .TS container REM REQUIRES: ffmpeg (recent) Input files audio DTS or similar for conversion to AC3 rem Known issue: PCM audio must be converted before using this rem Tested only on HD H264 video with DTS audio - no other streams rem If paths or filenames have spaces you will need to quote REM USAGE NOTES: rem Place this batch file in folder with all MKV's to be merged. rem Files will be added in standard sort order rem Customise paths to requirements then just call "merge.bat" rem DesitinationDir contains merged output rem Having source dir on different drive just to speed things up rem improvements possible such as quoting, I/O changes filtering etc. rem Consider this a work in progress skeleton to customise rem I hope someone finds this useful. rem jack616 :INIT set sourcedrive=%~d0% set sourcedir=%cd% set destinationDir=d:^\ffmpegTemp set workingdrive=d: rem if not already set do (or wherever yours is stored): rem set path=%PATH%;c:\media\ffmpeg\bin; :START %sourcedrive% cd %sourcedir% rem clean the merge list echo # Start > merge.lst REM WARNING: Keep the ')' next to the %%A in the 'set thisFile=' function or a rem space is appended in output filename for %%A in (*.mkv) do ( @echo file %%A >> merge.lst set thisfile=%%A) echo # End merge list >> merge.lst rem final output name based on last input name + .ts rename manually as reqd. ffmpeg -f concat -i merge.lst -acodec ac3 -ar 48000 -b:a 640k -c:v copy %destinationDir%^\%thisfile%.ts echo . echo End. echo Output is in %destinationDir% :END
Similar Threads
-
Right way to join two different video files using ffmpeg?
By yetanotherlogin in forum EditingReplies: 15Last Post: 25th Jun 2021, 02:25 -
[SOLVED] How to join MP4 files where some have more than one audio stream?
By yetanotherlogin in forum EditingReplies: 3Last Post: 19th Nov 2015, 04:32 -
Merge (Join) and Convert with the same Program
By AndreL in forum Video ConversionReplies: 8Last Post: 17th Jul 2014, 11:52 -
Need to join two videos with FFMPEG
By wolfox in forum EditingReplies: 1Last Post: 5th Oct 2012, 16:46 -
How to join four .flv files in to one .flv file using ffmpeg?
By spiderMan007 in forum EditingReplies: 3Last Post: 26th Aug 2012, 13:18