In manual it says:
ffmpeg -i input.mkv -filter:v 'setpts=0.5*PTS' output.mkv
But when I run:
ffmpeg -i input.mp4 -filter:v 'setpts=0.5*PTS' speedup.mp4
I get an error:
[AVFilterGraph # 0000000002500600] No such filter: 'setpts=0.5*PTS'
Error opening filters!
Not sure if it means that filter can't be opened at all or simply this filter is not available.
How do I run it correctly? Or maybe my release does not support it, then where can I get the release that would work right? Win32/x64 binary
Use both setpts and atempo to speed up both video and audio:
ffmpeg -i input-video.mp4 -vf "setpts=0.68*PTS" -filter:a "atempo=1.467" output-video.mp4
From: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
You'll have to do the right math for the numbers, of course. The setpts needs to be smaller to make the video go faster, but atempo needs to be larger to speed up the audio.
Audio value needed = 1 / Video value
if you have your ffmpeg.exe (mine for windows) for ex you can list all the available filters with this command line, you can edit the txt file c:\filters.txt to see them.
ffmpeg -filters > c:\yfilters.txt
in mine i can se the filter SETPS (VIDEO TO VIDEO only):
setpts V->V Set PTS for the output video frame.
your command line is correct and work with the ffmpeg version that have this filter(try to download the latest version)
this command line works also for me :
ffmpeg -i video_input -vf "setpts=factor*PTS" video_output
the factor can be :
1.for speeding the video 0.2,0.4,0.6,0.8..(<1)
2.for slowing the video:1.2,1.4,1.6,1.8,2.0,3.0,4.0,5.0,10.0... (>1)
Try using double quotes. e.g. ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" speedup.mp4
Related
This question is similar to Remove all non key frames from video without re-encoding but this one is specific to H.264 (AVC), not H.265 (HEVC). Also, the accepted answer to that question results in an unplayable 1k file for me.
My command line currently looks like this:
ffmpeg.exe -skip_frame nokey -i input.mp4 -vf "select='eq(pict_type,PICT_TYPE_I)'" -vsync vfr output.mp4
input.mp4 is 30fps and after I run the command line above, output.mp4 is 2fps as expected, but it's composed of not just I-frames (keyframes) but also P-frames and B-frames. Because that command is CPU-intensive, it appears to be re-encoding, and I want NO re-encoding.
Also it removes the exif information and I would like to preserve it in the file. I just want to remove the non-keyframes and keep everything else.
With ffmpeg 5.0 or later, and assuming your input container marks video keyframes (MP4, MKV do), use
ffmpeg -i input.mp4 -c copy -bsf:v noise=drop=not(key) output.mp4
If I want to change the video speed with ffmpeg,
what exactly is the difference changing the fps:
ffmpeg -y -r 10 -i video.mp4 video_new_fps.mp4
or using filter and setpts:
ffmpeg -i video.mp4 -filter:v "setpts=PTS*3" -an video_new_fps.mp4
It seems that with both options I can speed up or slow down the video.
So which one should be used in which case?
IMO, the latter is a universal safer approach. If the input video stream uses a constant framerate, then both should result in the identical output. If the input framerate is variable, -r input option will mess up the timing, I presume.
i try to concat multiple videos to one video and add an background music to it.
for some reason the background music is perfectly added to the output video but the audio of each part of the output is speed up to a chipmunk version of the video itself. this results in an output video of 7 minutes with about 5 minutes of silence since everything is so fast that all the audio finishes after about 2 minutes.
my command is:
ffmpeg -safe 0 -i videolist.ffconcat -i bg_loop.mp3 -y -filter_complex "[1:0]volume=0.3[a1];[0:a][a1]amix=inputs=2" -vcodec libx264 -r 25 -filter:v scale=w=1920:h=1080 -map 0:v:0 output.mp4
i tried to remove the background music (since i wasn't able to loop it through the video i thought maybe that's the issue) and still.. all the audio of the video clips is still speed up resulting in chaotic audio at the beginning and silence at the end.
my video list looks like this:
ffconcat version 1.0
file intro.mp4
file clip-x.mp4
file clip-y.mp4
file clip-x.mp4
file clip-y.mp4
[... and so on]
i hope somebody can tell me what i'm doing wrong here (and maybe how to adjust my command to loop the background music through all the clips)
i googled a bit and found the adjustment of my command to add amix=inputs=2:duration=first but that doesn't do the trick and if i add duration=shortest or duration=longest nothing changes the output audio
The concat demuxer requires that all streams in inputs have the same properties. For audio, that includes codec, sampling rate, channel layout, sample format..
If audio of some inputs is sounding funny after concat, that usually indicates a sampling rate mismatch. Run ffprobe -show_streams -select_streams a -v 0 "input-file" on each input to check. For those which are different, you can re-encode only the audio by adding -ar X where X is the most common sampling rate found among your inputs e.g. -ar 44100. Other parameters will depend on format details. Keep video by using -c:v copy.
I'm using the highpass audio filter then trying to use showfreqs on the resulting audio stream but it's not working. The showfreqs filter uses the original audio stream instead of the filtered one.
Command:
ffmpeg -i audio.mp3 -filter_complex highpass,showfreqs,format=yuv420p highpass.mp4
I tried naming the highpass output but it didn't make any difference:
ffmpeg -i audio.mp3 -filter_complex highpass[hi],[hi]showfreqs,format=yuv420p highpass.mp4
How do I structure my command so showfreqs uses the output from highpass?
UPDATE
I'm using FFMPEG 4.1.4 installed on Mac via Homebrew.
Source audio: https://dsc.cloud/weavermedia/audio.mp3
Commands and resulting files:
Run highpass on audio.mp3:
ffmpeg -i audio.mp3 -filter_complex highpass highpass.mp3
result: https://dsc.cloud/weavermedia/highpass.mp3 CORRECT
Run showfreqs on audio.mp3:
ffmpeg -i audio.mp3 -filter_complex showfreqs,format=yuv420p showfreqs.mp4
result: https://dsc.cloud/weavermedia/showfreqs.mp4 CORRECT
Run showfreqs on highpass.mp3:
ffmpeg -i highpass.mp3 -filter_complex showfreqs,format=yuv420p showfreqs.mp4
result: https://dsc.cloud/weavermedia/highpass-showfreqs.mp4 CORRECT
Run highpass and showfreqs in series on audio.mp3:
ffmpeg -i audio.mp3 -filter_complex highpass,showfreqs,format=yuv420p highpass.mp4
result: https://dsc.cloud/weavermedia/highpass.mp4 INCORRECT
I tried several different source audio files and always get the same results.
I tried on 2 different Macs, albeit both with FFMPEG 4.1.4 installed via Homebrew.
I tried with different highpass settings and get same results (the default highpass settings are enough to hear the difference anyway).
UPDATE 2
Looking at the resulting videos side by side in QuickTime I see that showfreqs does actually appear to be using the audio stream from highpass but the final video contains the original unfiltered audio.
So my problem is actually how to get the resulting video to use the filtered audio stream instead of the original.
showfreqs converts its audio input to a video output, so ffmpeg will fallback on the original audio for audio output. In order to avoid this, split the highpass result and pass one copy to showfreqs while leaving the other for audio output.
ffmpeg -i audio.mp3 -filter_complex highpass,asplit=2[sf][aud];[sf]showfreqs,format=yuv420p;[aud]anull highpass.mp4
I have vps server and i setup ffmpeg successfully. I downloaded 720p hd video. I need only add text on video. And i added successfuly but video quality is very low after adding. I use this command
ffmpeg -i a.mp4 -vf "drawtext=fontsize=30:box=1:fontfile=/usr/share/fonts/a.ttf:text='Stack Overflow':x=(w-text_w)/2:y=(h-text_h-line_h)/2" -strict -2 c.mp4
I dont know -strict -2 command. i try and ffmpeg error say add -strict -2 then i add. Now i need only add text, not change video quality.
You haven't specified any bitrate. So it is going to go for default bitrate of 200kbps which will give you bad output if your size is 720p like you claim. Please specify the bitrate to a reasonable value.
Define Bitrate..
For example
ffmpeg -i input.mp4 -filter_complex "drawtext=fontsize=27:text=\'hellow\':x=(10):y=(main_h-30):fontcolor=white" -b:v 3M output.mp4