Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to keep the orientation number after converting from a video file to a image file by a ffmpeg command
15 mars 2018, par user27240The command below is working perfectly fine for my environment except it deletes the orientation number of the image file after being converted from a video file.
I'd like to know how to keep the orientation number of the image with the command line below(it also have to keep the original purpose of its functionality which is conversion of a video to a image to another directory). I'd appreciate your support.
for i in /path/to/inputs/*.mp4; do ffmpeg -i "$i" -frames:v 1 "/path/to/outputs/$(basename "$i" .mp4).jpg"; done
ffmpeg version 2.2.2
OS:centos-6 (x86_64) -
Extract frames from a video file as rgb array
15 mars 2018, par MilanIs there a way that I can extract frame by frame from a video file. I need raw rgb data in my memory so i can calculate positions of objects. I tried doing that using ffmpeg in linux but i had a lot of problems, for example when I use function
av_register_all()
I get full screen of errors. The tutorial describes pretty much what I need, but it's out of date and I cant compile it with new version of ffmpeg. Can someone help me with some advice on how to update/edit this code or different method of compiling. -
Use ffmpeg to extract frames listed in a text file
15 mars 2018, par chicago1356ffmpeg -i video.mp4 -ss 00:00:07.000 -vframes 1 thumb.jpg
I know I can do the above to extract one frame from a video, but I have a list of timestamps in a text file formatted as such:
00:01:22.277 00:01:38.501 00:01:49.306
I need to extract 1 frame at each of those times (there are over 100 of them). How would I do this?
Thanks.
-
ffmpeg : concat and encode with one command
15 mars 2018, par Massimo VantaggioI have a script that automates encode and concat a series of input video files. I'm trying to get encode and concat in a single command.
At the moment it does not work causing immense empty pauses in the final video output.
I would like to get the result with concat demux instead of concat protocol because it is much harder to automate in a script
Do you know if it is possible to archive this result with concat demux? Thanks a lot!
Massimo
ENCODE / CONCAT 1080p
for f in ./*.mp4; do echo "file '$f'" >> list.txt; done ffmpeg -f concat -safe 0 -y -i list.txt -i ../logo/logo.png -c:a aac -b:a 384k -ar 48000 -ac 2 -af aresample=async=1000 -c:v libx264 -x264opts keyint=50:min-keyint=50:no-scenecut -bf 0 -r 25 -b:v 4800k -maxrate 4800k -bufsize 3000k -profile:v main -crf 22 -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10,scale=1920:1080,setsar=1" ../buffer/1080set.mp4
It seems to add long pause at low frame-rate:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb03f05e600] Auto-inserting h264_mp4toannexb bitstream filter
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:18:52.56 bitrate=1348.0kbits
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:18:56.57 bitrate=1343.3kbits/
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:19:00.65 bitrate=1338.5kbits/
frame= 9745 fps= 13 q=27.0 size= 186368kB time=00:19:02.29 bitrate=1336.5kbits/
More than 1000 frames duplicated
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4': Metadata: major_brand : mp42 minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 2016-02-27T22:25:49.000000Z encoder : HandBrake 0.10.5 2016021100 Duration: 00:06:29.87, start: 0.000000, bitrate: 3447 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 768x432, 3282 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default) Metadata: creation_time : 2016-02-27T22:25:49.000000Z handler_name : VideoHandler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default) Metadata: creation_time : 2016-02-27T22:25:49.000000Z handler_name : Stereo Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4': Metadata: major_brand : M4V minor_version : 1 compatible_brands: M4V mp42isom creation_time : 2016-02-27T18:52:37.000000Z Duration: 00:07:16.93, start: 0.000000, bitrate: 1184 kb/s Stream #1:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 991 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default) Metadata: creation_time : 2016-02-27T18:52:37.000000Z handler_name : Mainconcept MP4 Video Media Handler encoder : AVC Coding Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default) Metadata: creation_time : 2016-02-27T18:52:37.000000Z handler_name : Mainconcept MP4 Sound Media Handler Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '3.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41 creation_time : 2017-06-27T17:58:17.000000Z Duration: 00:05:05.05, start: 0.000000, bitrate: 2622 kb/s Stream #2:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 2301 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default) Metadata: creation_time : 2017-06-27T17:58:17.000000Z handler_name : Alias Data Handler encoder : AVC Coding Stream #2:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default) Metadata: creation_time : 2017-06-27T17:58:17.000000Z handler_name : Alias Data Handler Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '4.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41 creation_time : 2017-06-27T17:53:32.000000Z Duration: 00:06:47.36, start: 0.000000, bitrate: 3144 kb/s Stream #3:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 768x432, 2819 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default) Metadata: creation_time : 2017-06-27T17:53:32.000000Z handler_name : Alias Data Handler encoder : AVC Coding Stream #3:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default) Metadata: creation_time : 2017-06-27T17:53:32.000000Z handler_name : Alias Data Handler
-
Python FuncAnimation is saved only 30%
14 mars 2018, par cvutI am trying to make a movie out of data I've calculated. I am using ffmpeg writer. When I start the animation in Spyder it is working fine and goes to the end, but when I try to save it it goes only for first 30% of animation. How can I make it to save the whole animation?
Here is a bit of code( it's long); MM is place where the matrices are stored (1200 of them).
import matplotlib matplotlib.use("Agg") from mpl_toolkits.mplot3d import axes3d import matplotlib.animation as animation import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm nx = 10 ny = 10 X=np.linspace(0, Lx, nx) Y=np.linspace(0, Ly, ny) Writer = animation.writers['ffmpeg'] writer = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1) plt.ion() fig = plt.figure() im = plt.contourf(X, Y, MM[0], np.linspace(T_ok,np.max(MM[-1]),150), cmap = cm.hot) ax = fig.add_subplot(111, projection='3d') plt.colorbar(im) def anime(i): ax.cla() im = ax.contourf(X, Y, MM[i], np.linspace(T_ok,np.max(MM[-1]),150), cmap = cm.hot) plt.title('%5.3f'%i) return im, anim = animation.FuncAnimation(fig, anime) anim.save('anime.mp4', writer=writer)
EDIT: I just set frames to 10000 and it's working, but I would like to know why. There are 1200 matrices that should be plotted.