VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 15 of 15
Thread
  1. i have two videos a1.mp4 and a2.mp4 from the same source for the testing purpose, they are short.

    how can i join them in to 1?

    i tried 4 ways written in websites somewhere. but all didnt work


    1. ffmpeg.exe -i A1.mp4 -i A2.mp4 A12.mp4 -newvideo -newaudio
    this is my 1st trial but it didnt work

    2. ffmpeg.exe -i A1.mp4 -i A2.mp4 A12.mp4
    didnt work

    3. ffmpeg -i “concat:a1.mp4|a2.mp4” a12.mp4
    didnt work

    4. ffmpeg -i a1.mp4 -i a2.mp4 -filter complex “[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]” -map “[v]” -map “[a]” a12.mp4
    didnt work
    Quote Quote  
  2. Try:

    Code:
    ffmpeg.exe -f concat -i list.txt -c copy a12.mp4
    list.txt is a plain text file that looks like:

    Code:
    file 'a1.mp4'
    file 'a2.mp4'
    Quote Quote  
  3. jagabo is correct as always, but your example #3 should have worked. Please copy the exact error message if you want help with it.

    Note, you show curly quotes (concat:a1.mp4|a2.mp4) but you need straight quotes ("concat:a1.mp4|a2.mp4")

    Code:
    ffmpeg.exe -i "concat:a1.mp4|a2.mp4" -c copy a12.mp4
    https://trac.ffmpeg.org/wiki/Concatenate
    Quote Quote  
  4. ffmpeg.exe -y -f concat -i list.txt -c copy a12.mp4
    file 'b1.mp4'
    file 'b2.mp4'

    working well, but i need this for many file joinings someday, i need the one below

    --------------------------------

    ffmpeg.exe -y -i "concat:b1.mp4|b2.mp4" -c copy a12.mp4

    not working because a12.mp4 was created but it was the same as b1.mp4
    Image Attached Thumbnails Click image for larger version

