2 pass h264 encode for size limit

Questions and answers on how to get the most out of FFAStrans
momocampo
Posts: 595
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

2 pass h264 encode for size limit

Post by momocampo »

Hello All,

Another workflow to create and I want to limit the size of my output encoded file. I must limit size to be sure the output file can enter in a mailbox.
I saw I have to do 2 pass with ffmpeg but I must say I don't know how write this in a custom ffmpeg node. Is it possible indeed? Someone has already create a workflow with 2 pass in FFastrans?
Thanks for the help ;)

Cheers.

Benjamin
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: 2 pass h264 encode for size limit

Post by emcodem »

Sure... Benjamin, it will be a pleasure for me to try to support you.

in this workflow, i use the cmd processor for it, you will like it i think. All Settings including Output Directory etc.. are set in the first "GLOBAL VARS" processor, check it out.
Example_2-Pass.xml
(7.7 KiB) Downloaded 509 times
The command looks like this:

Code: Select all

cmd /C "cd "%s_working_directory%" && "%s_ffmpeg%" -report  -y -i "%s_source%" %s_encoding_settings% -pass 1 -f mp4 /dev/null && "%s_ffmpeg%" -y -report -i "%s_source%" %s_encoding_settings% -pass 2 "%s_outputfile%"" && "%s_ffmpeg%" -report  -y -i "%s_source%" %s_encoding_settings% -pass 1 -f mp4 /dev/null && "%s_ffmpeg%" -y -report -i "%s_source%" %s_encoding_settings% -pass 2 "%s_outputfile%""
Exploded this means:
1) [cmd /C ""] the doublequotes of cmd /C start before the first command is executed and end after the last command, this is Standard in a cmd processor node

2) then we have 3 DOS commands in one line, they are splitted by &&.
3) First DOS command, everyone should know what this means: [cd "%s_working_directory%"]
4) Then we have 2 ffmpeg commands:
First pass:

Code: Select all

"%s_ffmpeg%" -report  -y -i "%s_source%" %s_encoding_settings% -pass 1 -f mp4 /dev/null 
Second pass:

Code: Select all

"%s_ffmpeg%" -y -report -i "%s_source%" %s_encoding_settings% -pass 2 "%s_outputfile%"

%s_ffmpeg% translates to wherever ffmpeg.exe resides
-report and -y is optional but a good idea, -report will write a log into the directory where we first did cd into
-y will disable the promting for "do you want to override" - just in case ffmpeg is asking
Then -i "s_source" should be clear.
Then %s_encoding_settings% will be replaced by what you did configure in the first GLOBAL VARS node. Note that we do not wrap the encoding settings in "" because they are not a "file path" ;-)
Then -f mp4 for the first pass don't influence, it just prevents ffmpeg from complaining that the output format is not clear.
Then -pass 1 or 2 is hardcoded, it is not a user variable because we will always need this value and it will never change.

Last but not least the output file for the second ffmpeg command (that contains pass 2). %s_outputfile% translates to whatever you input in GLOBAL VARS for the outputfile variable. Note that in difference to the "Custom FFMpeg" node, the output will be written directly into the output directory and we don't need a delivery node.

Let me know any question :-)
Cheers,
emcodem
emcodem, wrapping since 2009 you got the rhyme?
momocampo
Posts: 595
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: 2 pass h264 encode for size limit

Post by momocampo »

Hi emcodem,

FIrst, really kind to help me. I have often some difficulties to use ffmpeg inside ffastrans. I tried directly on DOS and it's ok, it's when I try to use inside ffastrans that I begin to cry :)
Anyway, I tried your workflow but I have an error directly on start "Process exited with error code: 1 (Le chemin d'accès spécifié‚ est introuvable.)" (log file means "path not found")
I added a monitor folder node in front of global variables but same thing.
Honestly you explained me very well, all is clear but it seems the working directory can't be created. Weird.
Are you tested this workflow? I think you do.

