Stitch or Concatenate

Questions and answers on how to get the most out of FFAStrans
vijm1972
Posts: 128
Joined: Fri Apr 24, 2015 7:35 am

Stitch or Concatenate

Post by vijm1972 »

Hi Steipal,

I am trying to stitch three source file's and wanted to transcode to one output format, FFAStrans showing audio/video error. I am dropping .txt file in monitor. Same .txt file when I use through FFMPEG command prompt it's properly transcoded.

My text file is

# this is a comment
file 'D:/Stitching_Test/Test1.mxf'
file 'D:/Stitching_Test/Test2.mxf'
file 'D:/Stitching_Test/Test3.mxf'

and command I am using in FFMPEG is -f concat -i D:\Stitching_Test\Inbox\MyList.txt -c copy

Can you please suggest if there is any option in FFAStrans where I can monitor multiple source and stitch them.

Thanks
Vijay
admin
Site Admin
Posts: 1659
Joined: Sat Feb 08, 2014 10:39 pm

Re: Stitch or Concatenate

Post by admin »

Hi Vijay,

The problem is that the "Custom FFmpeg"-encoder is hard coded with "...ffmpeg.exe -i <yourfile>" and it does not put a "-f concat" prior to "-i". So to address these kinds of problems I'm going to modify the existing "Custom FFmpeg"-encoder or create a new one that is more customizable. In the mean time, you can use the "Command executor" instead but then you will not get any progress, other than if you select the "Show console" option.

-steipal
vijm1972
Posts: 128
Joined: Fri Apr 24, 2015 7:35 am

Re: Stitch or Concatenate

Post by vijm1972 »

Hi Steipal,

Please suggest if latest version have concat option enabled, Please provide one sample workflow if possible.

Thanks,
Vijay
admin
Site Admin
Posts: 1659
Joined: Sat Feb 08, 2014 10:39 pm

Re: Stitch or Concatenate

Post by admin »

I'm afraid there is no change here yet. If you want to use the "concat" option you must either use the "Command executor" or set the concat as the 2'nd input in the "Custom FFmpeg"-encoder: "-f concat -i "<your_concat_file.txt>" -map 1.... other options..."

-steinar
ernie1901
Posts: 16
Joined: Fri Aug 07, 2020 8:50 am

Re: Stitch or Concatenate

Post by ernie1901 »

Firstly, what a wonderful application you guys have developed. I've just started experimenting with workflows and have barely scratched the surface of how powerful it could be.
It looks like you have a great community and one I'm exciting to be a part of and contribute into.

My first workflow actually uses the concat function. It works great in CMD and using the 'command executor' processor. However I'd like to use it inside the custom FFMPEG processor for two reasons. When I abort a job the command executor task continues to run. I'd also like percentage feedback in the job monitor views.

Is there a way to achieve a concat inside the Custom FFMPEG processor?
emcodem
Posts: 1643
Joined: Wed Sep 19, 2018 8:11 am

Re: Stitch or Concatenate

Post by emcodem »

Hey @ernie1901 welcome to the Forum and thank you for using ffastrans :-)

Good point about the sub-task of the commandline proc not being cancelled, this is something that steinar (hopefully) solved a few days ago but it will take some time until we get a release version with this enhancement.

The problem with getting it running with the custom ffmpeg node (and all other encoders) is that they do automatically build this line:

Code: Select all

ffmpeg -i "%s_source%"
So you could theoretically get what you want:
There are some caveats:
-) there is an old and a new ffmpeg concat text file style. the old one requires "-f concat" BEFORE -i and as we cannot change anything BEFORE -i for encoding processors, this is not a way to go
-) the new style for concat text files requires the text file to contain "ffconcat version 1.0" in the first line. This makes the use of "-f concate" BEFORE -i obsolete - so this would be a way to go
-) BUT we cannot specify absolute paths in the concat file as this again would require "-safe 0" BEFORE -i in the ffmpeg command

