
Recherche avancée
Autres articles (65)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
Librairies et binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...)
Sur d’autres sites (7232)
-
Is there a way to batch split a file by chapter with ffmpeg and then reassemble with mkvmerge in windows ?
13 avril, par SipherdrakonSo I made a batch script originally with the ability to relatively precision trim a video into chapters without having to run by keyframes, but the code looks horrible and I can't get it to loop through all mp4 files nor get mkvmerge to append the files after splitting them. Code is below but be gentle it is my first try.


@echo off
setlocal enableDelayedExpansion

REM CODE BELOW CREATES JSON FILES FOR ALL MP4 FILES WITHIN THE SAME DIRECTORY
ffprobe -v quiet -print_format json -show_chapters -loglevel error "01x01.mp4" > "01x01.json"

REM CODE BELOW SETS VARIABLES FROM EACH SPECIFIC JSON
FOR /F "delims=" %%i in ('jq .chapters[2].start ^< 01x01.json') DO SET /A start1=%%i
FOR /F "delims=" %%j in ('jq .chapters[2].end ^< 01x01.json') DO SET /A end1=%%j

FOR /F "delims=" %%k in ('jq .chapters[4].start ^< 01x01.json') DO SET /A start2=%%k
FOR /F "delims=" %%l in ('jq .chapters[4].end ^< 01x01.json') DO SET /A end2=%%l

FOR /F "delims=" %%m in ('jq .chapters[6].start ^< 01x01.json') DO SET /A start3=%%m
FOR /F "delims=" %%n in ('jq .chapters[6].end ^< 01x01.json') DO SET /A end3=%%n

FOR /F "delims=" %%o in ('jq .chapters[8].start ^< 01x01.json') DO SET /A start4=%%o
FOR /F "delims=" %%p in ('jq .chapters[8].end ^< 01x01.json') DO SET /A end4=%%p

REM SETS THE DURATION OF EACH FILE TO USE PRECISION TIMING FOR START AND STOP TIMES
CALL vbs (%end1%-%start1%)/1000
SET duration1=%val%
CALL vbs (%end2%-%start2%)/1000
SET duration2=%val%
CALL vbs (%end3%-%start3%)/1000
SET duration3=%val%
CALL vbs (%end4%-%start4%)/1000
SET duration4=%val%

REM SETS THE START TIME IN SECONDS VS MILLISECONDS
CALL vbs (%start1%)/1000
SET start1=%val%
CALL vbs (%start2%)/1000
SET start2=%val%
CALL vbs (%start3%)/1000
SET start3=%val%
CALL vbs (%start4%)/1000
SET start4=%val%

REM TRIM AND SPLIT ORIGINAL FILE INTO SEPERATE SECTIONS BASED ON CHAPTER MARKERS
ffmpeg -ss %START1% -i 01x01.mp4 -ss 0 -c copy -to %DURATION1% -avoid_negative_ts make_zero 01x01-1.mp4
ffmpeg -ss %START2% -i 01x01.mp4 -ss 0 -c copy -to %DURATION2% -avoid_negative_ts make_zero 01x01-2.mp4
ffmpeg -ss %START3% -i 01x01.mp4 -ss 0 -c copy -to %DURATION3% -avoid_negative_ts make_zero 01x01-3.mp4
ffmpeg -ss %START4% -i 01x01.mp4 -ss 0 -c copy -to %DURATION4% -avoid_negative_ts make_zero 01x01-4.mp4

REM DELETES UNNEEDED JSON AFTER USE
del /s *.json

REM APPEND ALL MP4 FILES INTO COHESIVE MKV
for /d /r %%D in (*) do (
 pushd %%D
 set files=
 for %%F in (*.mp4) do set files=!files! + ^( "%%F" ^)
 if not "!files!"=="" %mkvmerge% -o "01x01-FINAL.mkv" !files:~2!
 popd
)

REM DELETE UNNEEDED MP4 ORIGINALS AND SPLIT FILES
del /s *.mp4



I know it is super long and every time I try to use a variable or a loop to run through all files it can't read the json file. I've been at this all day and I can use the script as is but I have to make a file for each iteration.


