1

I've got an script which is to bulk join and intro file, video files and a outro into one file:

cd converted
    for %%f in (*.mp4) do (
      echo.>%%f.list
      echo file 'intro_outro/c_intro.mp4' >> %%f.list
      echo file '%%f' >> %%f.list
      echo file 'intro_outro/c_outro.mp4' >> %%f.list
    )


for %%f in (*.list) do (
  ffmpeg -f concat -i %%f -c copy concatenated/%%f.mp4
)

Now I have a problem, I just got a video file and an outro file and I don't need an intro. What do I need to change to just add an outro to the videos in bulk?

Salexes
  • 187
  • 1
  • 2
  • 20

1 Answers1

2

Remove the intro reference, so

cd converted
    for %%f in (*.mp4) do (
      echo.>%%f.list
      echo file '%%f' >> %%f.list
      echo file 'intro_outro/c_outro.mp4' >> %%f.list
    )


for %%f in (*.list) do (
  ffmpeg -f concat -i %%f -c copy concatenated/%%f.mp4
)
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Okay I used this code now. My first mp4 file is: 15 seconds long My Second mp4 file (outro) is: 3 seconds long and the concated video is suddenly 20 seconds long and the sound of the outro starts 1-2 seconds to late Any idea how i could fix this ? – Salexes Mar 01 '16 at 12:18
  • I found another answer from you which is maybe the fix for my problem: http://stackoverflow.com/a/35520705/2059411 <-- can we integrate this code into the code above, so bulk adding outro will work perfectly ? – Salexes Mar 01 '16 at 12:24
  • Let me see the input properties for a pair of main file and outro. – Gyan Mar 01 '16 at 12:25
  • Here I just uploaded the codes/bat files which i am using and the outro file and a sample mp4 file. Then you can fully understand how I do it. Maybe I did a mistake somewhere. https://www.dropbox.com/s/0fxz8jaqyu59tdn/ffmpeg_convert_concat_batch.rar?dl=0 – Salexes Mar 01 '16 at 12:34
  • 1
    For concat, the streams should have the same properties. But your video frame rates don't match, neither do your audio sampling rates. Also, your main audio is 0.8 seconds longer than the video, so the joint occurs later compared to the video joint. You can try to correct that by running `ffmpeg -i main -c copy -shortest output.mp4` for each main video. – Gyan Mar 01 '16 at 12:43
  • I am not sure if I understand you correctly. I assume you have downloaded the files first i run the convert.bat, so the videos get converted to the same file ending in this case .mp4 then I run the concat.bat which should concat the two video files. Do i need to run this on the concated file or do i need to do that on the source file already ? And how can I do that it bulk, it would take really long to do it for over 1000 videos – Salexes Mar 01 '16 at 12:58
  • Like this? for %%f in (*.mp4) do ( ffmpeg -i "%%f" -c copy -shortest %%f.mp4 ) – Salexes Mar 01 '16 at 13:03
  • 1
    Yes, like that. The concat demuxer in copy mode only works correctly for files with same properties and streams within a file of equal length. – Gyan Mar 01 '16 at 13:08
  • So if it is needed to be done before I convert the files then this should be the right code for the convert.bat: http://pastebin.com/ViEdR1Sd right ? – Salexes Mar 01 '16 at 13:19
  • Since you are re-encoding, you can skip the first command and add `shortest` to the 2nd. – Gyan Mar 01 '16 at 13:33
  • Ok, I did all of this now and still the outcome is not working correctly see here: https://www.dropbox.com/s/3vsf6a9ps3hkfs6/c_976854978987732152_1772817218.mp4.list_x264.mp4?dl=0 The sound of the outro starts to late how can i fix this ? – Salexes Mar 01 '16 at 17:45
  • The conversion commands as well. You did insert the shortest in the 2nd command from the earlier pastebin? – Gyan Mar 01 '16 at 18:42
  • 1
    Add the same sampling rate in both conversions e.g. `-ar 44100` – Gyan Mar 01 '16 at 19:53