So after all, how it could work is that you place all files to concat in the same folder, then make sure the concat txt file does contain "ffconcat version 1.0" as first line and all other lines contain filenames only, no paths at all.
If you manage to make %s_source% to be the concat txt file (e.g. by watchfolder or by using populate processor), you STILL need to take care that there are "NO BACKSLASHES" in the path to the concat file but FORWARD SLASHES instead of it. (you can use the $relace function to change all backslashes to forward slashes.

To come forward quickly, i recommend to set up a test workflow with one populate node only, not more. This populate processor sets %s_source% to this

Code: Select all

$replace("%s_source%","\","/")
and in the second line, it sets %s_success% to %s_source% (s_success just the message that you see i the Status line when the job is done). When you submit a file by rightclicking the populate processor, the workflow will finish immediately and the job monitor "status" line will show you the changed %s_source% value. If it is your submitted file path but with forward slashes only, you can go on and connect an encoder and deliver node. Submit your concat file again and check out the result.

When all is done, you insert a watchfolder processor and connect it to the populate processor, set the watchfolder processor to watch only for *.txt (your concat files).

And please let us know how it works out for you :-)

EDIT:
here some example concat file with NEW style:

Code: Select all

ffconcat version 1.0
file live1.mp4
file live2.mp4
emcodem, wrapping since 2009 you got the rhyme?
ernie1901
Posts: 16
Joined: Fri Aug 07, 2020 8:50 am

Re: Stitch or Concatenate

Post by ernie1901 »

Works a treat. Thank you so much @emcodem.

The concat function is so fast I love it!
crispyjones
Posts: 104
Joined: Wed Dec 27, 2017 3:21 am

Re: Stitch or Concatenate

Post by crispyjones »

This is very interesting, I developed my own concatenate workflow using a custom command executor node a few months ago. I did not know about the newer "ffconcat version 1.0" concat syntax style. Let me do this in two posts, I will include my original, working, command executor based concat workflow in this one. I have not experienced, that I know of, the issue @ernie1901 had with the process continuing to run, probably because I haven't been paying attention.

My workflow is actually two separate workflows. Step 1 expects the user to put all the video files they want concatenated into a directory, the name of the directory will end up as the final file name, and that directory is dropped into a watch folder. Concat_step1 iterates through all the files and creates a concat.txt file (using the old concat syntax with full paths because I specify -safe 0 in the next step) and concatExt.txt a file containing the file extension of the video files. Concat_step2 is set to *only* accept concat.txt and uses it as the concat file in an ffmpeg command called by a command executor node along with the concatExt.txt file extension to create the correct output file. It also transcodes to mxf (our house format), delivers it using the name of the initial directory and then deletes everything. It has a final conditional branch in case someone drops the initial video files directly in the watch folder (without a sub-directory) so it will not delete the watch folder on completion. The concat step is amazingly fast.

My next post, when I get to it, will be the issues I am having with the custom ffmpeg rewritten version. I wanted to put this here now as someone might find the first step useful.
Concat_step1.json
Step 1 of two part concatenate workflow
(3.83 KiB) Downloaded 319 times
Concat_step2.json
Step 2 pf two part concatenate workflow
(10.76 KiB) Downloaded 292 times
Last edited by crispyjones on Fri Sep 11, 2020 3:56 pm, edited 1 time in total.
crispyjones
Posts: 104
Joined: Wed Dec 27, 2017 3:21 am

Re: Stitch or Concatenate

Post by crispyjones »

Here is my attempted rewrite of the above workflow using the newer concat syntax and a custom ffmpeg node instead of command processor.

The step1 workflow has been modified to ad ffconcat version 1.0 to the top of the file and not use full paths. The step2 workflow has two debug nodes added, one is a text file block to capture what is going on with %source% and the other is a deploy immediately after the ffmpeg concat node. This workflow fails every time on the xdcam transcode node with this error Cannot parse media file. Might be corrupt. Please do a manual file check. The concat ffmpeg node is working because I get a non-corrupt concatenated file from my deploy debug node. Even more strange is if I take the source path from the debug text file and right-click directly submit it to the xdcam node it processes the file without issue. What am I missing?
Concat_step1_ff.json
step1 of ffconcat version 1.0 workflow
(4.91 KiB) Downloaded 304 times
Concat_step2_ff.json
step2 (broken) of ffconcat version 1.0 workflow
(11.15 KiB) Downloaded 287 times
Last edited by crispyjones on Fri Sep 11, 2020 3:57 pm, edited 1 time in total.
crispyjones
Posts: 104
Joined: Wed Dec 27, 2017 3:21 am

Re: Stitch or Concatenate

Post by crispyjones »

A question that affects both workflows. On step1 I want the user to drop in a folder filled with their video files but there isn't a "forget missing folders" checkbox for watch folders. So users can't use the same folder name twice. Any way to work around that?
Post Reply