VideoHelp Forum
+ Reply to Thread
Results 1 to 11 of 11
Thread
  1. To concatenate videos properly they have to be the same format, resolution, fps, etc. There are a ton of settings that need to match in both videos, obviously. But lets say I wanted to add an intro/outro to a video. It seems sloppy and quite slow to encode the entire video, especially since the intro/outro is always small by comparison. I would much rather encode the Master intro/outro to match the settings of the video I'm adding it to. Surely there is a program that can accomplish this? I tried with ffmpeg but it doesn't seem to work that way, it requires me to encode the main video too which is not what I want. Still, it might be possible if I could make ffmpeg pull data from a video and use it in the conversion process, but again, I haven't found anything in that area either. Any ideas?
    Last edited by imkira3; 28th May 2024 at 15:02.
    Quote Quote  
  2. If you can create your intro file to match the exact specs of the file you want to attach it to you could use the append feature in AviDemux which would combine the videos and you can set it that it doesn't re-encode but make sure down on the muxer that you set that for the type of container you want to keep it as.
    Quote Quote  
  3. Originally Posted by Tom Saurus View Post
    If you can create your intro file to match the exact specs of the file you want to attach it to you could use the append feature in AviDemux which would combine the videos and you can set it that it doesn't re-encode but make sure down on the muxer that you set that for the type of container you want to keep it as.
    You misunderstood my question, I already know how to concatenate 2 videos of matching types.
    Quote Quote  
  4. So you want to make an intro and not have it match the specs and somehow want a program to bring it to the specs to match your main video and not re-encode the main video as well. I trust someone here has the answer and I am interested to know what it is.
    Quote Quote  
  5. Originally Posted by Tom Saurus View Post
    So you want to make an intro and not have it match the specs and somehow want a program to bring it to the specs to match your main video and not re-encode the main video as well. I trust someone here has the answer and I am interested to know what it is.
    Yeah that's pretty much it, and it works even better if your using uncompressed video for your Master intro/outro. Basically, I would keep the uncompressed intro and outro and would have to perform an encode to match whatever video I'm attaching it to at the time. So, the intro, outro and main would only need receive one encode, ever. It will minimize quality loss, and it actually sounds like a perfect tool for any youtuber come to think of it. It's important enough that something that can do this likely exists already.
    Last edited by imkira3; 28th May 2024 at 16:37.
    Quote Quote  
  6. Use ffprobe to get properties from your target file (as environment variables). Use ffmpeg to encode your intro with those properties. Use ffmpeg to concatenate the intro and target to a new file. Delete the intro file. All in one batch file. It won't be easy and it will be fraught with problems in practice.
    Quote Quote  
  7. Originally Posted by jagabo View Post
    Use ffprobe to get properties from your target file (as environment variables). Use ffmpeg to encode your intro with those properties. Use ffmpeg to concatenate the intro and target to a new file. Delete the intro file. All in one batch file.
    Oh, that sounds perfect, and I won't even need a new program. Still, I know nothing about using ffprobe, can you give an example of how to use it to grab an environment variable? I can take it from there.
    Quote Quote  
  8. Here's an example of a batch file that uses ffprobe to get the width and height of the frame, stores them in environment variables, and then runs a ffmpeg to reduce the frame size by half (each dimension):

    Code:
    ffprobe.exe -v quiet -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p width= < %1.txt
    ffprobe.exe -v quiet -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p height= < %1.txt
    del %1.txt
    
    REM At this point the environment variables "width" and "height" are available to your ffmpeg command line.
    REM for example, to scale to half width and half height:
    ffmpeg -i %1 -vf scale=%width%/2:%height%/2 output.mkv
    
    pause
    Quote Quote  
  9. Originally Posted by jagabo View Post
    Here's an example of a batch file that uses ffprobe to get the width and height of the frame, stores them in environment variables, and then runs a ffmpeg to reduce the frame size by half (each dimension):

    Code:
    ffprobe.exe -v quiet -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p width= < %1.txt
    ffprobe.exe -v quiet -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p height= < %1.txt
    del %1.txt
    
    REM At this point the environment variables "width" and "height" are available to your ffmpeg command line.
    REM for example, to scale to half width and half height:
    ffmpeg -i %1 -vf scale=%width%/2:%height%/2 output.mkv
    
    pause
    Thanks, I threw this together based on your example, it seems to work well so far. Honestly, I was expecting more trouble, but only a few things need to line up for proper concatenation or so it seems, though your output file will likely have a variable framerate:

    Code:
    ffprobe.exe -v quiet -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 MAIN > %1.txt
    set /p width= < .txt
    ffprobe.exe -v quiet -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 MAIN > %1.txt
    set /p height= < .txt
    ffprobe.exe -v quiet -show_entries stream=pix_fmt -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 MAIN > %1.txt
    set /p pix_fmt= < .txt
    ffprobe.exe -v quiet -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 MAIN > %1.txt
    set /p codec_name= < .txt
    del .txt
    
    ffmpeg -i INPUT -vf scale=%width%:%height% -pix_fmt %pix_fmt% -c:v %codec_name% OUTPUT
    
    pause
    Note: This will take INPUT, convert it to have the properties of MAIN and then give the OUTPUT. Be aware this is the Win7 version of the code, minor tweaking may be necessary.

    EDIT: I did get an error as it turns out, I know how to fix it but I'm not sure what the issue is. The quickstream fix in VideoRedo fixes concatenation issues, I think it's because I ran it on all the other videos (including MAIN) as the final step, so whatever adjustments the quickstream fix applies weren't applied by the script, but when I ran it on the output videos together with the script it made the videos similar enough to combine. I reckon the same principals might apply if I used mkvtoolnix in the final step, but I can't be sure without further testing. Machete also implied the videos have different compression parameters whatever that means.
    Last edited by imkira3; 2nd Jun 2024 at 01:38.
    Quote Quote  
  10. How are you concatenating the segments? The regular concat filter only works with containers that can be simply appended (transport streams and elementary streams). You need to use the "list" method for other containers (MP4, MOV, MKV...).

    https://trac.ffmpeg.org/wiki/Concatenate
    Quote Quote  
  11. Originally Posted by imkira3 View Post
    To concatenate videos properly they have to be the same format, resolution, fps, etc. There are a ton of settings that need to match in both videos, obviously. But lets say I wanted to add an intro/outro to a video. It seems sloppy and quite slow to encode the entire video, especially since the intro/outro is always small by comparison. I would much rather encode the Master intro/outro to match the settings of the video I'm adding it to. Surely there is a program that can accomplish this? I tried with ffmpeg but it doesn't seem to work that way, it requires me to encode the main video too which is not what I want. Still, it might be possible if I could make ffmpeg pull data from a video and use it in the conversion process, but again, I haven't found anything in that area either. Any ideas?
    Hi there, we use it as smart rendering/smart transcoding technology in our video eiditor, that you can test online
    https://freevideoeditor.online/

    desktop product is here
    https://www.solveigmm.com/en/products/video-editor/

    So you add to a timeline your longest file, that will be copied, and the intro that well be transcode na joined to 1st file
    Image
    [Attachment 79767 - Click to enlarge]
    Quote Quote  



Similar Threads

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