I was also hoping to be able to have it only pull chapters labeled as "video" but I haven't quite figured that one out yet.


I'll add the vbs batch file for the arithmetic section as well as the sample json if it will help.


@echo off
>"%temp%\VBS.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject") : Wscript.echo (%*)
for /f "delims=" %%a in ('cscript /nologo "%temp%\VBS.vbs"') do set "val=%%a"
del "%temp%\VBS.vbs"



{
 "chapters": [
 {
 "id": 0,
 "time_base": "1/1000",
 "start": 0,
 "start_time": "0.000000",
 "end": 5590,
 "end_time": "5.590000",
 "tags": {
 "title": "Video"
 }
 },
 {
 "id": 1,
 "time_base": "1/1000",
 "start": 5590,
 "start_time": "5.590000",
 "end": 13994,
 "end_time": "13.994000",
 "tags": {
 "title": "Advertisement"
 }
 },
 {
 "id": 2,
 "time_base": "1/1000",
 "start": 13994,
 "start_time": "13.994000",
 "end": 163964,
 "end_time": "163.964000",
 "tags": {
 "title": "Video"
 }
 },
 {
 "id": 3,
 "time_base": "1/1000",
 "start": 163964,
 "start_time": "163.964000",
 "end": 195940,
 "end_time": "195.940000",
 "tags": {
 "title": "Advertisement"
 }
 },
 {
 "id": 4,
 "time_base": "1/1000",
 "start": 195940,
 "start_time": "195.940000",
 "end": 547849,
 "end_time": "547.849000",
 "tags": {
 "title": "Video"
 }
 },
 {
 "id": 5,
 "time_base": "1/1000",
 "start": 547849,
 "start_time": "547.849000",
 "end": 595850,
 "end_time": "595.850000",
 "tags": {
 "title": "Advertisement"
 }
 },
 {
 "id": 6,
 "time_base": "1/1000",
 "start": 595850,
 "start_time": "595.850000",
 "end": 1413588,
 "end_time": "1413.588000",
 "tags": {
 "title": "Video"
 }
 },
 {
 "id": 7,
 "time_base": "1/1000",
 "start": 1413588,
 "start_time": "1413.588000",
 "end": 1477569,
 "end_time": "1477.569000",
 "tags": {
 "title": "Advertisement"
 }
 },
 {
 "id": 8,
 "time_base": "1/1000",
 "start": 1477569,
 "start_time": "1477.569000",
 "end": 1529696,
 "end_time": "1529.696000",
 "tags": {
 "title": "Video"
 }
 }
 ]
}



I also tried using the start_time so I didn't have to do extra calculations but jq didn't like that either.


mkvmerge doesn't even try to run when I have it in here and I still need to cut 7 seconds off the end and 12 seconds off the front of it once it is all one file again.


Any help would be appreciated, I know it's a lot but I seem to have hit a roadblock or just sleep deprived at this point.


UPDATE


This works amazing I just need to figure out how to use files with spaces and I'm all set. I guess I could run a batch before hand replacing all spaces with underscores. That would probably work but I would like to not change filenames if I can help it.


@echo off

for %%i in (*.mp4) do (
FOR /F "delims=" %%A IN ('ffprobe -v quiet -print_format json -show_chapters -loglevel error "%%i" ^| xidel - -se "$json/(chapters)()[id!=0 and tags/title='Video']/concat('ffmpeg -ss ',start div 1000,' -i %%i -to ',((end - start) div 1000),' -c copy -avoid_negative_ts make_zero %%~ni-',position(),'.mp4')"') DO %%A
FOR /F "delims=" %%A IN ('xidel -s --xquery "concat('mkvmerge -o &quot;%%~ni-FINAL.mkv&quot; &quot;',join(file:list(.,false(),'%%~ni-*.mp4'),'&quot; + &quot;'),'&quot;')"') DO %%A
)



-
ffmpeg tpad adding delay to start and stop of film
10 octobre 2020, par Devin DixonIn ffmpeg there is the
-filter_complex "tpad=stop_duration=20"
that adds 20 seconds to back of video/stream, or-filter_complex "tpad=start_duration=20"
which adds it to the front.