Something I don't understand about the 2 pass is where do you specify the final bitrate? Is it the 555k in encoding setting?

Thanks a lot emcodem

Cheers ;)

B.
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: 2 pass h264 encode for size limit

Post by emcodem »

Hey Benjamin,

from feeling, again you suffer from a permission issue: the only thing that should cause this is if you did not set the important %s_working_directory% in the "GLOBAL VARIABLES processor" to an existing and accessable directory.

Let me know if that was your problem.

Cheers,
emcodem
emcodem, wrapping since 2009 you got the rhyme?
momocampo
Posts: 595
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: 2 pass h264 encode for size limit

Post by momocampo »

Hey,

Ok but even I create a folder on desktop, and of course replace the path in global variables, I have even an error message"process exited with error code 1". The log file is well created in the working directory, I found "ffmpeg-20190117-223838.log" in the working directory.
Never mind, I will try tomorrow in my office, I'm at home now and maybe it will be better.
Thanks for your big patience :)

Cheers.
B.
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: 2 pass h264 encode for size limit

Post by emcodem »

Sounds good! ..at least it works for me using the submitted example template when c:\temp exists. Maybe it is best to start from here.
By the way, i did not at all take care about the settings of the transcoding, just entered some random stuff. I concentrated on showing how to get 2-pass working basically.
emcodem, wrapping since 2009 you got the rhyme?
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: 2 pass h264 encode for size limit

Post by admin »

Hi Benjamin :-)
I tried directly on DOS and it's ok, it's when I try to use inside ffastrans that I begin to cry :)
What kind of problems do you have with the custom ffmpeg encoder node? Does it not work as expected?

-steinar
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: 2 pass h264 encode for size limit

Post by emcodem »

I guess using the custom ffmpeg node, the "passfile" from first pass cannot be written to the current directory?
emcodem, wrapping since 2009 you got the rhyme?
momocampo
Posts: 595
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: 2 pass h264 encode for size limit

Post by momocampo »

Hi friends,

@Steinar : Hé hé I recognize your curiosity :) No, don't worry it's not FFastrans which has a problem it's me. I must admit I always some difficulties to understand what is the good way to write ffmpeg command line inside FFastrans.
E.g : yesterday I tried a new H264 encode with H264 node and I just wanted to add a "yadif" to deinterlace my video. So in the bottom of the h264 edit node, I added a "-vf yadif" but doesn't work(it seems to work with x264 params but too for me...)
Anyway, just to tell I am really "too light" with the ffmpeg command line. I am more a video Technician than a programmer even I really like to be one.
I should learn but no enough time, don't worry Steinar, all is ok ;)

@emcodem : I tried this morning on another computer on Windows 7 (I don't know why I have some doubt about the 10 version of windows...). Same thing (the system cannot find the path specified). I created the folder myself and other error message "Process exited with error code: 1 (Input #0, mov,mp4,m4a,3gp,3g2,mj2, from c:\temp\file.mov"
Like yesterday, the log file is in the folder, I join you this log file. I think I see something wrong at the end " no such file or directory" --> bad

Let me know what you think about.

Thanks a lot my friends.
Cheers.

Benjamin
Attachments
ffmpeg-20190118-102546.log
(6.53 KiB) Downloaded 454 times
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: 2 pass h264 encode for size limit

Post by emcodem »

Well i wouldn't see a how to use the Custom ffmpeg node for 2-pass, first i dont know if one can specify an Output Folder for the passfile in ffmpeg (it would be written to the current Directory by Default, but this is C:\windows\syswow64 by Default), second i would not have any idea how to specify "null" Output for the pass1. But using the commandline processor instead makes me more powerful anyway and i don't see any drawback as the running Progress is also parsed and shown on the native monitor.

@Benjamin,thanks for the log, that is very helpful. I dont't understand why it works on my Workstation but not on yours, however, please change the "Encode 2-pass" processor's command:

Find /dev/null in the middle of the command and change it to null
emcodem, wrapping since 2009 you got the rhyme?
Post Reply