I am new, pls help me cut video

Website, builds, or other suggestions.
Post Reply
Thanhgsm
Posts: 1
Joined: Sun Dec 30, 2018 10:46 pm

I am new, pls help me cut video

Post by Thanhgsm » Sun Dec 30, 2018 10:53 pm

Hi friends, 1st time I use FFmpeg so not have experience. Pls help me cutting video into multiple 5 seconds sences. Pls help me check correct code. Thank you so much.

ffmpeg -i scv31.mp4 -vcodec copy -acodec copy -map 0 -segment_time 00:01:00 -f segment output%03d.mp4

Code: Select all

@ECHO OFF
REM FF Prompt 1.2
REM Open a command prompt to run ffmpeg/ffplay/ffprobe
REM Copyright (C) 2013-2015  Kyle Schwarz

TITLE FF Prompt

IF NOT EXIST bin\ffmpeg.exe (
  CLS
  ECHO bin\ffmpeg.exe could not be found.
  GOTO:error
)

CD bin || GOTO:error
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS
ffmpeg -version
ECHO.
ECHO For help run: ffmpeg -h
ECHO For formats run: ffmpeg -formats ^| more
ECHO For codecs run: ffmpeg -codecs ^| more
ECHO.
ECHO Current directory is now: "%CD%"
ECHO The bin directory has been added to PATH
ECHO.

ffmpeg -i scv31.mp4 -vcodec copy -acodec copy -map 0 -segment_time 00:01:00 -f segment output%03d.mp4

CMD /Q /K 
GOTO:EOF

:error
ECHO.
ECHO Press any key to exit.
PAUSE >nul
GOTO:EOF

I get error:

Code: Select all

ffmpeg version N-92833-gfccba32b4c Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 8.2.1 (GCC) 20181201
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfr
eetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
 --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --en
able-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-lib
wavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --en
able-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enab
le-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enab
le-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --ena
ble-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable
-avisynth --enable-libopenmpt
libavutil      56. 25.100 / 56. 25.100
libavcodec     58. 42.104 / 58. 42.104
libavformat    58. 25.100 / 58. 25.100
libavdevice    58.  6.101 / 58.  6.101
libavfilter     7. 46.101 /  7. 46.101
libswscale      5.  4.100 /  5.  4.100
libswresample   3.  4.100 /  3.  4.100
libpostproc    55.  4.100 / 55.  4.100

For help run: ffmpeg -h
For formats run: ffmpeg -formats | more
For codecs run: ffmpeg -codecs | more

Current directory is now: "C:\Cut video\bin"
The bin directory has been added to PATH

ffmpeg version N-92833-gfccba32b4c Copyright (c) 2000-2018 the FFmpeg developers

  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-lib
freetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amr
wb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --
enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l
ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --en
able-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --en
able-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --e
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enab
le-avisynth --enable-libopenmpt
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 42.104 / 58. 42.104
  libavformat    58. 25.100 / 58. 25.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'scv31.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-02-28T06:00:22.000000Z
  Duration: 00:06:17.79, start: 0.000000, bitrate: 17260 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080
, 17003 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2016-02-28T06:00:22.000000Z
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
p, 256 kb/s (default)
    Metadata:
      creation_time   : 2016-02-28T06:00:22.000000Z
      handler_name    : SoundHandle
[mp4 @ 00000000003cf0c0] Invalid segment filename template 'outputC:\Cut video\f
f-prompt.bat3d.mp4'
Could not write header for output file #0 (incorrect codec parameters ?): Invali
d argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
    Last message repeated 1 times
C:\Cut video\bin
>

therube
Posts: 30
Joined: Thu Nov 02, 2017 7:41 pm

Re: I am new, pls help me cut video

Post by therube » Thu Jan 03, 2019 4:31 am

It looks like the batch file is interpreting the %03d in a manner you're not wanting.
(It works fine like that directly from a command prompt.)

Not sure the "correct" method to fix it, so I simply tried adding an extra %, so %%3d, & that looks to work (in the batch file).
(Likewise, it breaks things when run directly from a command prompt ;-).)


Heh, turns out %% may even be "correct", Escape Characters.

Post Reply