News:

--

Main Menu

Adding Black Frames in Middle of Video

Started by Peter99, January 22, 2021, 10:17:08 AM

Previous topic - Next topic

Peter99

Could you tell me please if and how I can insert a second or two of black screen in the middle of a video?......I do not want them to fade in or out and I would like these frames to be silent - so leaving the audio/video before and after the black frames unchanged.

[ The file to receive the black frames came out of Avidemux as:
     Video: Mpeg4AVC (x264)
     Audio: AAC (FDK)
     Format: MP4 Muxer ]

butterw

- If your video (or another video with the exact same encoding parameters) already contains such a suitable segment, you would just need to copy/paste it.

- Otherwise, for video you can use filter transform > Black which will encode a segment to black
- I don't know what's available for audio in Avidemux.

Peter99

Thank you for the thoughts.....

Quote from: butterw on January 22, 2021, 11:09:15 AMOtherwise, for video you can use filter transform > Black which will encode a segment to black

Wouldn't "transform" mean that I would lose some of the existing video? (Which I don't want to do.)

Quote from: butterw on January 22, 2021, 11:09:15 AMIf your video (or another video with the exact same encoding parameters)

Does "exact coding parameters" mean just the things I mentioned in my post - or is there more that has to be the same?

Quote from: butterw on January 22, 2021, 11:09:15 AMyou would just need to copy/paste it.

I can see that I could put the video with the silent black segment into Avidemux, edit and save just the black part, split the target video video in two and then join the three pieces together........is that what you mean by copy/paste or is there a short cut?

butterw

#3
Quote from: Peter99 on January 22, 2021, 12:09:02 PM
Quote from: butterw on January 22, 2021, 11:09:15 AMOtherwise, for video you can use filter transform > Black which will encode a segment to black

Wouldn't "transform" mean that I would lose some of the existing video? (Which I don't want to do.)

You could select/copy/paste a quiet segment from your video at the desired point then apply the Black filter with start/stop parameters. The Black Filter approach implies re-encoding is required.

Quote from: Peter99 on January 22, 2021, 12:09:02 PM
Quote from: butterw on January 22, 2021, 11:09:15 AMIf your video (or another video with the exact same encoding parameters)
Does "exact coding parameters" mean just the things I mentioned in my post - or is there more that has to be the same?

Same codec/framerate/resolution would be required in every case.
codec encoding settings must be the same if you want to edit without re-encoding.

Quote from: Peter99 on January 22, 2021, 12:09:02 PM
Quote from: butterw on January 22, 2021, 11:09:15 AMyou would just need to copy/paste it.
I can see that I could put the video with the silent black segment into Avidemux, edit and save just the black part, split the target video video in two and then join the three pieces together........is that what you mean by copy/paste or is there a short cut?
If you have the black segment loaded after the video, you can first select it then cut and paste it where you want it, you don't need 3 separate files.
The shortcut would be an insert script, as there is no insert command currently in Avidemux.

Peter99

Thank you for that.....

I am almost there now with the video, but seem to have an audio problem remaining:

I used existing black frames and made them silent by using the Audio tab at the top and deselecting the track.

Then I put them between parts A and B of the video. The video runs fine, but the silence that begins with the black frames continues through part B.

I tried to reselect the audio track for the black edit (now that it is silent), but I just get an error message saying there are multiple tracks selected.

So I tried another way of muting the black frames by copying them with Copy/Copy/Audio Only. But this lead to the problem that the output is "raw" and I can't see a way to get it back into Avidemux to re-encode.

eumagga0x2a

Quote from: Peter99 on January 22, 2021, 05:50:02 PMI used existing black frames and made them silent by using the Audio tab at the top and deselecting the track.

No, this cannot work. Don't look for existing black frames but for any existing frames in the video where the audio track is silent. Choose the video encoder of your liking, copy the selection containing this silent episode to the spot in the timeline where black frames need to be, add "black" filter with start and end points matching this location.

If you want to have a fade-out and fade-in effect, add two corresponding "fade to black" filter instances. Re-encode the whole video as the last step.

Any solutions which avoid re-encoding video are much more complicated due to the necessity to use an external audio track and resulting problems with A/V sync.

butterw

If you already have a non-silent black frames section in the video, is it possible to apply an audio Gain Filter (ex:-70dB) restricted to this section to mute it ?

Papou

What about saving a selection of your existing black frames to file black.mp4, editing that file and Audio>Select Track to remove any track, File>Save it and then File>Append... it wherever you want?
Otherwise said, what sound will AviDemux use for the span of an appended file that has none?
black.mp4 must start with a key frame and you will have to keep it beside your file until you File>Save the result in Copy mode.
Having found no black frames sequence, I tried re-encoding a section with mp4, x262, Constant Bit rate 1kbps, Black filter and no soundtrack and I'd better let you experiment it than try to describe the "codecs don't match", "can't initialize sound" and crashes I met.

eumagga0x2a

Quote from: Papou on August 11, 2021, 07:18:16 PMOtherwise said, what sound will AviDemux use for the span of an appended file that has none?

From the moment where a sound track goes missing, there will be no sound, even if another segment is added from a reference video which has a sound track. Therefore it is mandatory to add a matching audio track to the black video prior to appending it (and then eventually copypasting to the desired location).

It is quite possible that earlier versions of Avidemux (i.e. anything other than the latest git master) crashed if the audio track disappeared, unsure about that.

Quote from: Papou on August 11, 2021, 07:18:16 PMI tried re-encoding a section with mp4, x262, Constant Bit rate 1kbps, Black filter and no soundtrack and I'd better let you experiment it than try to describe the "codecs don't match", "can't initialize sound" and crashes I met.

When appending, video codec extradata (Avidemux displays a hexdump of up to 64 bytes of extradata in the video properties dialog) of both videos must match perfectly.

If the original video was encoded with x264 (not just H.264 but H.264 produced by the x264 encoder), you might be able to extract its configuration from a SEI message, embedded into the video stream (Avidemux prints the content of this message to the log when copying video, else please use mediainfo to oview this message). You will need to replicate this configuration 100% which is a difficult task.