elmopl / ktba

Blender addons
MIT License
56 stars 12 forks source link

Rendering with an audio codec selected will cause problems #30

Open tin2tin opened 3 years ago

tin2tin commented 3 years ago

Rendering with an audio codec selected and mixdown unchecked, will result in dropouts in the audio track.

Rendering with an audio codec selected(ex. mp4, h.264, ac3) and mixdown checked, will result in dropouts in the audio track.

Rendering AVI JPEG and mixdown checked, will result in dropouts in the audio track.

So, maybe it is necessary to do something like this to overwrite the audio when mixdown is checked? Or even strip the audio from the rendered file and then mux the mixdown audio in? https://superuser.com/questions/602662/how-do-i-replace-the-audio-in-an-mp4-file-without-re-encoding

If no audio codec is selected, there are no dropouts in the audio.

elmopl commented 3 years ago

I am going to assume that dropouts happen on the boundary of each batch.

I discovered that when I started creating this addon. That's why this addon first generates all video, then (if mixdown enabled) it generates audio for the whole length of video as mp3. Then it uses ffmpeg to stitch everything together.

If concatenate is enabled then ffmpeg is run to join video files. In addition if mixdown is checked the ffmpeg command is passed in the full length mp3 with: '-i', sound_path, '-codec:a', 'copy', '-q:a', '0'

The main difference in that StackOverflow answers is "-map 0:0 -map 1:0", but I am not sure that should make a difference.

Maybe my command fails to "overwrite" audio if video clips have been rendered with audio.

tin2tin commented 3 years ago

It seems to me that currently the audio isn't added to the clip, when there already is audio - that would explain the dropouts.

Some time back I remember looking for a solution to overwrite the audio, but couldn't find one, so I ended up first removing the audio and then adding it, not very elegant, but it worked.

A quick search and this came up - with the map function: https://ottverse.com/add-remove-extract-audio-from-video-using-ffmpeg/

NonMeme commented 3 years ago

I am going to assume that dropouts happen on the boundary of each batch.

I discovered that when I started creating this addon. That's why this addon first generates all video, then (if mixdown enabled) it generates audio for the whole length of video as mp3. Then it uses ffmpeg to stitch everything together.

If concatenate is enabled then ffmpeg is run to join video files. In addition if mixdown is checked the ffmpeg command is passed in the full length mp3 with: '-i', sound_path, '-codec:a', 'copy', '-q:a', '0'

The main difference in that StackOverflow answers is "-map 0:0 -map 1:0", but I am not sure that should make a difference.

Maybe my command fails to "overwrite" audio if video clips have been rendered with audio.

I get this on my set-up too.