Name:	ScreenHunter_001.png
Views:	115
Size:	35.1 KB
ID:	41819  

    Last edited by sommers; 6th Jun 2017 at 10:12.
    Quote Quote  
  5. Originally Posted by sommers View Post
    ffmpeg.exe -y -i "concat:b1.mp4|b2.mp4" -c copy a12.mp4

    not working because a12.mp4 was created but it was the same as b1.mp4
    That's what happens for me too. It apparently will only work with file types that can be simply concatenated at the FILE level, like transport streams.
    Last edited by jagabo; 6th Jun 2017 at 11:11.
    Quote Quote  
  6. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    As documented here with example of automating the list file or using process substitution for the concat demuxer.
    Quote Quote  
  7. Another way to build the cat list. Put this in a batch file:

    Code:
    del list.txt
    FOR %%a IN (%*) DO ( @echo File '%%a' >>list.txt )
    Then you can drag/drop files onto that batch file to build your list. Put the batch file in your SendTo folder and you can highlight some files in explorer, right click on them, and select Send To -> filename.bat. Of course, you could include the ffmpeg command in the same batch file to build the list and concatenate all at once. The one problem is this is you don't have much control over the ordering of the list. To get around that problem you can run Notepad within the batch file, between building the list and running ffmpeg.
    Quote Quote  
  8. Here's a full batch file that builds a list of the files dragged onto it, opens Notepad so you can reorder the list, then concatenates the files in the list to an output file of the same name and extension as the first file in the list -- excpet that .cat is added between the name and extension. The pause near the end is to let you see any error messages and review the list.txt file before it's deleted.

    Code:
    del list.txt
    FOR %%a IN (%*) DO ( @echo file '%%~nxa' >>list.txt )
    
    notepad list.txt
    
    "g:\program files\ffmpeg\bin\ffmpeg.exe" -f concat -safe 0 -i list.txt -c copy "%~n1.cat%~x1"
    
    pause
    
    del list.txt
    You will need to change the path to ffmpeg.exe.
    Quote Quote  
  9. aa=FOR %%a IN (%*) DO ( @echo file '%%~nxa' >>list.txt )
    bb=FOR %%a IN (*.*) DO ( @echo file '%%~nxa' >>list.txt )

    what is the difference between aa= and bb=, they both seem to make the same results,
    in other words, the difference between %* and *.*

    >"you can drag/drop files onto that batch file"
    this is amazing. i dont know about this until now. i found there is a potential usage here about console commands and mouse interface. i gotta talk to ztree maker about this if there is a way to implement this with their menus. in other words, all my batch scripts are in the ztreemenu which doesnt support a mouse.

    can you enlighten me with a few words what console symbol or an idea specially makes "console commands and mouse interface" possible from FOR %%a IN (%*) DO ( @echo file '%%~nxa' >>list.txt ), somehow i think it is %%a's ability to pass the mouse selectecd strings to %%a
    Last edited by sommers; 6th Jun 2017 at 21:47.
    Quote Quote  
  10. (%*) are all the arguments on the command line
    (*.*) are all files in the folder

    If you highlight a bunch file files in Explorer and drop them onto a batch file (or program), Explorer passes all the file names to the batch file as if you had typed them. Ie, highlighting file1.mp4 and file2.mp4 then dragging them onto DOIT.BAT is the same as typing "DOIT.BAT file1.mp4 file2.mp4" at the command line.
    Quote Quote  
  11. 1. where can i find some help words about %~x1 from the console command like c:\>for /? but not from the web help.

    2. i need to add some error controls

    IF "%~x1"=="" ECHO "%~x1" & GOTO :EOF
    works

    IF "%*"=="" ECHO "%*" & GOTO :EOF
    doesnt work, how can i make it work?

    ffmpeg.exe -i "concat:a1.mp4|a2.mp4" -c copy a12.mp4
    i hope they make this work someday soon
    Quote Quote  
  12. First, you need a decent command line reference: https://ss64.com/nt/. Beware, the are some variations depending on whether you are using XP, Win7, Win10, etc.

    Originally Posted by sommers View Post
    1. where can i find some help words about %~x1 from the console command like c:\>for /? but not from the web help.
    Parameter Extensions: https://ss64.com/nt/syntax-args.html

    "%~x1" is the extension of the first filename on the command line. "%1" is the first argument on the command line, in this case the first full filename (eg. "C:\folder\filename.ext". "%~dpnx1" is also the full filename. Etc. Be careful, sometimes the filename includes surrounding double quotes, sometimes not. I think the rule with "%1" syntax the name will include quotes if there are spaces in the path/name, otherwise not. With the "%~dpn1" syntax there are no quotes -- you may need to supply them yourself depending on usage.

    Originally Posted by sommers View Post
    2. i need to add some error controls

    IF "%~x1"=="" ECHO "%~x1" & GOTO :EOF
    works

    IF "%*"=="" ECHO "%*" & GOTO :EOF
    doesnt work, how can i make it work?
    In the first case you are testing the first argument on the command line. The second case doesn't make sense -- "%*" is a list of arguments, not any particular argument. I don't think it can ever be null because the first argument, "%0", the name of the batch or exe file, is always present. It's not included in FOR loop processing.

    I used a FOR loop for building the list because it allows for a variable number of arguments. But you could also do it linearly. Ie, instead of:

    Code:
    del list.txt
    FOR %%a IN (%*) DO ( @echo file '%%~nxa' >>list.txt )
    you could use:

    Code:
    del list.txt
    IF EXIST %1 @echo File '%1' >>list.txt
    IF EXIST %2 @echo File '%2' >>list.txt
    IF EXIST %3 @echo File '%3' >>list.txt
    IF EXIST %4 @echo File '%4' >>list.txt
    IF EXIST %5 @echo File '%5' >>list.txt
    IF EXIST %6 @echo File '%6' >>list.txt
    IF EXIST %7 @echo File '%7' >>list.txt
    IF EXIST %8 @echo File '%8' >>list.txt
    IF EXIST %9 @echo File '%9' >>list.txt
    What that does is test for the existence of each file on the command line. If the argument isn't present it doesn't resolve to an existing filename. So only arguments that resolve to valid filenames are added to list.txt.

    With either of those methods you could test for the existence of list.txt to determine if there were any filenames on the command line.

    By the way, if you know that the files to be appended will always be appended in alphabetical order you could use SORT to make sure the names are in the correct order, rather than spawning Notepad.
    Quote Quote  
  13. Code:
    @Echo Off
    
    color 6
    
    del *.tmp
    
    set "d="
    if not defined d set "d=%cd%
    
    del concatList.txt
    
    rem xcopy /y v:\automazioneclip\core\processaTuttiFileMxfSenzaSovrascrivereAVI_SD.bat "%d%"
    
    rem start call "%d%\processaTuttiFileMxfSenzaSovrascrivereAVI_SD.bat"
    
    
    REM -- Define File Filter, i.e. files with extension .txt
    Set FindStrArgs=/E /C:".MXF"
    
    REM -- Extract Ftp Script to create List of Files
    Set "FtpCommand=ls"
    
    
    
    Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\%~n0.ftp"
    Rem Notepad "%temp%\%~n0.ftp"
    
    REM -- Execute Ftp Script, collect File Names
    Set "FileList="
    For /F "Delims=" %%A In ('"Ftp -v -i -s:"%temp%\%~n0.ftp"|Findstr %FindStrArgs%"') Do (
        Call Set "FileList=%%FileList%% "%%A""       
    )
    
    
    REM -- Extract Ftp Script to download files that don't exist in local folder
    Set "FtpCommand=mget"
    For %%A In (%FileList%) Do If Not Exist "%%~A" Call Set "FtpCommand=%%FtpCommand%% "%%~A""
    
    
    
    Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\%~n0.ftp"
    Rem Notepad "%temp%\%~n0.ftp"
    
    For %%A In (%FtpCommand%) Do Echo.%%A
    
    REM -- Execute Ftp Script, download files
    ftp -i -s:"%temp%\%~n0.ftp"
    Del "%temp%\%~n0.ftp"
    
    SETLOCAL Disabledelayedexpansion
    del concatList.txt
    set mypath=
    call :treeProcess
    goto :eof
    
    
    
    :treeProcess
    setlocal
    for %%f in (*.mxf) do echo file '%cd%\%mypath%%%f' >> "concatList.txt"
    
    
    
    
    endlocal
    
    rem ******************************** HD to mp4HD420 MAIN profile media qualità  *********************************** 
    v:\automazioneclip\core\ffmpeg64bitmar2017.exe -threads 12 -y -f concat -safe 0 -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -vf scale=interl=1 -pix_fmt yuv420p -c:v libx264 -profile:v main -level:v 4.1 -g 33 -bf 2 -crf 24 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 MP4_HD_420.MP4
    rem *******************************************************************************************************************************
    pause
    
    rem ******************************** HD to mp4HD qualità standard  *********************************** 
    v:\automazioneclip\core\ffmpeg64bitmar2017.exe -threads 12 -y -f concat -safe 0 -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -pix_fmt yuv422p -c:v libx264 -profile:v high422 -level:v 3 -g 33 -bf 2 -crf 22 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 MP4concatenatoHD.mp4
    rem *******************************************************************************************************************************
    pause
    
    rem ******************************** HD to mp4SD media qualità per fare in fretta crf(SD) a 22  *********************************** 
    v:\automazioneclip\core\ffmpeg64bitmar2017.exe -threads 12 -y -f concat -safe 0 -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -vf yadif=1:tff,scale=w=720:h=576:in_range=tv:out_range=tv,unsharp=luma_msize_x=3:luma_msize_y=3:luma_amount=0.8,colormatrix=bt709:bt601,interlace -sws_flags lanczos+accurate_rnd -pix_fmt yuv422p -c:v libx264 -profile:v high422 -level:v 3 -g 33 -bf 2 -crf 22 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 MP4concatenatoHDtoSDmediaQualita.mp4
    rem *******************************************************************************************************************************
    pause
    
    rem ******************************** HD to mp4SD SD alta qualità ******************************** 
    v:\automazioneclip\core\ffmpeg64bitmar2017.exe -y -f concat -safe 0 -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -color_range 2 -vf yadif=1:tff,zscale=w=720:h=576:f=spline36:r=full,unsharp=luma_msize_x=3:luma_msize_y=3:luma_amount=0.8,colormatrix=bt709:bt601,interlace -color_range 2 -pix_fmt yuv422p -c:v libx264 -profile:v high422 -level:v 3 -g 33 -bf 2 -crf 15 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 MP4concatenatoHDtoSD.mp4
    rem **************************************************************************
    pause
    
    rem ******************************** HD to mp4HD qualità standard  *********************************** 
    v:\automazioneclip\core\ffmpeg64bitmar2017.exe -threads 12 -y -f concat -safe 0 -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -pix_fmt yuv422p -c:v libx264 -profile:v high422 -level:v 3 -g 33 -bf 2 -crf 22 -flags +ildct+ilme -top 1 -c:a ac3 -b:a 320k -ar 48000 -aspect 16:9 MP4concatenatoHD.mp4
    rem *******************************************************************************************************************************
    pause
    
    v:\automazioneclip\core\FFMPEG.exe -threads 12 -y -f concat -i concatList.txt -af "pan=stereo:c0=c0:c1=c1,volume=1.0" -vf crop=720:576:0:32,scale=interl=1:in_range=tv:out_range=tv -pix_fmt yuv420p -c:v libx264 -profile:v main -level:v 3 -g 33 -bf 1 -crf 18 -flags +ilme+ildct -top 1 -x264opts tff=1 -c:a libmp3lame -b: 320k -aspect 16:9 MP4concatenatoTGR_BO_420_SD.mp4
    pause
    
    
    
    
    
    v:\automazioneclip\core\ffmpeg.exe -y -f concat -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -vcodec copy -c:a pcm_s24le -aspect 16:9 concatHD.mov
    
    rem v:\automazioneclip\core\ffmpeg.exe -y -f concat -i concatList.txt -af "pan=stereo:c0=c0:c1=c1,volume=1.0" -vcodec copy -c:a pcm_s24le -aspect 16:9 concatIMX.mov
    
    
    rem ********************** le seguenti 3 linee convertono il file HD concatHD.mov [attenzione a non rinominarlo] in IMX SD ******************************************
    rem v:\automazioneclip\core\ffmpeg.exe -y -i concatHD.mov -af "pan=stereo:c0=c0:c1=c1" -c:a pcm_s16le -ar 48000 tmpAudio.wav
    rem v:\automazioneclip\core\ffmpeg.exe -y -i concatHD.mov -vf yadif=1:tff,scale=720:576,unsharp=luma_msize_x=3:luma_msize_y=3:luma_amount=0.8,colormatrix=bt709:bt601,interlace -sws_flags lanczos+accurate_rnd -an -pix_fmt yuv422p -c:v rawvideo -f rawvideo - | v:\automazioneclip\core\ffmbc.exe -y -f rawvideo -pix_fmt yuv422p -s 720x576 -r 25 -i - -i tmpAudio.wav -acodec pcm_s24le -target imx50 -aspect 16:9 concatHDtoIMX_SD.mxf
    rem *****************************************************************************************************************************************************************
    
    rem *** per TGR Bologna file HD e SD 4:2:0 ***
    rem v:\automazioneclip\core\ffmpeg.exe -y -f concat -i concatList.txt -filter_complex "[0:1] [0:2] amerge" -c:v libx264 -profile:v main -level:v 4.1 -g 33 -bf 1 -crf 18 -flags +ildct+ilme -top 1 -x264opts tff=1:colorprim=bt709:transfer=bt709:colormatrix=bt709 -filter_complex crop=out_h=1080:y=0,scale=interl=1:in_range=tv:out_range=tv -pix_fmt yuv420p -c:a libmp3lame -b:a 320k -ar 48000 -aspect 16:9 MP4concatenatoTGR_BO_420_HD.mp4
    rem v:\automazioneclip\core\ffmpeg.exe -y -f concat -i concatList.txt -af "pan=stereo:c0=c0:c1=c1,volume=1.0" -vf crop=720:576:0:32,scale=interl=1:in_range=tv:out_range=tv -pix_fmt yuv420p -c:v libx264 -profile:v main -level:v 3 -g 33 -bf 1 -crf 16 -flags +ilme+ildct -top 1 -x264opts tff=1 -c:a libmp3lame -b: 320k -aspect 16:9 MP4concatenatoTGR_BO_420_SD.mp4
    
    
    
    
    
    
    
    
    
    
    
    if exist tmpAudio.wav del tmpAudio.wav
    
    
    start "" "%programfiles%\Elecard\Elecard Converter Studio\ConverterStudio.exe"
    
    del concatList.txt
    
    GOTO:EOF
    
    
    :extractFileSection StartMark EndMark FileName -- extract a section of file that is defined by a start and end mark
    ::                  -- [IN]     StartMark - start mark, use '...:S' mark to allow variable substitution
    ::                  -- [IN,OPT] EndMark   - optional end mark, default is first empty line
    ::                  -- [IN,OPT] FileName  - optional source file, default is THIS file
    :$created 20080219 :$changed 20100205 :$categories ReadFile
    :$source http://www.dostips.com
    SETLOCAL Disabledelayedexpansion
    set "bmk=%~1"
    set "emk=%~2"
    set "src=%~3"
    set "bExtr="
    set "bSubs="
    if "%src%"=="" set src=%~f0&        rem if no source file then assume THIS file
    
    
    for /f "tokens=1,* delims=]" %%A in ('find /n /v "" "%src%"') do (
        if /i "%%B"=="%emk%" set "bExtr="&set "bSubs="
        if defined bExtr if defined bSubs (call echo.%%B) ELSE (echo.%%B)
        if /i "%%B"=="%bmk%"   set "bExtr=Y"
        if /i "%%B"=="%bmk%:S" set "bExtr=Y"&set "bSubs=Y"
    
    )
    
    
    
    [Ftp Script 1]:S
    !Title Connecting...
    open 192.168.0.18
    admin
    pdw-f800
    
    !Title Preparing...
    cd clip
    lcd %cd%
    binary
    hash
    
    !Title Processing... %FtpCommand%
    %FtpCommand%
    
    !Title Disconnecting...
    disconnect
    bye
    Quote Quote  
  14. sorry I'm a CAT (not a ConCat) this is my custom batch, I cannot program and code but I use it.
    If you want use a part of it: it auto-connect as ftp site the camera and "download" all .mxf files, create a concat.txt list and do some encode
    Quote Quote  
  15. You can join all the files in MKVMerge / MKVToolnix. The output will be mkv.
    But you can just use this:
    Code:
    ffmpeg -i "a12.mkv" -c copy "a12.mp4"
    after to get an mp4.

    If they are named sequentially, MKVMerge will ask to import and join them all in order.
    Quote Quote  



Similar Threads