Hello
I have used this code to extract h264 streams from mp4 file and split it but when i have joined splited parts but there was problems.
Original clip's duration is 1:20:18 but joined clip is 1:25:11!Code:for %%a in ("*.mp4") do "C:\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vcodec copy -bsf h264_mp4toannexb -an -f h264 -ss 00:00:00 -t 00:08:30 "%%~na-01.h264" for %%a in ("*.mp4") do "C:\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vcodec copy -bsf h264_mp4toannexb -an -f h264 -ss 00:08:30 -t 00:10:30 "%%~na-02.h264" for %%a in ("*.mp4") do "C:\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vcodec copy -bsf h264_mp4toannexb -an -f h264 -ss 00:10:30 -t 10800 "%%~na-03.h264" pause
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 5 of 5
Thread
-
Last edited by ben45; 9th Oct 2016 at 15:40.
-
https://trac.ffmpeg.org/wiki/Seeking#Seekingwhiledoingacodeccopy
You need cut on I frames...
https://ffmpeg.org/ffmpeg-all.html#Main-options
-ss position (input/output)
When used as an input option (before -i), seeks in this input file to position. Note that in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.
When used as an output option (before an output filename), decodes but discards input until the timestamps reach position.
position must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual. -
ffmpeg has the segment format that always cuts on GOP boundaries.
Here's a little batch file that works for me. Offered as-is & without support.
ffmpeg-split.batCode:@echo off :: https://forum.videohelp.com/threads/380794?p=2462195#post2462195 :: http://ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment :: CONFIG :: * select segment list type (default .m3u8 playlist) :: * set -segment_time (default 10 sec) :: * set codecs etc :: * maybe set an output folder :: * uncomment one (and only one) OPTION below :: OPTION 1 - call with single file argument if not exist "%~dpnx1" goto :EOF cd "%~dp1" call :M3U8_LIST "%~nx1" :: OPTION 2 - process whole folder (caution) ::for %%f in (*.mp4) do call :M3U8_LIST "%%~nxf" goto :eof :: generate 'name.ext' list in csv format: :: segment_filename,segment_start_time,segment_end_time :CSV_LIST @echo on ffmpeg -i "%~nx1" -codec copy ^ -f segment -segment_time 10 -segment_start_number 1000 ^ -segment_list_type "ext" -segment_list "%~n1.ext" ^ "%~n1-seg%%d%~x1" @echo off if errorlevel 1 pause goto :eof :: generate 'name.concat' file in ffmpeg 'concat' format :CONCAT_LIST @echo on ffmpeg -i "%~nx1" -codec copy ^ -f segment -segment_time 10 -segment_start_number 1000 ^ -segment_list_type "ffconcat" -segment_list "%~n1.concat" ^ "%~n1-seg%%d%~x1" @echo off if errorlevel 1 pause goto :eof :: generate 'name.m3u8' file, version 3, compliant with :: http://tools.ietf.org/id/draft-pantos-http-live-streaming :: and playable in MPC-HC :M3U8_LIST @echo on ffmpeg -i "%~nx1" -codec copy ^ -f segment -segment_time 10 -segment_start_number 1000 ^ -segment_list_type "m3u8" -segment_list "%~n1.m3u8" ^ "%~n1-seg%%d%~x1" @echo off if errorlevel 1 pause goto :eof
-
Thanks for reply
I'm not familiar with ffmpeg. coud you please correct my code?
Code:for %%a in ("*.mp4") do "C:\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vcodec copy -bsf h264_mp4toannexb -an -f h264 -ss 00:00:00 -t 00:08:30 "%%~na-01.h264" for %%a in ("*.mp4") do "C:\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vcodec copy -bsf h264_mp4toannexb -an -f h264 -ss 00:08:30 -t 00:10:30 "%%~na-02.h264" for %%a in ("*.mp4") do "C:\ffmpeg\bin\ffmpeg.exe" -i "%%a" -vcodec copy -bsf h264_mp4toannexb -an -f h264 -ss 00:10:30 -t 10800 "%%~na-03.h264" pause
-
ffmpeg have limitations and this is not about improving script - try raffriff42 script and perhaps consider to modify your own with using https://ffmpeg.org/ffmpeg-all.html#segment_002c-stream_005fsegment_002c-ssegment .
Similar Threads
-
Split subtitle in 12 parts by the end of the video
By Username2013 in forum SubtitleReplies: 2Last Post: 14th Jan 2016, 11:29 -
FFMPEG - How to record multiple RTMP streams into multiple files
By wwwmaster2k in forum CapturingReplies: 1Last Post: 11th Jul 2014, 12:51 -
Split AVI video into several parts
By phedon in forum Newbie / General discussionsReplies: 5Last Post: 27th Jan 2013, 11:18 -
[VirtualDub] How to split avi to x parts with one operation?
By ralf07 in forum Video ConversionReplies: 3Last Post: 5th Apr 2012, 17:01 -
Split a giant MKV into parts, at specific spots?
By Asterra in forum Newbie / General discussionsReplies: 4Last Post: 12th Jan 2012, 01:15