[FFmpeg-user] Various problems exchanging end of video
Hauke Westemeier
Hauke_Westemeier at web.de
Sun Sep 18 06:51:17 EEST 2016
Hi,
I'm using ffmpeg version N-81664-g6f062eb with Windows 8.1 and have
some problems. I want to replace the end of a short video by an image
and avoid recoding.
Step 0) Some details of the initial video:
ffmpeg.exe -i original.mp4
Duration: 00:00:47.50, start: 0.000000, bitrate: 97 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
480x270 [SAR 1:1 DAR 16:9], 97 kb/s, 10 fps, 20 tbr, 10240 tbn, 40 tbc
(default)
I've read a little about fps tbr, tbn, tbc but I'm not really sure why
all four values are different from each other but for now accepted
that this is the case (due to interlacing?)
Step 1) Remove end
ffmpeg.exe -i original.mp4 -codec copy -ss 00:00:00 -to 00:00:43 cut.mp4
warn
Using AVStream.codec to pass codec parameters to muxers is deprecated,
use AVStream.codecpar instead.
but cut.mp4 seems to be playing fine and as expected the old end is
removed.
Interestingly the frame rate is slightly changed (due to rounding
effects?)
ffmpeg.exe -i cut.mp4
Duration: 00:00:43.00, start: 0.000000, bitrate: 107 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
480x270 [SAR 1:1 DAR 16:9], 106 kb/s, 9.81 fps, 20 tbr, 10240 tbn, 40
tbc (default)
Step 2) Create new end based on an image
ffmpeg.exe -loop 1 -i newEnd.png -t 5 -r 9.81 -c:v libx264 -pix_fmt
yuv420p newEnd.mp4
gives the desired video of this image
ffmpeg.exe -i newEnd.mp4
Duration: 00:00:05.10, start: 0.000000, bitrate: 8 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
480x270 [SAR 1:1 DAR 16:9], 5 kb/s, 9.81 fps, 9.81 tbr, 15696 tbn,
19.62 tbc (default)
Step 3) Concat the cutted video and new end to get final result
ffmpeg.exe -f concat -i videos.txt -codec copy -r 9.81 finalresult.mp4
with videos.txt containing:
file cut.mp4
file newEnd.mp4
Instead of 43s + 5s =48 s the resulting video is significantly longer
as the fps decreased again :-/
ffmpeg.exe -i finalresult.mp4
Duration: 00:01:13.41, start: 0.000000, bitrate: 63 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
480x270 [SAR 1:1 DAR 16:9], 62 kb/s, 6.43 fps, 20 tbr, 15696 tbn, 40 tbc
If I use VLC to watch the resulting video the newEnd is not shown but
the video freezes at the end. I tested various approaches (with and
without "-r" option, providing length in the videos.txt, ...) but I
don't get it to work. Help is highly appreciated, already many thanks!!
Hauke
More information about the ffmpeg-user
mailing list