Hey guys
I have a python script that lists videos and their chapters and permits the user to cut these chapters out.
But the problem is that even tough I provided the start and end of the chapter, ffmpeg is cutting some seconds before or after these chapters.
I even opened a video and took note of how many milliseconds it was delaying, then putted that on my script, but the offset varies from video to video. ffmpeg is not obeying my command. It just cuts wherever it feels like it. This is driving me nuts.
Here it is an example:
ffmpeg -y -ss 00:06:36.830 -t 00:00:23.657 -i "videos\bh_LSB_00_r240P.m4v" -vcodec copy "C:\DOCS\FILIPE\SCRIPTS\Jw chopper\out\23_Isaias\35\006.m4v"
Like I said, it cuts a little before or/and after those times.
Is there any other command line tool that would permit doing the same job accurately? I would rather stick to ffmpeg if this has a solution.
Please help
+ Reply to Thread
Results 1 to 12 of 12
-
Last edited by shuantsu; 3rd Jun 2015 at 15:44.
-
http://ffmpeg-users.933282.n4.nabble.com/force-key-frames-td4669084.html says you have to use list of actual timecodes (to hit specific target times such as a chapter start) or an equation (to hit regular time intervals such as 1/2 second), and of course these only work when you are (re/trans-)encoding. Your script example has no time values attributed to the force_key_frames switch. You may need to include accompanying & exactly corresponding time values list for the "-segment_times" switch (haven't tried that yet so not sure), which I notice you don't have in that script either.
Scott -
Last edited by shuantsu; 3rd Jun 2015 at 15:56.
-
Why not? How so?
IIWY, I'd use matching timecodes on both force_key_frames and segment_times switches, just like the advice says.
"Segment" has to cut on GOP boundaries, as per documentation. But those boundaries don't have to be where YOU wanted the chapters to start, unless you explicitly account for them.
Scott -
I'm trying to do what you said, this is what I have so far, after reading ffmpeg documentation
-force_key_frames[ : stream_specifier] time[,time...] (output,per-stream)
https://ffmpeg.org/ffmpeg.html
ffmpeg -y -ss 00:09:26.33 -t 00:00:13.446 -i "C:\DOCS\FILIPE\VIDEOS LIBRAS\LV\lv_LSB_01_r480P.m4v" -vcodec copy "C:\DOCS\FILIPE\SCRIPTS\Jw chopper\out\19_Salmos\11\005.m4v" -force_key_frames 00:09:26.33, 00:00:13.446
but its giving me this message:
Unable to find a suitable output format for '00:00:13.446'
Also, segment_times is giving this error:
Unrecognized option 'segment_times'
There is nothing in the documentation about segment_timesLast edited by shuantsu; 3rd Jun 2015 at 17:33.
-
Your using -c copy. Therefore it can only cut at nearest key-frame. Depending on GOP length it could be + or - 1~3 seconds from where you want to make the cuts. To be accurate, it will need to be re-encoded.
Got my retirement plans all set. Looks like I only have to work another 5 years after I die........ -
Yes there is. In the Formats 4.17 ("Segments") section.
Again, how can you have "-vcodec copy" when you have to re-encode (because re-encoding is ALWAYS necessary when creating/forcing keyframes)?* And, unless I'm misinterpreting this, are you wanting to put a keyframe on the last frame?
*re:Seeking / Re-encoding vs. Copy
Seeking while doing a bitstream copy
Using -ss as input option together with -c:v copy might not be accurate since ffmpeg is forced to only use/split on i-frames. Though it will—if possible—adjust the start time of the stream to a negative value to compensate for that. -
I don't know of such commands. I only know that I also had a problem with the accurate cutting and joining of containers MKV / MP4. Everything was based on keyframes (GOP).
I think you will be forced to buy SolveigMM Video Splitter 5 based on FFmpeg. I think that the cutter has been deliberately modified to somehow accuracy frames. -
Jakaima, SolveigMM Video Splitter don't give the option to select chapters and copy them, like my script does.
If I have to re-encode my video, what encoder you guys suggest? Do I have to do two commands, one to re-encode and one to split the video?
Also, checking the documentation it says:
segment_time time
Set segment duration to time, the value must be a duration specification. Default value is "2". See also the segment_times option.
Note that splitting may not be accurate, unless you force the reference stream key-frames at the given time. See the introductory notice and the examples below.
Also, using segment_times or segment_time is giving me the message unrecognized option segment_times or unrecognized option segment_timeLast edited by shuantsu; 4th Jun 2015 at 20:17.
-
*bump*
Guys, please help. I can't make this to work. I opened a question on super user:
http://superuser.com/questions/924223/ffmpeg-no-cutting-accurately
But some guy told me that I should re-encode the video with h.624. I did it but the video turned the triple of it size. And when I cutted the video it did it with 5 or 6 seconds of difference. Way worst than without re-encoding.
Someone please help me. I'm desperate. -
Feature "accurate editing" is not cutting lossless. This is a re-conversion to the frame I.
Accordingly, since it doesn't mean cutting lossless it is not it better to convert the whole piece? I don't see the point of that record for long-GOP 50 <> 250.
ffmpeg -y -ss 00:37:32.52 -t 00:00:10.244 -i "videos\bh_LSB_01_r240P.m4v" -vcodec copy "out\19_Salmos\90\002.m4v"Last edited by Jamaika; 8th Jun 2015 at 07:17.
-
Hi, are you still needing help .. I'm also jht and I have solution in bash. You can emulate it on windows. Are you interested?
You found the exact timecode chapter at the metadata on the file.
Similar Threads
-
Just an idea: ffmpeg based key frame accurate cutting,...
By Selur in forum Newbie / General discussionsReplies: 30Last Post: 21st Mar 2017, 03:56 -
cutting file .ts accurately
By muxado in forum Video ConversionReplies: 2Last Post: 21st Apr 2013, 07:41 -
How can I ACCURATELY split/cut a video file?
By KushSmoka420 in forum EditingReplies: 5Last Post: 2nd Mar 2012, 14:16 -
Splitting/cutting/joining MP4 accurately...
By The.King in forum EditingReplies: 2Last Post: 2nd Nov 2011, 12:35 -
How to accurately synchronize a subtitle file with another
By scept in forum SubtitleReplies: 5Last Post: 24th Oct 2010, 07:08