VideoHelp Forum
+ Reply to Thread
Results 1 to 28 of 28
Thread
  1. Hi cats,

    I would like encode for dvd using ffmpeg and optimise bitrate.

    Please consider this partial commandline

    Code:
    ffmpeg.exe -y -i input.avi -f dvd -target pal-dvd -b:v 8000k -r 25 -vf scale=720:576 -ar 48000 -b:a 224k output.mpg
    I need to generate an output.mpg for a dvd of 4,7GB and one for dvd of 9GB (dual layer)

    How can I tell to ffmpeg that I have 4,7 or 9 GB?

    And how can I tell that ffmpeg have to use variable bitrate, and what is a correct range?

    In everycase the output don't have to exceed the 4,7 or 9GB fixed, but the bitrate have to be the maximum possible compatible with the lenght of the input video

    so that maxrate = 8000000
    and minrate = 0

    thanks
    Quote Quote  
  2. You should use a decent MPEG-2 encoder. If you don't have the use of a decent commercial one, then HCEnc is way better.

    To get the final size you want you use a bitrate calculator to figure the video bitrate when given the final size and the audio bitrate and muxing overhead minus the size of any menus or anything else. Oh, and those sizes are 4.37 and 8.5, not 4.7 and 9.

    You don't need to encode the audio so you can have an MPG made. Any authoring program that even accepts an MPG as a source will demux it internally before authoring it for DVD. Most people will feed the authoring program elementary streams (separate audio and video files) and let the program take it from there.

    Not what you wanted to hear, I don't suppose, but in my opinion your workflow is amateurish and inferior. Others may disagree. And I'm not a cat and neither are you, as much as you might wish it otherwise. You just make yourself sound foolish.
    Quote Quote  
  3. Use a dvd bitrate calculator and enter the bitrate

    EDIT: yeah, what manono said ^
    Quote Quote  
  4. You use 4:2:2 some lossless or whatever you use, HD as original and then you let ffmpeg mpeg2 encoder to encode, not really the best solution, here is the solution with HcEncoder, btw. all that was in those scripts I linked in your previous thread:
    Code:
    echo AviSource("HD_interlaced_input_tff.avi", audio = false)   > "input.avs"
    echo ConverttoYV12()  >> "input.avs"
    echo Load_Stdcall_plugin("C:\Avisynth 32-bit Plugins\yadif.dll")  >> "input.avs"
    echo Assumetff()  >> "input.avs"
    echo Yadif(mode=1,order=1)  >> "input.avs"
    echo Spline16Resize(720,576)  >> "input.avs"
    echo Blur(0,0.5)  >> "input.avs"
    echo # or use IResize  >> "input.avs"
    echo ColorMatrix(mode="Rec.709->Rec.601", clamp=0)   >> "input.avs"
    echo AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave()  >> "input.avs"
    
    aften.exe -b 256000 "audio.wav" "audio.ac3"
    HCenc_025.exe -i "input.avs" -o "video.m2v" -INTERLACED -TFF -AUTOGOP 15 -CQ_MAXBITRATE 3 -AQ 2 -MAXBITRATE 8000 -aspectratio 16:9 -logfile "hc.encoder.log"
    HC.ini could be:
    Code:
    *MAXBITRATE       8000
    *PROFILE          best
    *AUTOGOP          15
    *DC_PREC          10
    *PREVIEW
    *INTRAVLC         2
    *MATRIX           mpeg
    *PRIORITY         normal
    *WAIT             0
    that HcEncoder line is 1pass for video that is less than 1hour and 15min long, encoder would not set 8000kbps all the time anyway, for longer times use 2pass:
    rem calculate average bitrate, %average%, use some calculator or subroutine I already gave you
    Code:
    HCenc_025.exe -i "input.avs" -o "video.m2v" -2pass -INTERLACED -TFF -AUTOGOP 15 -MAXBITRATE 8500 -B %average% -aspectratio 16:9 -logfile "hc.encoder.log"
    Last edited by _Al_; 23rd Mar 2015 at 18:53.
    Quote Quote  
  5. thanks but maybe I think there is a problem: my source is one file for video and one file for audio

    source.avi
    source.wav

    with hcenc maybe I need remux in oneInputFile.avi (that have video and audio)

    and then: I need apply a colormatrix bt 709 to 601 conversion during process

    Seems that you use avisynth, as well, but I try to understand if ffmpeg do it all (consider that my source is 460GB and avisynth need 4 hours only for indexing)
    Quote Quote  
  6. consider also my source is interlaced

    and is 1920x1080, so that I need to resize to sd (yadif--> resize--> interlace)

    I have not burn on dvd this mpg but tomorrow I try with:

    Code:
    ffmpeg.exe -y -i source.wav -i source.avi -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  -c:v mpeg2video -f dvd -target pal-dvd -s 720x576 -r 25 -pix_fmt yuv420p -g 15 -flags +ilme+ildct -top 1 -b:v 7448k -maxrate 7448k -minrate 7448k -bufsize 1835008 -packetsize 2048 -pass 1 -ar 48000 -acodec mp2 -b:a 256k output.mpg
    this seems do all-in-one
    Last edited by marcorocchini; 23rd Mar 2015 at 19:12.
    Quote Quote  
  7. ---Avisource does not make any index file,... no indexing here, also color space is changed, also audio and video is treated separately, you did not even looked at it,
    ---secondly your source is interlaced HD, ffmpeg would not make SD interlaced out of it without some magic,..., it is Avisynth that is making that magic here because it uses couple of lines, ..., and resizing of interlace content, it was subject of discussion using endless count of pages ....
    ---the quality of ffmpeg mpeg2 encoder was also mentioned
    Quote Quote  
  8. in avisynth I have try use the AviSource instead of FFVidfeoSource but I get a solid green screen

    about interlaced output: seems to me that x264 support only MBAAF interlaced output instead of PAFF, but when ffmpeg use mpeg2video codec generate pure interlaced output file in PAFF mode

    the quality of ffmpeg's mpeg2 is ? low?

    However I have this

    source.avi
    and
    source.wav

    that is HD 1920x1080 interlaced uncompressed

    466GB the video part
    864 MB the audio part

    is there another way than ffmpeg to generate a DVD mpeg output file? what is that way? thanks
    Quote Quote  
  9. try:
    Code:
    echo AviSource("HD_interlaced_4:2:2_input_tff.avi", pixel_type="YUY2")   > "input.avs"
    change that avi name to your name, no special characters, make sure that path is included if it is not in that folder
    http://avisynth.nl/index.php/AviSource
    Quote Quote  
  10. for kindness I have another question:

    I need encode my catShow of 1 hour and 15 minutes in MP4 but possibly I would like store this in a DVD of 4,7 GB

    so I think use something like this (ffmpeg/x264)

    Code:
    ffmpeg.exe -y -i source.wav -i source.avi -c:v libx264 -profile:v high422 -level:v 4.1 -g 33 -bf 2 -crf 25 -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 yuv422p -c:a libmp3lame -b:a 256k  -aspect 16:9 out.mp4
    but is it correct use the crf? or what is the best way to do this, if that were possible

    I need to keep:

    --> interlace
    --> 4:2:2 colorspace
    --> fullHD resolution
    Quote Quote  
  11. Originally Posted by _Al_ View Post
    try:
    Code:
    echo AviSource("HD_interlaced_4:2:2_input_tff.avi", pixel_type="YUY2")   > "input.avs"
    change that avi name to your name, no special characters, make sure that path is included if it is not in that folder
    http://avisynth.nl/index.php/AviSource
    sorry but it don't wont work

    Click image for larger version

