I have been using ffmpeg to convert a sequence of jpegs to a video using the following syntax
ffmpeg -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi
it works a treat, however if the filenames dont start at 0 and then pursue in accending order I get weird results. for example the first file in the directory is frame1 and last file is fram 61.I should point out that im always using a list of jpegs which accend in incrental order. for example a list of files called frame1, fram2, fram3 etc.
the following works fine
frame1.jpg to frame9.jpg
frame1.jpg to frame10.jpg
frame2.jpg to frame8.jpg
frame2.jpg to frame10.jpg
frame2.jpg to frame11.jpg
frame2.jpg to frame17.jpg
frame2.jpg to frame20.jpg
frame2.jpg to frame30.jpg
frame2.jpg to frame61.jpg
the following doesnt work
26 to 57 fail
11 to 61 fail
10 to 61 fail
20 to 61 fail
24 to 61 fail
Can I modify the arguments for ffmpeg so that it will make the video regardless of the filenames? (frame%d)
The only way I got this to work was by naming frames files with a constant fixed width for frame counters. If you are taking frames from webcams check if that could be done by the webcam itself, otherwise, you'll have to rename it yourself. You may develop a Windows Service that use a FileWatcher class in C# that "listens" for a folder to be writted with a frame and then rename it to another folder with the beforemention format. This worked for me.
frame01.jpg
frame02.jpg
...
frame10.jpg
frame11.jpg
...
frame61.jpg
Then using this:
ffmpeg.exe -r 1 -f image2 -i frame%02d.jpg -r 16 -vcodec mpeg4 -b 800k -y video.avi
-i frame%02d.jpg: indicates 2 digits for frame counter
I added -r 1 and -r 16 as optional framerates that I test to have worked for me.
You could rename all jpeg files so the numbering always starts at zero and there are no gaps.
Related
I'm using some X11 bindings to query some window information and later pass it to FFmpeg. FFmpeg expects a "window ID" given in hexadecimal notation.
This notation seems somewhat standard, as it is returned by programs like xwininfo or wmctrl. I haven't found much information about it, but it seems to just be the hexadecimal representation of the window pointer? If I take the ID string given by these programs and give it to FFmpeg, it is able to capture the window correctly:
$ xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x2800014 "Desktop — Plasma"
$ ffmpeg -f x11grab -window_id 0x2800014 -i :0+0,0 -f apng -vframes 1 out.png
# works fine
However, if I try listing all the windows in code:
var root = Window.None;
var parent = Window.None;
Xlib.XQueryTree(_display, Xlib.XDefaultRootWindow(_display), ref root, ref parent, out var children);
var ids = children
.Select(ptr => $"0x{(ulong) ptr:x}")
.ToArray();
I don't see 0x2800014 in the results (even disregardingleading zeroes), and if I try running FFmpeg on one of those results, it fails terribly:
$ ffmpeg -f x11grab -window_id 0x4400003 -i :0+0,0 -f apng -vframes 1
# snipped for brevity
Trailing option(s) found in the command: may be ignored.
[x11grab # 0x55b811a8da40] Cannot get the image data event_error: response_type:0 error_code:8 sequence:10 resource_id:167772160 minor_code:4 major_code:130.
[x11grab # 0x55b811a8da40] Continuing without shared memory.
[x11grab # 0x55b811a8da40] Cannot get the image data event_error: response_type:0 error_code:8 sequence:11 resource_id:71303171 minor_code:0 major_code:73.
Input #0, x11grab, from ':0+0,0':
Duration: N/A, bitrate: 38361 kb/s
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 200x200, 38361 kb/s, 29.97 fps, 1000k tbr, 1000k tbn
At least one output file must be specified
So I must conclude my guess that they are hex pointers is incorrect, or that the Window type is not the pointer itself, but then the question stands, how can I get the actual window IDs so I can pass them to FFmpeg?
I must have missed the documentation. XQueryTree returns only children windows (direct descendants), not all descendants. You have to recursively call it on the returned children array to gather the entire tree.
I am Using FFMPEG With C# , And I want to add a water mark to a video , so I store the position of the user click in the media player and then Use the FFMPEG Command :
-i input.mp4 -vf "drawtext="Roboto-Regular.ttf":text='Stack Overflow':fontcolor=white:fontsize=24:box=1:boxcolor=black#0.5:boxborderw=5:x=300:y=100" -codec:a copy "ouput.mp4"
but this is not working , Any Solutions ?
Try this:
-i input.mp4 -vf "drawtext=Roboto-Regular.ttf:text='Stack Overflow':fontcolor=white:fontsize=24:box=1:boxcolor=black#0.5:boxborderw=5:x=300:y=100" -codec:a copy "output.mp4"
Note that the double-quotes have been removed from the font file name. In my testing this worked fine on Windows.
TL;DR:
Here is my question:
Can a ffmpeg process recording a rtsp stream run for 10 years or will it break down at some point, given there are no issues with storage and the stream? Glad for any experience like ( "this process has run for x weeks or days)
I have a task to enable my client to record and archive rtsp cam recordings. They should be restreamable and searchable so i opted for mpegts for fast cutting and concatenation, and restreaming as Video on Demand at a later point. This was all fun and games until a new recent requirement, that this should be stable for 10 years.
My FFMPEG Arguments look like this:
-hide_banner -rtsp_transport tcp -i rtsp://MYRTSPURL -threads 8 -pix_fmt yuvj420p -map 0 -c:v h264 -b:v 2M -bf 0 -muxpreload 0 -muxdelay 0 -force_key_frames "expr:gte(t,n_forced0.5)" -strftime 1 -f segment -segment_time 60 -segment_format mpegts -reset_timestamps 1 C:\RecorderTest\capture-%Y-%m-%d_%H-%M-%S.ts -pix_fmt yuvj420p -map 0 -c:v h264 -b:v 200k -bf 0 -muxpreload 0 -muxdelay 0 -force_key_frames "expr:gte(t,n_forced0.5)" -s 192:144 -strftime 1 -f segment -segment_time 60 -segment_format mpegts -reset_timestamps 1 C:\RecorderTest\capture-%Y-%m-%d_%H-%M-%S_preview.ts
which I utilize trough a C# Process. It works quite well so far but I noticed that despite I have set -reset_timestamps 1 the StdErr Progress Output is not resetting but keeps increasing.
FFMPEG STDERR says: frame= 1840 fps= 30 q=28.0 q=22.0 size=N/A time=00:00:59.80 bitrate=N/A dup=0 drop=2 speed=0.983x
FFMPEG STDERR says: [segment # 0000023d8c5e8b40] Opening 'C:\RecorderTest\capture-2022-03-01_11-54-57_preview.ts' for writing
FFMPEG STDERR says: [segment # 0000023d8c5ee940] Opening 'C:\RecorderTest\capture-2022-03-01_11-54-57.ts' for writing
FFMPEG STDERR says: frame= 1855 fps= 30 q=28.0 q=22.0 size=N/A time=00:01:00.30 bitrate=N/A dup=0 drop=2 speed=0.983x
So the time value is increasing and not resetting. Now I fear that this could lead to some undefined behavior. Does anyone know where I could check in ffmpeg source if the case that this time index reaches the max value is catched or if the process will crash by then?
I am using c#.net for writing the map and reduce function.I have basically followed the example being given here
Final command
Hadoop jar hadoop-streaming.jar -files "hdfs:///example/apps/map.exe,hdfs:///example/apps/reduce.exe" -input "/example/apps/data.csv" -output "/example/apps/output.txt" -mapper "map.exe" -reducer "reduce.exe"
The Job ran successfully
Now from the Interactive JS mode, if I write
js> #cat /example/apps/output.txt
cat: File does not exist: /example/apps/output.txt
Where as :
js> #ls /example/apps/output.txt
Found 3 items
-rw-r--r-- 3 xxxx supergroup 0 2013-02-22 10:23 /example/apps/output.txt/_SUCCESS
drwxr-xr-x - xxxx supergroup 0 2013-02-22 10:22 /example/apps/output.txt/_logs
-rw-r--r-- 3 xxxx supergroup 0 2013-02-22 10:23 /example/apps/output.txt/part-00000
What is the mistake I am making and how can I see the output?
The -output flag specifies an output folder, not a file. Since there can be multiple reducers, each one will produce a file in this folder.
In this case, you have one reducer, and it produced one file: part-00000. If there were more reducers, they would be named part-00001, part-00002, etc.
The command cat /example/apps/output.txt/part-00000 will display your output. In the future, don't name your output folders something.txt, as that will just confuse you and others :)
I have created a .NET C# project that I have commented using blocks similar to ///<summary>A summary...</summary> that I would like to document using Doxygen. I have set up Doxygen and it runs generating a some 100 .tex-files and a Makefile.
As I have understood, the Makefile is the key to generating the documentation as a PDF, however I do not get it to work.
I'm using a Mac to do the LaTeX and Doxygen bit by writing make -f Makefile in the Terminal when I am in the Doxygen LaTeX output directory.
all: refman.pdf
pdf: refman.pdf
refman.pdf: clean refman.tex
pdflatex refman
makeindex refman.idx
pdflatex refman
latex_count=5 ; \
while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
do \
echo "Rerunning latex...." ;\
pdflatex refman ;\
latex_count=`expr $$latex_count - 1` ;\
done
clean:
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
When running, i get the following message:
MacBook-Pro-13:latex sehlstrom$ make
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
make: *** No rule to make target `refman.tex', needed by `refman.pdf'. Stop.
How can I get the Makefil thing work?
refman.tex is supposed to be created by Doxygen. I just tested with my installed version, doxygen 1.7.2, and it created a refman.tex.
Make sure you aren't setting any option that says this is a component of a larger project that shouldn't have its own index.