How can I add it to both ? Something like
ffmpeg -re -i {$file} -filter_complex "tpad=stop_duration=20&start_duration=20"
duration does not work, and there is no documentation I can find on using both filters in one command.

-
How can I capture simple video input with audio from a capture device
17 décembre 2020, par Geoff SweetI'm using ffmpeg on Arch linux and trying to convert some old video to digital. The setup is pretty straightforward and if I connect to the capture device with VLC I get the video and audio just fine. So now I want to capture that with ffmpeg and write it to a file so I can edit it and clean it up. I'm only so-so familiar with ffmpeg and I've been digging through the man pages and here is where I am at.


This command captures perfect audio, but no video :


ffmpeg -f alsa -ac 2 -i front:CARD=Capture,DEV=0 out.mpeg



This command captures perfect video ;


ffmpeg -f video4linux2 -i /dev/video0 out.mpeg



captures the video signal great, but with no audio. So combining them together should give me :


ffmpeg -y -f alsa -ac 2 -i front:CARD=Capture,DEV=0 -f video4linux2 -i /dev/video0 out.mpeg



But that command kinda falls on it's face. I get the audio, but no video :


ffmpeg -y -f alsa -ac 2 -i front:CARD=Capture,DEV=0 -f video4linux2 -i /dev/video0 out.mpeg
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
 built with gcc 10.2.0 (GCC)
 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-shared --enable-version3
 libavutil 56. 51.100 / 56. 51.100
 libavcodec 58. 91.100 / 58. 91.100
 libavformat 58. 45.100 / 58. 45.100
 libavdevice 58. 10.100 / 58. 10.100
 libavfilter 7. 85.100 / 7. 85.100
 libswscale 5. 7.100 / 5. 7.100
 libswresample 3. 7.100 / 3. 7.100
 libpostproc 55. 7.100 / 55. 7.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'front:CARD=Capture,DEV=0':
 Duration: N/A, start: 1608093176.894565, bitrate: 1536 kb/s
 Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2,v4l2 @ 0x56248fe0ab80] Dequeued v4l2 buffer contains corrupted data (0 bytes).
Input #1, video4linux2,v4l2, from '/dev/video0':
 Duration: N/A, start: 0.000000, bitrate: 995328 kb/s
 Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080, 995328 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
 Stream #1:0 -> #0:0 (rawvideo (native) -> mpeg1video (native))
 Stream #0:0 -> #0:1 (pcm_s16le (native) -> mp2 (native))
Press [q] to stop, [?] for help
[video4linux2,v4l2 @ 0x56248fe0ab80] Dequeued v4l2 buffer contains corrupted data (0 bytes).
 Last message repeated 30 times
[alsa @ 0x56248fdb3840] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[mpeg @ 0x56248fe0dfc0] VBV buffer size not set, using default size of 230KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'out.mpeg':
 Metadata:
 encoder : Lavf58.45.100
 Stream #0:0: Video: mpeg1video, yuv420p(progressive), 1920x1080, q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc
 Metadata:
 encoder : Lavc58.91.100 mpeg1video
 Side data:
 cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
 Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
 Metadata:
 encoder : Lavc58.91.100 mp2
frame= 2 fps=0.0 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=2.0 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=1.3 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=1.0 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.8 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.7 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.6 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.5 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.4 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.4 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.4 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.3 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.3 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.3 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.3 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.2 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/sframe= 2 fps=0.1 q=3.2 size= 0kB time=01:48:49.26 bitrate= 0.0kbits/s[video4linux2,v4l2 @ 0x56248fe0ab80] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=0 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=2020 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=4061 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=6102 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=8143 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=10184 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=12225 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=14266 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=16307 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=18348 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=20389 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=22430 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=24471 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=26512 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=28553 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=30594 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=32635 size=36451
[mpeg @ 0x56248fe0dfc0] buffer underflow st=0 bufi=34676 size=36451
frame= 2 fps=0.1 q=2.0 Lsize= 1470kB time=01:48:49.30 bitrate= 1.8kbits/s speed= 221x 
video:63kB audio:1388kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.314351%
Exiting normally, received signal 2.



what I would ideally like is just a fairly raw 2ch stereo "dump" of what comes through the capture card.


As always, I super appreciate any advice