Reputation: 23
I have a video shot from my smartphone that is [email protected]. Originally, it was exactly 5 minutes long. I replaced the audio with a music file that is 5 minutes and 11 seconds using ffmpeg -i video.mp4 -i audio.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4
I expected 11 seconds of black at the end, but instead the video output freezes on the last frame for 11 seconds. There's definitely something funky going on because when I try to upload to youtube, it only sees the first 5 minutes. The last 10 seconds of audio get dropped.
I tried making a second black clip with ffmpeg -f lavfi -i color=c=black:s=uhd2160:r=57.74 -t 11 -pix_fmt yuv420p blk2.mp4
. When I try to concat the two files with ffmpeg -f concat -safe 0 -i list.txt -c copy teacup6.mp4
I get a huge list of errors such as [mp4 @ 00000166fda994c0] Non-monotonous DTS in output stream 0:0; previous: 27002920, current: 3728954; changing to 27002921. This may result in incorrect timestamps in the output file.
for what appears to be about 11 seconds worth of frames, so basically the entire 11 second black clip. When I play it in VLC it goes black, but I suspect it's not actually processing/playing 11 seconds of good black video because if I click along the track timeline, visual glitches start happening in the canvas.
Here is what ffmpeg tells me about my inputs and outputs as far as framerate, pixel format, etc.
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000239e6cb2880] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'list.txt':
Duration: N/A, start: -0.023021, bitrate: 72244 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160, 71994 kb/s, SAR 1:1 DAR 16:9, 57.74 fps, 59 tbr, 90k tbn, 180k tbc
Metadata:
handler_name : VideoHandle
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 250 kb/s
Metadata:
handler_name : SoundHandler
Output #0, mp4, to 'teacup5.mp4':
Metadata:
encoder : Lavf58.35.102
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 71994 kb/s, 57.74 fps, 59 tbr, 90k tbn, 90k tbc
Metadata:
handler_name : VideoHandle
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 250 kb/s
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
alternatively, I tried to make a black 3840x2160 png file and create an 11 second slideshow. It didn't turn out any better. I tried a single image for 11 seconds @ 57.74fps, I also tried a looping slideshow of that one image, looping on every single frame, at 57.74 fps. I should note that wether a slideshow or a color generator, the filesize for the 11 seconds of black comes out to about 160KB. Strangely small in my opinion, but I was chalking it up to a good compression algorithm.
I tried to do this in Da Vinci Resolve 16.1 instead and the video wouldn't play. I also couldn't find a way to maintain the same unusual 57.74 framerate with the free version, so it was undesirable anyway. I tried to re-process using Handbrake, but it threw an error. The output of the Handbrake processed video file also gets stuck on the last frame of the video, instead of going to black.
Upvotes: 0
Views: 228
Reputation: 134093
The tpad filter is the easiest method:
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex "[0:v]tpad=stop=-1[v]" -map "[v]" -map 1:a -c:a copy -shortest output.mp4
See the link above for additional options such as how to change the color of the blank frames or to repeat the last frame instead of making a solid color.
Upvotes: 1