Newsgroup: it.comp.os.linux.iniziare
Titolo: estrarre porzione di un video

$ ffmpeg -i x.mp4 -vcodec copy -acodec copy -ss 00:00:10 -t 00:00:30 x.mp4
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg 
developers
   built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
   configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu 
--incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping 
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa 
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca 
--enable-libcdio --enable-libflite --enable-libfontconfig 
--enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm 
--enable-libmp3lame --enable-libmysofa --enable-libopenjpeg 
--enable-libopenmpt --enable-libopus --enable-libpulse 
--enable-librubberband --enable-librsvg --enable-libshine 
--enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh 
--enable-libtheora --enable-libtwolame --enable-libvorbis 
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 
--enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi 
--enable-omx --enable-openal --enable-opengl --enable-sdl2 
--enable-libdc1394 --enable-libdrm --enable-libiec61883 
--enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 
--enable-shared
   libavutil      55. 78.100 / 55. 78.100
   libavcodec     57.107.100 / 57.107.100
   libavformat    57. 83.100 / 57. 83.100
   libavdevice    57. 10.100 / 57. 10.100
   libavfilter     6.107.100 /  6.107.100
   libavresample   3.  7.  0 /  3.  7.  0
   libswscale      4.  8.100 /  4.  8.100
   libswresample   2.  9.100 /  2.  9.100
   libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'x.mp4':
   Metadata:
     major_brand     : mp42
     minor_version   : 0
     compatible_brands: isommp42
     creation_time   : 2018-12-26T07:49:41.000000Z
   Duration: 00:04:37.90, start: 0.000000, bitrate: 179 kb/s
     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 
0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 80 kb/s, 30 
fps, 30 tbr, 15360 tbn, 60 tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 
stereo, fltp, 95 kb/s (default)
     Metadata:
       creation_time   : 2018-12-26T07:49:41.000000Z
       handler_name    : IsoMedia File Produced by Google, 5-11-2011
File 'x.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'x.mp4':
   Metadata:
     major_brand     : mp42
     minor_version   : 0
     compatible_brands: isommp42
     encoder         : Lavf57.83.100
     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 
0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 80 
kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 
stereo, fltp, 95 kb/s (default)
     Metadata:
       creation_time   : 2018-12-26T07:49:41.000000Z
       handler_name    : IsoMedia File Produced by Google, 5-11-2011
Stream mapping:
   Stream #0:0 -> #0:0 (copy)
   Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55c4436c3e20] stream 1, offset 0x200c1: 
partial file
x.mp4: Invalid data found when processing input
frame=    0 fps=0.0 q=-1.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A 
speed=   0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: unknown
 
Ogni volta è un problema...

 ffmpeg -i x.mp4 -vcodec copy -acodec copy -ss 00:00:10 -t 00:00:30 x.mp4
 
Differenzia il nome del video di destinazione da quello d'origine.
Se vuoi mantenere gli stessi codec audio e video puoi anche usare la forma
abbreviata "-c copy" al posto di "-vcodec copy -acodec copy".
 

Il 26/12/18 18:37, Tony Borlini ha scritto:

Benissimo, grazie :D


Io utilizzavo gli switch -ss xxx -to xxx in questo modo tagliavo dalla 
posizione iniziale x alla posizione finale y, senza dare il lasso di 
tempo da tagliare a partire dalla posizione iniziale x.
 
Esempio:
ffmpeg -report -i input.mp4 -ss 01:32:00.000 -to 01:40:32.000 -acodec copy 
-vcodec copy output.mp4
 
Naturalmente se poi ti servono più segmenti, puoi unire i vari comandi in 
uno script unico:
 
#!/bin/bash
ffmpeg -report -i input.mp4 -ss 00:00:00.000 -to 00:03:00.000 -acodec copy 
-vcodec copy output001.mp4
ffmpeg -report -i input.mp4 -ss 00:05:00.000 -to 00:07:00.000 -acodec copy 
-vcodec copy output002.mp4
ffmpeg -report -i input.mp4 -ss 00:29:00.000 -to 00:30:37.000 -acodec copy 
-vcodec copy output003.mp4
 
[eccetera]
 
Ciao,
Nemo

Il 27/12/18 19:39, Nemo ha scritto:

grazie ancora :D