Name:	GREENS.jpg
Views:	348
Size:	131.1 KB
ID:	30861
    Quote Quote  
  12. ok, you need to give more information how you got that avi, post mediainfo, ..., I only guessed it is 4:2:2 from the other thread, I have no idea what it is , you might surprise me as always revealing that it is actually H.264 in there inside , where of course AviSource is useless ....., if it is really avi, how about 2-3sec video posted, so it can be troubleshoot without endless ping-pong what is wrong with that file etc.....

    to encode to certain size you need to encode 2pass, because using 1pass crf you can only guess what the filesize is going to be, as was suggested, get your average bitrate, you did not do anything in that direction, as it was advised above, mpeg2 or mp4, all the same, you need to encode to certain size, you need 2pass, so you can try google "ffmpeg 2pass mp4" it gives you plenty of ideas, understand that search gives you always two ffmpeg lines, each for one pass ...
    Quote Quote  
  13. Originally Posted by _Al_ View Post
    ok, you need to give more information how you got that avi, post mediainfo, ..., I only guessed it is 4:2:2 from the other thread, I have no idea what it is , you might surprise me as always revealing that it is actually H.264 in there inside , where of course AviSource is useless ....., if it is really avi, how about 2-3sec video posted, so it can be troubleshoot without endless ping-pong what is wrong with that file etc.....

    to encode to certain size you need to encode 2pass, because using 1pass crf you can only guess what the filesize is going to be, as was suggested, get your average bitrate, you did not do anything in that direction, as it was advised above, mpeg2 or mp4, all the same, you need to encode to certain size, you need 2pass, so you can try google "ffmpeg 2pass mp4" it gives you plenty of ideas, understand that search gives you always two ffmpeg lines, each for one pass ...
    General
    Complete name : j:\sfilataESP\sfilata.avi
    Format : AVI
    Format/Info : Audio Video Interleave
    Format profile : OpenDML
    File size : 435 GiB
    Duration : 1h 15mn
    Overall bit rate : 830 Mbps

    Video
    ID : 0
    Format : YUV
    Codec ID : YUY2
    Codec ID/Info : YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel
    Duration : 1h 15mn
    Bit rate : 830 Mbps
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate : 25.000 fps
    Color space : YUV
    Chroma subsampling : 4:2:2
    Compression mode : Lossless
    Bits/(Pixel*Frame) : 16.004
    Stream size : 435 GiB (100%)
    Quote Quote  
  14. https://www.dropbox.com/s/uw91ryuwrj42tqa/example.avi?dl=0

    virtualdub opens ok the file, avisynth (avisource) not

    avisynth FFVideoSource is ok.. but is 435GB and indexing need 4 hours in my pc
    Quote Quote  
  15. What about trying with AVStoDVD? It may be set up to use both FFmpeg and HCenc. It accepts separate video/audio sources. It will take care to calculate the bitrate for DVD size output. You can customize the command line options and AviSynth script.

    Ah, there is also the italian language translation...



    Bye
    MrC

    AVStoDVD Homepage
    Quote Quote  
  16. ok thanks, and is there a similar tool to encoding in MP4 H264?

    the most important thing is that it have adjust the VBR so that finale size output is (in everycase the optimum) for dvd 4,7 and 9 GB
    Quote Quote  
  17. Is that avi coming from your NLE that for some reason you do not want to give up? Mediainfo you posted says this:
    Code:
    Codec ID/Info : YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel
    So not sure how to make AviSource to load it, why it does not work or what is going on.
    Quote Quote  
  18. Originally Posted by _Al_ View Post
    Is that avi coming from your NLE that for some reason you do not want to give up? Mediainfo you posted says this:
    Code:
    Codec ID/Info : YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel
    So not sure how to make AviSource to load it, why it does not work or what is going on.
    it become from the Speed Razor f.c. 5.51
    Quote Quote  
  19. Originally Posted by poisondeathray View Post
    Use a dvd bitrate calculator and enter the bitrate
    I wonder: can I encode in VBR mode using ffmpeg foreseeing tha final size?

    for example I like encode in MP4 x264 in VBR, 1 hours and 15 minutes, what are the parameters for do an encoding such that the final output mp4 file don't exceed 4.37 GB?

    If I do a 2 pass encoding, quality is better?

    thanks
    Quote Quote  
  20. You seem to be missing this vital bit of information, true for all codecs and containers:
    Code:
    file size = bitrate * running time
    Plus a little container overhead. bitrate is the sum of bitrates of all audio, video, and other tracks.
    Quote Quote  
  21. Name:  SHA.jpg
