
Recherche avancée
Médias (91)
-
Spitfire Parade - Crisis
15 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Wired NextMusic
14 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
-
Sintel MP4 Surround 5.1 Full
13 mai 2011, par
Mis à jour : Février 2012
Langue : English
Type : Video
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (63)
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...) -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
Sur d’autres sites (5757)
-
FFMPEG Wierd behaviour for atrim, concat, setpts
22 novembre 2016, par Prasanna MahendiranMy actual app
So actually I was designing an app which uses HTML5 video player. I am capturing the seekbar events and then cutting the video and audio of it.
I am storing the breakpoint events from when it seeked and to where it seeked. For example, if 10 second video has [ [1,2], [5,8] ] then it means
Video starts from 0 to 1 seeked to 2 then moves till 5 then seeked to 8 then moved till 10.PROBLEM :
So I wanted to slice a video and then I got the error "Buffer queue overflow, dropping". The frames of both video and audio dropped in the output file. I did a bit of research and found the following flaw. Code1 creates problem but Code2 doesn’t create that problem.
Code1
ffmpeg -i sample_cat.mp4 -filter_complex \
"[0:v]split=2[v0][v1];
[v0]trim=32:34,setpts=N/FRAME_RATE/TB[0v];
[v1]trim=34:37,setpts=N/FRAME_RATE/TB[1v];
[0:a]asplit=2[a0][a1];
[a0]atrim=36:34,asetpts=N/SR/TB[0a];
[a1]atrim=34:37,asetpts=N/SR/TB[1a];
[0v][0a][1v][1a]concat=n=2:v=1:a=1[vv][aa]" -map "[vv]" -map "[aa]" output.mp4Code2
ffmpeg -i sample_cat.mp4 -filter_complex \
"[0:v]split=2[v0][v1];
[v0]trim=32:34,setpts=N/FRAME_RATE/TB[0v];
[v1]trim=4:37,setpts=N/FRAME_RATE/TB[1v];
[0:a]asplit=2[a0][a1];
[a0]atrim=36:34,asetpts=N/SR/TB[0a];
[a1]atrim=4:37,asetpts=N/SR/TB[1a];
[0v][0a][1v][1a]concat=n=2:v=1:a=1[vv][aa]" -map "[vv]" -map "[aa]" output.mp4Between the two code there is only one difference. Also I noticed when the subsequent trims have time greater than the current end time of the trim then it doesn’t create any problem. Why does it happen like this ?
Adding full console output of the error
ffmpeg version 3.2-1~16.04.york1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.1 (Ubuntu 5.4.1-3ubuntu1~ubuntu16.04.1york0) 20161019
configuration: --prefix=/usr --extra-version='1~16.04.york1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-libtesseract --disable-stripping --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libschroedinger --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-libxvid --enable-libzmq --enable-libzvbi --enable-opengl --enable-sdl2 --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-openal --enable-frei0r --enable-libopencv --enable-libx264 --enable-chromaprint --enable-shared
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample_cat.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.56.100
Duration: 00:04:58.61, start: 0.000000, bitrate: 754 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 4:3 DAR 16:9], 621 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(slv): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'output.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x55642fc5cda0] using SAR=4/3
[libx264 @ 0x55642fc5cda0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x55642fc5cda0] profile High, level 3.0
[libx264 @ 0x55642fc5cda0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 4:3 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc57.64.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 (h264) -> split
concat -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[Parsed_concat_5 @ 0x55642fc8ca40] Buffer queue overflow, dropping.
Last message repeated 275 times
[Parsed_concat_5 @ 0x55642fc8ca40] Buffer queue overflow, dropping.N/A speed= 0x
Last message repeated 367 times
[output stream 0:0 @ 0x55642fca0b60] 100 buffers queued in output stream 0:0, something may be wrong.
frame= 1048 fps=174 q=-1.0 Lsize= 1334kB time=00:00:34.86 bitrate= 313.5kbits/s dup=644 drop=0 speed=5.78x
video:1322kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.913387%
[libx264 @ 0x55642fc5cda0] frame I:6 Avg QP:18.30 size: 28894
[libx264 @ 0x55642fc5cda0] frame P:398 Avg QP:22.39 size: 2493
[libx264 @ 0x55642fc5cda0] frame B:644 Avg QP:29.79 size: 292
[libx264 @ 0x55642fc5cda0] consecutive B-frames: 15.9% 4.2% 6.6% 73.3%
[libx264 @ 0x55642fc5cda0] mb I I16..4: 8.6% 67.7% 23.7%
[libx264 @ 0x55642fc5cda0] mb P I16..4: 2.5% 4.9% 0.5% P16..4: 25.4% 6.9% 2.1% 0.0% 0.0% skip:57.6%
[libx264 @ 0x55642fc5cda0] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 8.0% 1.0% 0.1% direct: 0.2% skip:90.6% L0:41.2% L1:54.0% BI: 4.7%
[libx264 @ 0x55642fc5cda0] 8x8 transform intra:63.4% inter:82.9%
[libx264 @ 0x55642fc5cda0] coded y,uvDC,uvAC intra: 45.4% 57.8% 16.4% inter: 3.9% 5.3% 0.5%
[libx264 @ 0x55642fc5cda0] i16 v,h,dc,p: 31% 25% 10% 34%
[libx264 @ 0x55642fc5cda0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 19% 18% 4% 7% 8% 7% 6% 5%
[libx264 @ 0x55642fc5cda0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 15% 11% 4% 8% 10% 6% 6% 4%
[libx264 @ 0x55642fc5cda0] i8c dc,h,v,p: 56% 17% 22% 5%
[libx264 @ 0x55642fc5cda0] Weighted P-Frames: Y:3.3% UV:2.5%
[libx264 @ 0x55642fc5cda0] ref P L0: 76.0% 11.5% 10.2% 2.2% 0.0%
[libx264 @ 0x55642fc5cda0] ref B L0: 92.3% 7.1% 0.7%
[libx264 @ 0x55642fc5cda0] ref B L1: 96.3% 3.7%
[libx264 @ 0x55642fc5cda0] kb/s:309.60 -
FFMPEG Concat with Videos in millisecond Length results in broken Video
1er septembre 2023, par SnickbrackI am using this List of Videos for Concatination in FFMPEG :


file 'C:\Work\test\RandomUpwardShots\0dcd83e6-1931-4bf1-87f0-211c758050f3.mp4'
inpoint 00:00:07.4890000
outpoint 00:00:07.7250000
file 'C:\Work\test\RandomUpwardShots\0dcd83e6-1931-4bf1-87f0-211c758050f3.mp4'
inpoint 00:00:01.6300000
outpoint 00:00:01.8660000
file 'C:\Work\test\RandomUpwardShots\0dcd83e6-1931-4bf1-87f0-211c758050f3.mp4'
inpoint 00:00:12.7170000
outpoint 00:00:12.9530000
file 'C:\Work\test\RandomUpwardShots\0dcd83e6-1931-4bf1-87f0-211c758050f3.mp4'
inpoint 00:00:05.6260000
outpoint 00:00:05.8620000
file 'C:\Work\test\RandomUpwardShots\0dcd83e6-1931-4bf1-87f0-211c758050f3.mp4'
inpoint 00:00:49.5930000
outpoint 00:00:49.8290000
file 'C:\Work\test\RandomUpwardShots\0dcd83e6-1931-4bf1-87f0-211c758050f3.mp4'
inpoint 00:00:50.3050000
outpoint 00:00:50.5410000
file 'C:\Work\test\RandomUpwardShots\18c1a3cc-5817-4676-a01b-18cc72f9dad7.mp4'
inpoint 00:00:28.1420000
outpoint 00:00:28.6830000
file 'C:\Work\test\RandomUpwardShots\18c1a3cc-5817-4676-a01b-18cc72f9dad7.mp4'
inpoint 00:00:08.0820000
outpoint 00:00:08.6230000
file 'C:\Work\test\RandomUpwardShots\18c1a3cc-5817-4676-a01b-18cc72f9dad7.mp4'
inpoint 00:00:18.6850000
outpoint 00:00:19.2260000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:22.3670000
outpoint 00:00:22.5140000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:03.4820000
outpoint 00:00:03.6290000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:40.2620000
outpoint 00:00:40.4090000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:49.5600000
outpoint 00:00:49.7070000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:20.4010000
outpoint 00:00:20.5480000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:30.4620000
outpoint 00:00:30.6090000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:40.8190000
outpoint 00:00:40.9660000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:03.5130000
outpoint 00:00:03.6600000
file 'C:\Work\test\RandomUpwardShots\1af968d4-a6e9-4c44-a6d9-c6c06bb8631a.mp4'
inpoint 00:00:20.0250000
outpoint 00:00:20.1720000
file 'C:\Work\test\RandomUpwardShots\22c3c2e2-4ab9-4ced-ada0-48eaeb4d0854.mp4'
inpoint 00:00:07.8730000
outpoint 00:00:08.2310000
file 'C:\Work\test\RandomUpwardShots\22c3c2e2-4ab9-4ced-ada0-48eaeb4d0854.mp4'
inpoint 00:00:02.9720000
outpoint 00:00:03.3300000
file 'C:\Work\test\RandomUpwardShots\22c3c2e2-4ab9-4ced-ada0-48eaeb4d0854.mp4'
inpoint 00:00:15.0240000
outpoint 00:00:15.3820000
file 'C:\Work\test\RandomUpwardShots\22c3c2e2-4ab9-4ced-ada0-48eaeb4d0854.mp4'
inpoint 00:00:14.9730000
outpoint 00:00:15.3310000
file 'C:\Work\test\RandomUpwardShots\22c3c2e2-4ab9-4ced-ada0-48eaeb4d0854.mp4'
inpoint 00:00:10.9450000
outpoint 00:00:11.3030000
file 'C:\Work\test\RandomUpwardShots\22c3c2e2-4ab9-4ced-ada0-48eaeb4d0854.mp4'
inpoint 00:00:12.3510000
outpoint 00:00:12.7090000
file 'C:\Work\test\RandomUpwardShots\61c509e8-efbf-4697-872a-dc288e5ae8d3.mp4'
inpoint 00:00:06.7640000
outpoint 00:00:07.0580000
file 'C:\Work\test\RandomUpwardShots\61c509e8-efbf-4697-872a-dc288e5ae8d3.mp4'
inpoint 00:00:38.3440000
outpoint 00:00:38.6380000
file 'C:\Work\test\RandomUpwardShots\61c509e8-efbf-4697-872a-dc288e5ae8d3.mp4'
inpoint 00:00:01.6260000
outpoint 00:00:01.9200000
file 'C:\Work\test\RandomUpwardShots\61c509e8-efbf-4697-872a-dc288e5ae8d3.mp4'
inpoint 00:00:01.8380000
outpoint 00:00:02.1320000
file 'C:\Work\test\RandomUpwardShots\61c509e8-efbf-4697-872a-dc288e5ae8d3.mp4'
inpoint 00:00:06.9730000
outpoint 00:00:07.2670000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:38.4000000
outpoint 00:00:38.5950000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:12.3260000
outpoint 00:00:12.5210000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:23.9310000
outpoint 00:00:24.1260000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:39.6420000
outpoint 00:00:39.8370000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:06.5000000
outpoint 00:00:06.6950000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:43.1100000
outpoint 00:00:43.3050000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:52.4960000
outpoint 00:00:52.6910000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:34.0990000
outpoint 00:00:34.2940000
file 'C:\Work\test\RandomUpwardShots\8a3041f6-7eba-4473-bd5c-2cf05f31e62c.mp4'
inpoint 00:00:33.3750000
outpoint 00:00:33.5700000
file 'C:\Work\test\RandomUpwardShots\8a769a1c-9ba7-4d59-bbea-f91fddb962a0.mp4'
inpoint 00:00:37.3980000
outpoint 00:00:37.9280000
file 'C:\Work\test\RandomUpwardShots\8a769a1c-9ba7-4d59-bbea-f91fddb962a0.mp4'
inpoint 00:00:25.1330000
outpoint 00:00:25.6630000
file 'C:\Work\test\RandomUpwardShots\8a769a1c-9ba7-4d59-bbea-f91fddb962a0.mp4'
inpoint 00:00:22.3130000
outpoint 00:00:22.8430000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:35.4570000
outpoint 00:00:35.6000000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:07.5190000
outpoint 00:00:07.6620000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:38.3690000
outpoint 00:00:38.5120000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:58.3520000
outpoint 00:00:58.4950000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:21.8970000
outpoint 00:00:22.0400000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:57.4000000
outpoint 00:00:57.5430000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:10.0960000
outpoint 00:00:10.2390000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:32.0420000
outpoint 00:00:32.1850000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:39.9040000
outpoint 00:00:40.0470000
file 'C:\Work\test\RandomUpwardShots\8a7951aa-70c8-4943-a059-a02264e82ddc.mp4'
inpoint 00:00:03.7370000
outpoint 00:00:03.8800000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:23.5900000
outpoint 00:00:23.7960000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:39.9760000
outpoint 00:00:40.1820000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:25.0120000
outpoint 00:00:25.2180000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:32.9350000
outpoint 00:00:33.1410000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:25.0670000
outpoint 00:00:25.2730000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:13.9150000
outpoint 00:00:14.1210000
file 'C:\Work\test\RandomUpwardShots\8cc0daf7-affd-4e16-bd2b-31727829b9eb.mp4'
inpoint 00:00:49.3900000
outpoint 00:00:49.5960000
file 'C:\Work\test\RandomUpwardShots\9ce865a0-4c34-478e-9952-72e4c280daf7.mp4'
inpoint 00:00:27.2750000
outpoint 00:00:28.0520000



And this command in CLI :


ffmpeg -y -safe 0 -f concat -i outputFile.txt -map 0:v -map 0:a -c:a copy -c:v copy outputFile.mp4


And I get this Video as a result :
https://www.youtube.com/shorts/gG4GG-0gIqw


The Points why I call this broken :


- 

- Audio has clearly some scrubbing to it
- The Video is playing under Windows (VLC-Player) but the Audio is "gone" after the first Clip
- The Video shows clearly some Fragments under Windows and you can't see anything








(For Point 2 and 3 this is not visible in the Youtube-Video. Sadly I dont know why. But I also dont know how to share the resulting video...)


Is there anything to clear this up ? Is there a way to re-encode the separate Clips after cutting them with FFMPEG ?


-
ffmpeg takes a while to start
17 octobre 2020, par SuspendedI have this command in python script, in a loop :


ffmpeg -i somefile.mp4 -ss 00:03:12 -t 00:00:35 piece.mp4 -loglevel error -stats



It cuts out pieces of input file (-i). Input filename, as well as start time (-ss) and length of the piece I cut out (-t) varies, so it reads number of mp4 files and cuts out number of pieces from each one. During execution of the script it might be called around 100 times. My problem is that each time before it starts, there is a delay of few seconds and it adds up to significant time. How can I get it to start immediately ?


The script (process_videos.py) :


import subprocess
import sys
import math
import time

class TF:
 """TimeFormatter class (TF).
This class' reason for being is to convert time in short
form, e.g. 1:33, 0:32, or 23 into long form accepted by
mp4cut function in bash, e.g. 00:01:22, 00:00:32, etc"""

def toLong(self, shrt):
 """Converts time to its long form"""
 sx = '00:00:00'
 ladd = 8 - len(shrt)
 n = sx[:ladd] + shrt
 return n

def toShort(self, lng):
 """Converts time to short form"""
 if lng[0] == '0' or lng[0] == ':':
 return self.toShort(lng[1:])
 else:
 return lng

def toSeconds(self, any_time):
 """Converts time to seconds"""
 if len(any_time) < 3:
 return int(any_time)
 tt = any_time.split(':')
 if len(any_time) < 6: 
 return int(tt[0])*60 + int(tt[1])
 return int(tt[0])*3600 + int(tt[1])*60 + int(tt[2])

def toTime(self, secsInt):
 """"""
 tStr = ''
 hrs, mins, secs = 0, 0, 0
 if secsInt >= 3600:
 hrs = math.floor(secsInt / 3600)
 secsInt = secsInt % 3600
 if secsInt >= 60:
 mins = math.floor(secsInt / 60)
 secsInt = secsInt % 60
 secs = secsInt
 return str(hrs).zfill(2) + ':' + str(mins).zfill(2) + ':' + str(secs).zfill(2)

def minus(self, t_start, t_end):
 """"""
 t_e = self.toSeconds(t_end)
 t_s = self.toSeconds(t_start)
 t_r = t_e - t_s
 hrs, mins, secs = 0, 0, 0
 if t_r >= 3600:
 hrs = math.floor(t_r / 3600)
 t_r = t_r - (hrs * 3600)
 if t_r >= 60:
 mins = math.floor(t_r / 60)
 t_r = t_r - (mins * 60)
 secs = t_r
 hrsf = str(hrs).zfill(2)
 minsf = str(mins).zfill(2)
 secsf = str(secs).zfill(2)
 t_fnl = hrsf + ':' + minsf + ':' + secsf
 return t_fnl

def go_main():
 tf = TF()
 vid_n = 0
 arglen = len(sys.argv)
 if arglen == 2:
 with open(sys.argv[1], 'r') as f_in:
 lines = f_in.readlines()
 start = None
 end = None
 cnt = 0
 for line in lines:
 if line[:5] == 'BEGIN':
 start = cnt
 if line[:3] == 'END':
 end = cnt
 cnt += 1
 if start == None or end == None:
 print('Invalid file format. start = {}, end = {}'.format(start,end))
 return
 else:
 lines_r = lines[start+1:end]
 del lines
 print('videos to process: {}'.format(len(lines_r)))
 f_out_prefix = ""
 for vid in lines_r:
 vid_n += 1
 print('\nProcessing video {}/{}'.format(vid_n, len(lines_r)))
 f_out_prefix = 'v' + str(vid_n) + '-'
 dat = vid.split('!')[1:3]
 title = dat[0]
 dat_t = dat[1].split(',')
 v_pieces = len(dat_t)
 piece_n = 0
 video_pieces = []
 cmd1 = "echo -n \"\" > tmpfile"
 subprocess.run(cmd1, shell=True) 
 print(' new tmpfile created')
 for v_times in dat_t:
 piece_n += 1
 f_out = f_out_prefix + str(piece_n) + '.mp4'
 video_pieces.append(f_out)
 print(' piece filename {} added to video_pieces list'.format(f_out))
 v_times_spl = v_times.split('-')
 v_times_start = v_times_spl[0]
 v_times_end = v_times_spl[1]
 t_st = tf.toLong(v_times_start)
 t_dur = tf.toTime(tf.toSeconds(v_times_end) - tf.toSeconds(v_times_start))
 cmd3 = ["ffmpeg", "-i", title, "-ss", t_st, "-t", t_dur, f_out, "-loglevel", "error", "-stats"]
 print(' cutting out piece {}/{} - {}'.format(piece_n, len(dat_t), t_dur))
 subprocess.run(cmd3)
 for video_piece_name in video_pieces:
 cmd4 = "echo \"file " + video_piece_name + "\" >> tmpfile"
 subprocess.run(cmd4, shell=True)
 print(' filename {} added to tmpfile'.format(video_piece_name))
 vname = f_out_prefix[:-1] + ".mp4"
 print(' name of joined file: {}'.format(vname))
 cmd5 = "ffmpeg -f concat -safe 0 -i tmpfile -c copy joined.mp4 -loglevel error -stats"
 to_be_joined = " ".join(video_pieces)
 print(' joining...')
 join_cmd = subprocess.Popen(cmd5, shell=True)
 join_cmd.wait()
 print(' joined!')
 cmd6 = "mv joined.mp4 " + vname
 rename_cmd = subprocess.Popen(cmd6, shell=True)
 rename_cmd.wait()
 print(' File joined.mp4 renamed to {}'.format(vname))
 cmd7 = "rm " + to_be_joined
 rm_cmd = subprocess.Popen(cmd7, shell=True)
 rm_cmd.wait()
 print('rm command completed - pieces removed')
 cmd8 = "rm tmpfile"
 subprocess.run(cmd8, shell=True)
 print('tmpfile removed')
 print('All done')
 else:
 print('Incorrect number of arguments')

############################
if __name__ == '__main__':
 go_main()



process_videos.py is called from bash terminal like this :


$ python process_videos.py video_data 



video_data file has the following format :


BEGIN
!first_video.mp4!3-23,55-1:34,2:01-3:15,3:34-3:44!
!second_video.mp4!2-7,12-44,1:03-1:33!
END



My system details :


System: Host: snowflake Kernel: 5.4.0-52-generic x86_64 bits: 64 Desktop: Gnome 3.28.4
 Distro: Ubuntu 18.04.5 LTS
Machine: Device: desktop System: Gigabyte product: N/A serial: N/A
Mobo: Gigabyte model: Z77-D3H v: x.x serial: N/A BIOS: American Megatrends v: F14 date: 05/31/2012
CPU: Quad core Intel Core i5-3570 (-MCP-) cache: 6144 KB 
 clock speeds: max: 3800 MHz 1: 1601 MHz 2: 1601 MHz 3: 1601 MHz 4: 1602 MHz
Drives: HDD Total Size: 1060.2GB (55.2% used)
 ID-1: /dev/sda model: ST31000524AS size: 1000.2GB
 ID-2: /dev/sdb model: Corsair_Force_GT size: 60.0GB
Partition: ID-1: / size: 366G used: 282G (82%) fs: ext4 dev: /dev/sda1
 ID-2: swap-1 size: 0.70GB used: 0.00GB (0%) fs: swap dev: /dev/sda5
Info: Processes: 313 Uptime: 16:37 Memory: 3421.4/15906.9MB Client: Shell (bash) inxi: 2.3.56