Reputation: 97
I'm using ffmpeg to cut a video. Here is the input information:
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 5113 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
And this is the command I use:
ffmpeg -y -ss 10 -t 5 -i test.mp4 -c copy output.mp4
But the output duration is about 9.66 seconds.
It worked when I removed the '-c copy' option or the input doesn't contain the 'tv, bt709' tag. But it's slower.
I wonder how I can use '-c copy' and get the right piece of video I need?
Upvotes: 6
Views: 6513
Reputation: 1091
Check you file by ffprobe,
ffprobe -show_entries format <input_file>
Check the property, start_time
, maybe in your case the property no a zero.
Upvotes: 0
Reputation: 8533
In my situation, I don't use -c copy
but still receive an incorrect duration. Upon investigation, I found that it caused by "video chapters". So disable chapters by -map_chapters -1
will output the correct duration.
ffmpeg -ss 04:20 -to 04:41 -i "$input_file" -c:a aac -c:v h264_videotoolbox -b:v 29445k -map_chapters -1 "output.mp4"
-ss 04:20 : From
-to 04:41 : To
-i "$input_file" : Input file
-c:a aac : Set AAC codec for audio output
-c:v h264_videotoolbox : h264 hw encoder on Mac
-b:v 29445k : Output video bitrate
-map_chapters -1 : Disable video chapters
"output.mp4" : Output file
Upvotes: 13
Reputation: 75
just delete -c copy and you will get the exact cut.
"ffmpeg -y -ss 10 -t 5 -i test.mp4 output.mp4"
Upvotes: -1
Reputation: 3384
The first command will cut from 00:01:00 to 00:03:00 (in the original), using the faster seek.
The second command will cut from 00:01:00 to 00:02:00, as intended, using the slower seek.
The third command will cut from 00:01:00 to 00:02:00, as intended, using the faster seek.
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
ffmpeg -i video.mp4 -ss 00:01:00 -to 00:02:00 -c copy cut.mp4
ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4
Full document enter link description here
Upvotes: 2
Reputation: 108
from the ffmpeg documentation:
-t duration (input/output) When used as an input option (before -i), limit the duration of data read from the input file.
When used as an output option (before an output url), stop writing the output after its duration reaches duration.
duration must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.
Given this, if you want a 5 seconds video stream try to specify the duration you want to read from the input file (before the -i tag) and the duration you want from your final output file (before the output url)
Upvotes: 0