VideoHelp Forum
+ Reply to Thread
Results 1 to 23 of 23
Thread
  1. Hello there,

    I have lot of MP4-videos (around 1000) and all of them have different width and height.

    What I want to do is: Set a certain height (for example 320px) and resize all of them at once so all of them are 320px high after this. Aspect ratio should be kept so width should be set automatically.

    After this, I want to add a logo/branding to all videos at once at a certain position (for example X = 0 and Y = 250).

    It's important to me that the original quality and FPS of this videos will not be changed, only the size.

    Is there any nice program to recommend? Free would be cool, but I'd also pay for it.
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    You could probably make a ffmpeg batch script.

    See:
    https://trac.ffmpeg.org/wiki/Scaling%20%28resizing%29%20with%20ffmpeg
    http://superuser.com/questions/683643/how-to-add-my-logo-for-the-first-30-seconds-in-a...eo-with-ffmpeg

    And the command will look something like
    Code:
    c:\ffmpeg\ffmpeg.exe -i c:\videos\input.mp4 -i c:\videos\logo.png -filter_complex "[0:v][1:v]overlay=0:250" -vf scale=-1:320  -c:v libx264 -c:a copy c:\videos\out.mp4
    And when you get that working can you make a bat file to go through all files. See https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg

    Or maybe can you find some ffmpeg frontend/gui with all those features.
    Last edited by Baldrick; 22nd Mar 2015 at 02:58.
    Quote Quote  
  3. Thank you so far. This looks really complicating, I have no knowledge in scripting, I need a finished program where I only have to select what I like.
    Quote Quote  
  4. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I'm not sure you will find any program with all your features. But if you get the ffmpeg command working can I help with the bat script.

    You download ffmpeg. Put ffmpeg.exe in c:/ffmpeg. Put your test input.mp4 video and logo.png in c:/videos. And last copy the code above and paste from windows start and run or from a command box.

    Or maybe you have some computer geek/programmer that can help you directly.
    Quote Quote  
  5. Assuming you know the output video format you want in detail and you are on a Windows system, you could use Hybrid:
    (Hybrid doesn't support adding a Logo on Mac&Linux atm.)
    1. Download and install Hybrid
    2. set 'Crop/Resize->Main->Resize->Picture Resize->AutoAdjust' to 'width'
    3. set the second parameter of 'Crop/Resize->Main->Resize->Picture Resize->Target resolution' to 320
    4. enable 'Crop/Resize->Misc->Misc->Keep resize for new source'
    5. If your files contain subtitle streams which should be kept, enable 'Config->Automation->Passthrough streams->Subtitle'
    6. drag&drop all your files into Hybrid (in the Main-tab); Hybrid will then analyse all of the input files
    7. enable 'Filtering->Avisynth->Others->Logo'
    8. use 'Filtering->Avisynth->Others->Logo->Select' to select the image you want to embed (make sure the logo is small enough)
    9. use the other settings to adjust position&co and use the 'Avisynth Preview' in the lower right corner to get a preview
    10. set 'Main->Handling->Audio handling' to 'passthrough all'
    11. configure the video settings the way you want/need them (I assume you know what output format you need)
    12. set a default output folder under 'Config->Path->Default output path'
    13. enable 'Main->Generate'
    14. create processing jobs by pressing 'Main->Add to queue' (button in the lower right corner)
    15. start the processing by pressing 'Jobs->Job Queue->Start' (the play-button)
    16. wait for Hybrid to process all your files.

    Also:
    Since you need to reencode to embed the logo you will always loose some quality, but depending on your video encoding settings they might not be visible during normal playback to most people.

    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  6. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Hybrid looks like a very good alternative if you hate ffmpeg scripting. I didn't know it had logo filters also.
    Quote Quote  
  7. Really great help so far, thank you.

    I want to try both methods to see which method gives me smaller filesize and/or better quality.

    @Selur: In Hybrid I have problems adding a logo, the logo is .jpg, does it have to be .png? Because I click on Add logo and nothing happens.

    To be exactly, it's not really a logo I need, I only want to write a URL on the video, so it's no graphic, only letters. Maybe there is a simple way for this?

    @Baldrick: I tried it out and I receive the following error: "Filtergraph 'scale=-1:320' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph. -vf/-af/-filter and -filter_complex cannot be used together for the same stream.

    What does this mean?

    Information: I first want to resize the video, and after it is resized I want to add the logo. I don't want to add the logo before the video is resized, because then the logo will become too small and people can't read it anymore.

    Regards.
    Quote Quote  
  8. Originally Posted by Selur View Post
    Assuming you know the output video format you want in detail and you are on a Windows system, you could use Hybrid:
    (Hybrid doesn't support adding a Logo on Mac&Linux atm.)
    1. Download and install Hybrid
    2. set 'Crop/Resize->Main->Resize->Picture Resize->AutoAdjust' to 'width'
    3. set the second parameter of 'Crop/Resize->Main->Resize->Picture Resize->Target resolution' to 320
    4. enable 'Crop/Resize->Misc->Misc->Keep resize for new source'
    5. If your files contain subtitle streams which should be kept, enable 'Config->Automation->Passthrough streams->Subtitle'
    6. drag&drop all your files into Hybrid (in the Main-tab); Hybrid will then analyse all of the input files
    7. enable 'Filtering->Avisynth->Others->Logo'
    8. use 'Filtering->Avisynth->Others->Logo->Select' to select the image you want to embed (make sure the logo is small enough)
    9. use the other settings to adjust position&co and use the 'Avisynth Preview' in the lower right corner to get a preview
    10. set 'Main->Handling->Audio handling' to 'passthrough all'
    11. configure the video settings the way you want/need them (I assume you know what output format you need)
    12. set a default output folder under 'Config->Path->Default output path'
    13. enable 'Main->Generate'
    14. create processing jobs by pressing 'Main->Add to queue' (button in the lower right corner)
    15. start the processing by pressing 'Jobs->Job Queue->Start' (the play-button)
    16. wait for Hybrid to process all your files.

    Also:
    Since you need to reencode to embed the logo you will always loose some quality, but depending on your video encoding settings they might not be visible during normal playback to most people.

    Cu Selur
    Thank you, this advice will come in handy. I will do as you suggest.
    Quote Quote  
  9. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Originally Posted by Basher06 View Post
    @Baldrick: I tried it out and I receive the following error: "Filtergraph 'scale=-1:320' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph. -vf/-af/-filter and -filter_complex cannot be used together for the same stream.

    What does this mean?
    Okey. Resizing and adding logo at same time doesn't seem to work. I'm no ffmpeg expert so I'm not sure how to solve that. Maybe try move the -vf scale=-1:320 before the -filter_complex "[0:v][1:v]overlay=0:250"
    Quote Quote  
  10. I just tried switching it but it still does not work.

    If I only use the branding it works, and if I only use the resizing it says:

    "width not divisible by 2"

    and

    "Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"

    What I also wanted to ask is how can I say ffmpeg to keep the original bitrate and FPS?
    Quote Quote  
  11. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    OKey. ffmpeg might not be that useful for auto resizing video(it must be divisible by 2).
    Last edited by Baldrick; 23rd Mar 2015 at 04:42.
    Quote Quote  
  12. Originally Posted by Baldrick View Post
    OKey. ffmpeg might not be that useful for auto resizing video(it must be divisible by 2).
    Video can be padded to be mod2 (or resized by mod2)

    fit + pad
    Code:
    scale='if(gt(a,30/17),480,-1)':'if(gt(a,30/17),-1,272)',pad=480:272:(ow-iw)/2:(oh-ih)/2
    MOD2
    Code:
    scale='320:trunc(ow/a/2)*2'
    Last edited by pandy; 23rd Mar 2015 at 08:08.
    Quote Quote  
  13. @Selur: In Hybrid I have problems adding a logo, the logo is .jpg, does it have to be .png? Because I click on Add logo and nothing happens.
    a. Where do you click 'Add logo'?

    You need to:
    0. make sure your image is small enough to fit onto your video (Hybrid will not resize the logo for your)
    1. enabled Filtering->Avisynth->Other->Logo
    2. Hit the 'Select'-Button and select your video
    3. Hit the 'Avisynth Preview'-button, look at the video with the logo and adjust the Logo settings

    b. got no problem here adding gif/jpeg/png
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  14. Banned
    Join Date
    Oct 2014
    Location
    Northern California
    Search PM
    Originally Posted by Basher06 View Post
    It's important to me that the original quality and FPS of this videos will not be changed, only the size.
    Quality is obviously not important to you otherwise you would not indiscriminately resize.

    May I ask why each video needs a logo?

    Quote Quote  
  15. Okay I finally managed to create a single video file how I want it to be with both methods.

    The file created by Hybrid is much larger than the file created by ffmpeg so I will stick to ffmpeg.

    Only problem here is that I still can't do resizing and adding logo in one encoding process because of this error: "-vf/-af/-filter and -filter_complex cannot be used together for the same stream."

    If there is a possibility to do both in one step this would be awesome
    Quote Quote  
  16. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    What video bitrate option are you using in hybrid? If you use constant quantizer encoding mode under x264 could you increase the quantization value to get smaller output.

    I don't know how to solve the resizing and filter_complex at same time.
    Quote Quote  
  17. ffmpeg by default is probably using crf 23.

    Code:
    ffmpeg.exe -y -i F:\Test-AC3-5.1.avi -i f:\cross.jpg -filter_complex "[0:v] scale=trunc(oh/a/2)*2:320 [src];[src][1:v] overlay=0:0"  -c:v libx264 -c:a copy f:\test.mp4
    isn't right either, but might help others to figure out the ffmepg call.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  18. @Baldrick: I used same CRF-value in Hybrid as in ffmpeg and still Hybrid file is much larger.

    @Selur: Why isn't it right either, it works fine now, resizing and watermarking, both together

    I used to resize my files with Avidemux, but even if I enter the same CRF value in ffmpeg I still think the quality is a little bit worse than in Avidemux. Filesize is around the same.

    I just checked the x264 configuration in Avidemux and there are a lot of checkboxes activated and a lot of different settings.. is it somehow possible to increase the quality of my ffmpeg output beside of changing the CRF value? Or maybe there is a way just to copy the Avidemux x264 settings into ffmpeg console?

    Here are checkboxes which I found activated on Avidemux:

    "Fast First Pass"
    "Macroblock-tree Rate control"
    "Weighted Prediction for B-frames"
    "8x8 DCT Spatial Transform"
    "4x4, 4x8 and 8x4 P-frame Intra-predicted Blocks"
    "8x8 Intra-predicted Blocks"
    "4x4 Intra-predicted Blocks"
    "CABAC"
    "Mixed References"
    "Chroma Motion Estimation"
    "Trellis Quantization:Final Macroblock Only"
    "Fast Skip Detection on P-frames"
    "DCT Decimation on P-frames"

    Which of them is making the quality better as in ffmpeg?

    Regards.
    Last edited by Basher06; 24th Mar 2015 at 03:49.
    Quote Quote  
  19. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Batch command to process all files with a logo and resize:

    Code:
    for %%a in ("*.mp4") do C:\ffmpeg.exe -i "C:\Videos\%%a" -i C:\logo1.png -filter_complex "[0:v] scale=-2:320 [src];[src][1:v] overlay=0:0" -c:v libx264 -crf 25 -c:a copy  "C:\Output\%%~na.mp4"
    pause
    Quote Quote  
  20. This is absolutely awesome, Baldrick! Thank you very much!
    Last edited by Basher06; 24th Mar 2015 at 06:02.
    Quote Quote  
  21. second input or complex is not required - for me, this works OK*:
    Code:
     -vf " ... [aaa] ; movie=picture.png [bbb]; [aaa] [bbb] overlay=W-w-16:H-h-64, ... "
    https://www.ffmpeg.org/ffmpeg-filters.html#movie-1

    *http://www.urbandictionary.com/define.php?term=works+for+me

    btw use alpha channel for antialiasing - logo will be nicely overlayed with anitaliased edges over video plane
    Quote Quote  
  22. @pandy: Nice, didn't know the movie-parameter.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  23. Thanks pandy, really great method, just tried it out works fine, too
    Quote Quote  



Similar Threads

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