Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Optimizing preprocessing of data
12 mai 2018, par WhatAMeshI have to preprocess 1-2,5 Terabytes of 1920x1080 videos (in .mp4 format) and try to find the fastest way to do so.
For every video I have to:
- Sample at 1 fps
- Crop two images out of every frame
- Save the two frames (output format needs to be uncompressed)
Im currently doing it the following way using ffmpeg:
def cropVideo(vidInPath, vidOutPath): crop = 'ffmpeg -i ' + vidInPath + ' -filter_complex "[0:v]crop=400:200:0:484[face];[0:v]crop=300:50:1624:300[number]" -map [face] -map 0:a ' + vidOutPath + '/face/face.mp4 -map [number] -map 0:a ' + vidOutPath + '/number/number.mp4' subprocess.call(crop) return def videoToImageSequence(vidInPath, vidOutPath): conv = 'ffmpeg -i ' + vidInPath + ' -vf fps=1 ' + vidOutPath + 'video-frame%05d.png' subprocess.call(conv) return cropVideo(dirPath + a + '.mp4', dirPath + a + '/') videoToImageSequence(dirPath + a + '/face/face.mp4', dirPath + a + '/face/') videoToImageSequence(dirPath + a + '/number/number.mp4', dirPath + a + '/number/')
Is there a faster way to do this?
-
how to appending write audio frame use ffmpeg ?
12 mai 2018, par fredirty2017- I found that ffmpeg has a concat protocol that can be used to splice/merge multiple audio files, but it has a param ouput file, that is, a new production to a target file; But I want to have a pattern added to the source file, just like the behavior of the fopen when mode = "a": Appends to a file. Writing operations. End of the file.
Is there a direct way to do this?
FILE *fopen (const char *filename, const char *mode)
-
Concatenating a video between a video in ffmpeg
12 mai 2018, par alan samuelI have a function which takes a video with parameters to cut the video between two time points and add in an existing video to it.
At the moment, I am using FFMPEG to
1) Convert the video to ts 2) Cut it into two 3) Concatenate the other video
But after I concatenate and play it on VLC it crashes, but on windows media player it plays but the audio is out of sync.
Here is what I am doing.
ffmpeg -i OriginalVideo.mp4 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=48000 -shortest -c copy -bsf:v h264_mp4toannexb -c:a aac -t 00:00:10 firstpart.ts ffmpeg -i OriginalVideo.mp4 -f lavfi -i anullsrc=channel_layout=mono:sample_rate=48000 -shortest -c copy -bsf:v h264_mp4toannexb -c:a aac -ss 00:00:15 secondpart.ts
So the first command would convert the video until the 10th second and the second command would convert the video from the 15th second.
And then I concatenate the videos like this
ffmpeg -f concat -safe 0 -i list.txt -c copy -bsf:a aac_adtstoasc finaloutput.mp4
list.txt contains
file 'firstpart.ts' file 'tojoin.ts' file 'secondpart.ts'
tojoin.ts is a video with a length of 4 seconds. But after its finished concatenating the length in the final output is about 10 seconds.
Any idea how to fix this ?
-
auto resize video resolution with ffmpeg
12 mai 2018, par Masoud MohammadiI wrote a bash script to convert all video file in a directory. some video resolution is
1280x720
and other720x1280
. how to write a command, if video resolution is1280x720
convert to640x360
and video resolution is720x1280
resize to360x640
? -
Build osg with ffmeg plugin
11 mai 2018, par JayKI'm trying to build OpenSceneGraph (OSG) with the FFMPEG plugin. Using:
- CentOS 7.2 64-bit
- GCC 4.8.5
- OSG 3.4.0
- FFMPEG 2.8
With FFMPEG, I
./configure
with no options,make
andmake install
. In OSG, Icmake .
, andmake
. I get this:Linking CXX shared module ../../../lib/osgPlugins-3.4.0/osgdb_ffmpeg.so /usr/bin/ld: /usr/local/lib/libavformat.a(allformats.o): relocation R_X86_64_32 against symbol `ff_a64_muxer' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/local/lib/libavformat.a(amr.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC ...(and a ton of others like this)
So I go back to FFMPEG and
./configure --enable-pic
. From --help:--enable-pic build position-independent code
make clean
,make
, andmake install
.I then go to OSG and
make
and get far fewer, but still get one:Linking CXX shared module ../../../lib/osgPlugins-3.4.0/osgdb_ffmpeg.so /usr/bin/ld: /usr/local/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status
I did some research on how to tell if an object is built with PIC and found:
terminal-> readelf --relocs ./libavcodec/x86/vc1dsp_mmx.o | egrep '(GOT|PLT|JU?MP_SLOT)' 000000000ea6 007300000004 R_X86_64_PLT32 0000000000000000 ff_avg_pixels16_mmx - 4 000000000eb6 007400000004 R_X86_64_PLT32 0000000000000000 ff_avg_pixels8_mmx - 4 000000000ec6 007500000004 R_X86_64_PLT32 0000000000000000 ff_put_pixels16_mmx - 4 000000000ed6 007600000004 R_X86_64_PLT32 0000000000000000 ff_put_pixels8_mmx - 4
When I build without --enable-pic, the previous command returns nothing.
For libavcodec.a, I did
nm
on it to look for this symbolff_pw_9
, and found these references:constants.o: ... 00000000000002d0 R ff_pw_9 ... vc1dsp_mmx.o: ... U ff_pw_9 ... vp8dsp_loopfilter.o: ... U ff_pw_9 ...
What am I missing here?