Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
byte-accurate ffmpeg segments
12 février 2016, par HousemanIs there any way to use ffmpeg to accurately break audio files into smaller files of a specific file size, or pull a specific number of samples from a file?
I'm working with a speech-to-text API that needs audio chunks in exactly 160,000 bytes, or 80,000 16-bit samples.
I have a video stream, and I have an ffmpeg command to extract audio from it:
ffmpeg -i "rtmp://MyFMSWorkspace/ingest/test/mp4:test_1000 live=1" -ar 16000 -f segment -segment_time 10 out%04d.wav
So now I have ~10 second audio chunks with a sample rate of 16 kHz. Is there any way to break this into exactly 160kb, 5 second files using ffmpeg?
I tried this:
ffmpeg -t 00:00:05.00 -i out0000.wav outCropped.wav
But the output was this:
Input #0, wav, from 'out0000.wav': Metadata: encoder : Lavf56.40.101 Duration: 00:00:10.00, bitrate: 256 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, 1 channels, s16, 256 kb/s Output #0, wav, to 'outCropped.wav': Metadata: ISFT : Lavf56.40.101 Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s Metadata: encoder : Lavc56.60.100 pcm_s16le Stream mapping: Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help size= 156kB time=00:00:05.00 bitrate= 256.1kbits/s
but now the size is 156kb
-
How to get accurate time information from ffmpeg audio outputs ?
11 février 2016, par user2192778I want to figure out the best way to have accurate (down to millisecond) time information encoded into a web stream audio recording. So, if I wanted to know what was streaming at exactly 07:57:25 yesterday, I could retrieve that information using my program code. How can I do this in my ffmpeg function?
So far I have a python script that calls the following ffmpeg function every hour:
ffmpeg -i http://webstreamurl.mp3 -t 01:30:00 outputname.mp3
It will record 1.5 hours of my stream every hour. This leaves me with many 1.5 hour-long clips which together (due to some overlap) will give me audio at every moment.
I don't know how I will sync these clips with their stream times, however. Is there a way to put timestamps in the audio and have python read it? Or is there a way to name these output files such that python could calculate the times itself? Any other way?
-
c++ get supported camera resolutions and frame rate OSX
11 février 2016, par SolidusI am using ffmpeg to record a video from a connected camera. I would like to be able to retrieve the supported camera resolution and framerate. Unfortunately this is currently not supported in ffmpeg on OSX. Are there other solutions out there? I've searched google and stackoverflow but the best I could find was a solution for windows using dshow.
I imagine this is possible with avfoundation but I don't have any experience with it. I am also using qt (not quicktime, the qt framework) so it would have to be compatible with that. :)
Thank you for your time.
-
Unrecognized options even though compiled FFmpeg on Ubuntu manually
11 février 2016, par Kathy LeeI would like to convert a video from .avi to .mp4 with same quality using ffmpeg but the command I put in the terminal always report some errors saying that there are unrecognized options.
I have compiled the ffmpeg manually following the steps in http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
After compiling the ffmpeg, I used the command below the compress the video
ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfaac -b:a 192k -ac 2 output.mp4
But the error message is saying "Unrecognized option 'crf'":
ffmpeg version 2.8.5 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04) configuration: --enable-nonfree --enable-pic --enable-shared libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 Unrecognized option 'crf'. Error splitting the argument list: Option not found
Then I tried to omit flag -crf, but I got error saying
Unrecognized option 'preset'. Error splitting the argument list: Option not found
Then I omitted flag -preset, it says I do not have libx264....
[mjpeg @ 0x164f2c0] Changeing bps to 8 Input #0, avi, from 'backup_bush.avi': Duration: 00:01:40.70, start: 0.000000, bitrate: 12409 kb/s Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 400x250 [SAR 1:1 DAR 8:5], 12407 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc Unknown encoder 'libx264'
I am very confused what is going on because I have complied ffmpeg step by step and also installed the dependencies such as libx264 as described in http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu. The command I used to configure ffmpeg is
./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
Why these errors happen? How can I fix them to allow me to convert the video from .avi to .mp4?
Thank you very much!
-
Python matplotlib.animation [Errno 13] Permission denied
11 février 2016, par FishmanI am trying to create a simple animated histogram and save it as a .mp4 using matplotlib and ffmpeg on a mac. I have already installed ffMpeg, specified the ffmpeg path, and now I am getting a permission denied error when writing to a folder in my desktop. I tried running as sudo and still get the same error. Help is much appreciated, thank you!
Here is the code:
df = pd.read_csv('.../data.csv') df = df.dropna() #Get list of weeks weeks = df.ot_date.unique() fig, ax = plt.subplots() data = df.intervals_filled[df['ot_date'].isin([weeks[0]])] n, bins = np.histogram( data , 20) # get the corners of the rectangles for the histogram left = np.array(bins[:-1]) right = np.array(bins[1:]) bottom = np.zeros(len(left)) top = bottom + n nrects = len(left) # here comes the tricky part -- we have to set up the vertex and path # codes arrays using moveto, lineto and closepoly # for each rect: 1 for the MOVETO, 3 for the LINETO, 1 for the # CLOSEPOLY; the vert for the closepoly is ignored but we still need # it to keep the codes aligned with the vertices nverts = nrects*(1 + 3 + 1) verts = np.zeros((nverts, 2)) codes = np.ones(nverts, int) * path.Path.LINETO codes[0::5] = path.Path.MOVETO codes[4::5] = path.Path.CLOSEPOLY verts[0::5, 0] = left verts[0::5, 1] = bottom verts[1::5, 0] = left verts[1::5, 1] = top verts[2::5, 0] = right verts[2::5, 1] = top verts[3::5, 0] = right verts[3::5, 1] = bottom barpath = path.Path(verts, codes) patch = patches.PathPatch( barpath, facecolor='green', edgecolor='yellow', alpha=0.5) ax.add_patch(patch) ax.set_xlim(left[0], right[-1]) ax.set_ylim(bottom.min(), top.max()+40) ax.set_xlabel('Number of intervals/week') ax.set_ylabel('Count of CSAs') plt.rcParams['animation.ffmpeg_path'] = '/usr/local/Cellar/ffmpeg' FFwriter = animation.FFMpegWriter() def animate(i): print i # simulate new data coming in data = df.intervals_filled[df['ot_date'].isin([weeks[i-1]])] n, bins = np.histogram(data, 20) yearweek = str(weeks[i-1]) year = yearweek[0:4] week = yearweek[4:] title = 'Week %(wk)s of %(yr)s' %{'wk': week, 'yr': year} ax.set_title(title) top = bottom + n verts[1::5, 1] = top verts[2::5, 1] = top return [patch, ] ani = animation.FuncAnimation(fig, animate, 53,interval=1000, repeat=False) ani.save('/Users/.../Desktop/1b.mp4', writer = FFwriter) plt.show()
And here is the traceback:
Traceback (most recent call last): File "/Users/Fishman1049/Desktop/reserves_histogram_timeline/python/1b_text.py", line 109, in
ani.save('/Users/Fishman1049/Desktop/1b', writer = FFwriter) File "/Users/Fishman1049/anaconda/lib/python2.7/site-packages/matplotlib/animation.py", line 761, in save with writer.saving(self._fig, filename, dpi): File "/Users/Fishman1049/anaconda/lib/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() File "/Users/Fishman1049/anaconda/lib/python2.7/site-packages/matplotlib/animation.py", line 186, in saving self.setup(*args) File "/Users/Fishman1049/anaconda/lib/python2.7/site-packages/matplotlib/animation.py", line 176, in setup self._run() File "/Users/Fishman1049/anaconda/lib/python2.7/site-packages/matplotlib/animation.py", line 204, in _run creationflags=subprocess_creation_flags) File "/Users/Fishman1049/anaconda/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/Users/Fishman1049/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 13] Permission denied I am running matplotlib version 1.5.1, just installed FFmpeg today using homebrew, spyder 2.3.8, python 2.7 and OS X 10.10.5. Thank you!.