Views: 6327
Size:  13.0 KB
    oh, but I'm a cat, I have problem of calculations

    however, can I calculate bitrate also in VBR mode?
    Quote Quote  
  22. It doesn't matter if the it's CBR or VBR. The calculation is the same. And, of course, if

    Code:
    file size = bitrate * running time
    then simple algebraic manipulation gives you:

    Code:
    bitrate = file size / running time
    Quote Quote  
  23. Calculate average bitrate first, choose any bitrate calculator you cen google or find it on this forum, that is a fictional bitrate for you video, where in reality your bitrate is going to be all over the place but average is going to be that value.

    Then you need two passes to actually encode to that average bitrate. For example your average bitrate is going to be 6000kbps. First pass analyzes what scenes has what degree of difficulty, so you do not need actual output from 1pass, it could be NUL output. Second pass actually distributes certain bitrate based on that first pass and encodes encodes those parts with calculated bitrates already so at the ant you get the same volume as if you encoded 6000 kbps CBR.

    Why would you not google it already? ffmpeg 2pass or something

    it would be slightly different getting mpeg2 or mp4, where getting mp4 you'd set bitrate in x264opts or how it is normally works
    Last edited by _Al_; 26th Mar 2015 at 15:46.
    Quote Quote  
  24. consider the MP4 H264 case:

    my source is 25fps interlaced, 466GB uncompressed YUY2 1920x1080, 1 hours and 15 minutes in total

    I have try this commandline

    Code:
    ffmpeg.exe -y -i audiosfilata.wav -i sfilata.avi -c:v libx264 -profile:v high422 -level:v 4.1 -g 33 -bf 2 -b:v 8123K -minrate 6000k -maxrate 8123K -pass 2 -bufsize 224 -pix_fmt yuv422p -c:a libmp3lame -b:a 448k  -aspect 16:9 out.mp4
    but:

    Click image for larger version

Name:	FF1.jpg
Views:	1215
Size:	325.6 KB
ID:	30882

    and however my target size is 4,7GB (DVD-5, or 4,37GB?), and I don't know if the -busize parameter is correct

    but I like use ffmpeg because of it's high quality in h264 encoding

    what would be a correct commanline to achieve a final output size of 4,7 GB to fit in a DVD-data? thanks
    Last edited by marcorocchini; 26th Mar 2015 at 16:33.
    Quote Quote  
  25. Did you run pass 1 first? You can't run only pass 2.

    It makes no sense to specify the same value for average and max bitrate.

    DVD = 4.7 GB (4.7 * 1000 * 1000 * 1000) = 4.3 GiB (4.3 * 1024 * 1024 *1024).
    Quote Quote  
  26. Originally Posted by _Al_ View Post
    so you can try google "ffmpeg 2pass mp4" it gives you plenty of ideas, understand that search gives you always two ffmpeg lines, each for one pass ...
    ....
    Quote Quote  
  27. Originally Posted by jagabo View Post
    Did you run pass 1 first? You can't run only pass 2.
    Click image for larger version

Name:	ohmygodcat.jpg
Views:	1778
Size:	24.2 KB
ID:	30884
    __
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!