VideoHelp Forum




+ Reply to Thread
Results 1 to 12 of 12
  1. 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
    Last edited by shuantsu; 3rd Jun 2015 at 15:44.
    Quote Quote  
  2. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    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
    Quote Quote  
  3. Originally Posted by Cornucopia View Post
    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

    Thanks for the fast reply...... but that doesn't solve the problem.
    Last edited by shuantsu; 3rd Jun 2015 at 15:56.
    Quote Quote  
  4. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    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
    Quote Quote  
  5. 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_times
    Last edited by shuantsu; 3rd Jun 2015 at 17:33.
    Quote Quote  
  6. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    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........
    Quote Quote  
  7. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    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.
    Scott
    Quote Quote  
  8. Originally Posted by shuantsu View Post
    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.
    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.
    Quote Quote  
  9. 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.
    How can I "force the reference stream key-frames at the given time"? What command should I use?

    Also, using segment_times or segment_time is giving me the message unrecognized option segment_times or unrecognized option segment_time
    Last edited by shuantsu; 4th Jun 2015 at 20:17.
    Quote Quote  
  10. *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.
    Quote Quote  
  11. 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.
    Quote Quote  
  12. Member
    Join Date
    Jul 2015
    Location
    Colombia
    Search Comp PM
    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!