Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
using FFMPEG with silencedetect to remove audio silence [closed]
15 avril, par ZahliiI am trying to use the following command with the latest ffmpeg build to remove silence from my .mp3 files:
ffmpeg -i SILENCE.mp3 -af silencedetect=n=-50dB:d=1 -y -ab 192k SILENCE_OUT.mp3
However, the following output is produced:
ffmpeg version N-66154-g1654ca7 Copyright (c) 2000-2014 the FFmpeg developers built on Sep 5 2014 22:10:38 with gcc 4.8.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca -- enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable- libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.100 / 56. 4.100 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 Input #0, mp3, from 'SILENCE.mp3': Metadata: title : Snowblind (Featuring Tasha Baxter) artist : Au5 album : Snowblind (Featuring Tasha Baxter) genre : Electronica performer : Au5 track : 1/1 date : 2014 album_artist : Au5,Tasha Baxter major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf55.42.100 Duration: 00:05:50.80, start: 0.025057, bitrate: 192 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s Output #0, mp3, to 'SILENCE_OUT.mp3': Metadata: TIT2 : Snowblind (Featuring Tasha Baxter) TPE1 : Au5 TALB : Snowblind (Featuring Tasha Baxter) TCON : Electronica TPE3 : Au5 TRCK : 1/1 TDRL : 2014 TPE2 : Au5,Tasha Baxter major_brand : mp42 minor_version : 0 compatible_brands: isommp42 TSSE : Lavf56.4.100 Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 192 kb/s Metadata: encoder : Lavc56.1.100 libmp3lame Stream mapping: Stream #0:0 -> #0:0 (mp3 (native) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help [silencedetect @ 0000000004398f40] silence_start: -0.00628118 [silencedetect @ 0000000004398f40] silence_end: 3.21413 | silence_duration: 3.22 041 [silencedetect @ 0000000004398f40] silence_start: 343.844 [libmp3lame @ 00000000043b2940] Trying to remove 1152 samples, but the queue is empty size= 8223kB time=00:05:50.79 bitrate= 192.0kbits/s video:0kB audio:8222kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011485%
The generated audio file however still has the original length without any silence removed. See the following images:
Any help is appreciated!
EDIT: Alright, silence detect is only DETECTING the silence. Not removing it. I will try to post a solution for this.
-
FFMEG option scale=-1 and scale=-2
15 avril, par smalI tried to convert a video and resize it with scale=-1:720, but got the error "width not divisible by 2". And I solved it with: scale=-2:720. What are the differences between
scale=-1:720
and
scale=-2:720
-
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 "%%~ni-FINAL.mkv" "',join(file:list(.,false(),'%%~ni-*.mp4'),'" + "'),'"')"') DO %%A )
-
Passing two named pipes as input to ffmpeg using python
13 avril, par KiktoI have two av streams, one video and one audio, i'm trying to pipe both as inputs to ffmpeg
os.mkfifo(VIDEO_PIPE_NAME) os.mkfifo(AUDIO_PIPE_NAME) ffmpeg_process = subprocess.Popen([ "ffmpeg", "-i", VIDEO_PIPE_NAME, "-i", AUDIO_PIPE_NAME, "-listen", "1", "-c:v", "copy", "-c:a", "copy", "-f", "mp4", "-movflags", "frag_keyframe+empty_moov", "http://0.0.0.0:8081"], stdin=subprocess.PIPE) pipe_video = open(VIDEO_PIPE_NAME,'wb') pipe_audio = open(AUDIO_PIPE_NAME,'wb') #Code stuck here
The code stuck on
pipe_audio = open(AUDIO_PIPE_NAME,'wb')
line, I'm guessing it is happening because ffmpeg only reads the first/video input and ignore the second/audio input so the pipe is not being read.If I use only
pipe_video
and removing-i AUDIO_PIPE_NAME
flag from ffmpeg everything works fine, but i only get the video without the audio. -
ffmpeg using zoompan and depan over a static image and a specific background [closed]
13 avril, par marcoroccoI would like use ffmpeg zoompan on a photo with this conditional
duration should be about 8 seconds
image should be scaled to avoid jiggly artifacts
should be freezze for some seconds, and depan
I already have my background: reference image is portrait
I would like use a sort of "pad" during transition
video out should be 1920x1080 16:9
zoompan on the center
How I can do? thanks