ffmpeg output video size limits to 4GB - ffmpeg

I have a video file of .mp4 format. I want to convert it into .mpeg.
But when the output file size reaches 4GB, the conversion stops with a message something like "av_interleaved_write_frame() file too large"
My file system is ext4.
The commands I used are as below :
ffmpeg -i "input_file.mp4" -q:v 0 -q:a 0 -c:v mpeg2video "output_file.mpeg"
ffmpeg -i "input_file.mp4" -q:v 0 -q:a 0 -c:v mpeg2video -fs 8G "output_file.mpeg"
I understand that the conversion target defaults to DVD, so, the 4GB is the upper limit. can I tweak the target ?
Or, is it possible to dump the output to a subsequent file2Out.mpeg once file1Out.mpeg reaches 4GB

Yes, the reason is the filesystem format. FAT32 doesnt allow an mpeg file to exceed 4GB.
thank you

For instance, if your input lasts for 2 hours, you can convert the first hour to one file, and the second hour to another file by using -to option to stop at a certain position and -ss (placed before -i) option to start from a certain position:
ffmpeg -i "input_file.mp4" -to 1:00:00 -q:v 0 -q:a 0 -c:v mpeg2video "output_file_h1.mpeg" && \
ffmpeg -ss 1:00:00 -i "input_file.mp4" -q:v 0 -q:a 0 -c:v mpeg2video "output_file_h2.mpeg"

Related

ffmpeg combined video increaes duration

I am splitting video file in scenes and then process them. After processing and combining them I gain a lot of extra seconds. Original duration 24:29 after combining 24:59.
First I split video with this command
ffmpeg -i test.mkv -f segment -c copy -map 0 -y $HOME/Encoding/SPLIT/OUTPUT-%07d.mkv
And then I process each file encoding x264 to AV1:
ffmpeg -i $HOME/Encoding/SPLIT/OUTPUT-0000125.mkv -map 0:0 -pix_fmt yuv420p10le -strict -1 -f yuv4mpegpipe /tmp/fifo_stream
SvtAv1EncApp -i /tmp/fifo_stream --profile 0 --preset 6 --qp 35 --max-qp 63 --min-qp 1 --rc 0 --keyint 240 --input-depth 10 --crf 30 --rc 0 --passes 2 --film-grain 0 -b $HOME/Encoding/CONVERTED/OUTPUT-0000125.ivf
and store information about every converted file in $HOME/Encoding/list.txt file
Then I combine files:
ffmpeg -f concat -safe 0 -i $HOME/Encoding/list.txt -y $HOME/Encoding/encoded.mp4
result video gained extra 30 seconds. Someone knows what to do so that combined file duration will be same as original?

Trying to get frame timestamp with ffmpeg from a RTSP camera

I'm trying to retrieve the timestamp of each frame of a camera using an rstp stream and them.
For recording I use the following command line and it's work :
ffmpeg
-correct_ts_overflow 0
-probesize 1G
-analyzeduration 1G
-i rtsp://user:password#ip:port
-vcodec copy
-bsf:v h264_mp4toannexb
-bufsize 10M
-acodec copy
-f ssegment
-segment_list_flags live
-segment_atclocktime 1
-reset_timestamps 1
-write_empty_segments 1
-segment_time 15
-segment_list C:\Video\Delivery\ffmpeg\list.video
-segment_list_type csv
-strftime 1 "C:\Video\Delivery\ffmpeg\%%Y%%m%%d_%%H-%%M-%%S.ts"
And for some utility I would like to be able to retrieve the timestamp of the machine when I receive a frame, so by searching a bit I found different post on '-mkvtimestamp_v2'. By trying it alone with the camera as if below:
ffmpeg
-copyts ^
-correct_ts_overflow 0 ^
-probesize 1G ^
-analyzeduration 1G ^
-i rtsp://user:password#ip:port
-c copy
-pix_fmt yuv420p
-flush_packets 1
-vframes 10
-reset_timestamps 1
-timestamp now
-copyts
-f mkvtimestamp_v2 timestamp.txt
-vsync 0
It works perfectly.
But from the moment I try to record AND try to retrieve the timestamp simultaneously with the following command :
ffmpeg
-use_wallclock_as_timestamps 1
-correct_ts_overflow 0
-probesize 1G
-analyzeduration 1G
-i rtsp://user:password#ip:port
-vcodec copy
-bsf:v h264_mp4toannexb
-bufsize 10M
-acodec copy
-f ssegment
-segment_list_flags live
-segment_atclocktime 1
-reset_timestamps 1
-write_empty_segments 1
-segment_time 15
-segment_list C:\Video\Delivery\ffmpeg\list.video
-segment_list_type csv
-strftime 1 "C:\Video\Delivery\ffmpeg\%%Y%%m%%d_%%H-%%M-%%S.ts"
-copyts
-vcodec copy
-flush_packets 1
-f mkvtimestamp_v2 log.txt
-vsync 0
I get a lot of: Non-monotonous DTS in output stream 0:0 warning.
I also have on average one minute delay between the recorded timestamps, and the real timestamp.
And the first video recorded have a bugged timer on a video player like this : Here
I've tried arranging the command in different orders but I get nothing conclusive...
So if you have any idea that would be a big help!
I work on Windows 10 and I use ffmpeg-3.4.1.
Cordially,
Jay
I solved it by piping the second output to another ffmpeg instance. The reason why I think this works is because the second ffmpeg will discard the timestamp offset that was added by -use_wallclock_as_timestamps 1 and reset the offset to 0.
ffmpeg -use_wallclock_as_timestamps 1 -i rtsp://#ip:port -c copy -copyts -y -f mkvtimestamp_v2 timestamps.txt -vsync 0 -c copy -f mpegts - | ffmpeg -f mpegts -i - -c copy -f segment output-segment-%d.mp4
Another problem however with this solution is that if RTSP drops some frames, then the mkvtimestamp_v2 file will be skipping some time values, making it hard to correlate the segments with the timestamps.txt file.
So instead I solved it by embedding the wall clock timestamps into the segments themselves.
ffmpeg -use_wallclock_as_timestamps 1 -i rtsp://#ip:port -c copy -copyts -vsync passthrough -f segment -segment_time 10 out%d.mp4
Then I can run ffprobe later on each segment to know their actual start time. (relative to system clock).

FFMPEG: Add FrameRate Option Seconds Stream

I am trying to Copy Two H264 stream into One MP4 File. But I want to set the Framerate for Both H264 stream before copying into One MP4 File. I am able to set FrameRate for First Video H264 Stream. But not able to able to set FrameRate for Seconds Video H264 Stream.
Here are my attempts.
ffmpeg -r:v:0 15 -i 15FPS.h264 -r:v:1 30 -i 30FPS.h264 -c:v:0 copy -c:v:1 copy -map 0 -map 1 hello.mp4
ffmpeg -r:v:0 15 -i 15FPS.h264 -r:v:1 30 -i 30FPS.h264 -c copy -map 0 -map 1 hello.mp4
First H264 Stream in MP4 File is with 15 FPS but For Second Stream FFMPEG takes by default FPS setting with 25 even I specified 30 explicitly.
Can Someone Point me which part is wrong in my command. It would be appreciated.
Your 2nd stream specifier is wrong. It should also be -r:v:0 since -r is a per-file option and raw .h264 can contain only one stream. (So you can drop the specifier altogether)
ffmpeg -r 15 -i 15FPS.h264 -r 30 -i 30FPS.h264 -c copy -map 0 -map 1 hello.mp4

What command convert mjpeg IP camera streaming to mp4 file with lowest CPU usage?

like above question, I want find out what ffmpeg command can help me reduce cpu usage when running 50 IP camera (running same 50 command).
My ffmpeg command:
ffmpeg -f mjpeg -y -use_wallclock_as_timestamps 1 -i 'http://x.x.x.x:8090/test1?.mjpg' -r 3 -reconnect 1 -loglevel 16 -c:v mjpeg -an -qscale 10 -copyts '1.mp4'
50 command like that take my computer (4 core) 200% CPU
I want this computer can run for 150 camera, any advise?
=========================================================
using -c:v copy can make it faster but fize size is terrible
I try slow down frame rate by 3 with -r 3 or -framerate 3 to decrease file size but not succesful (because vcodec copy can't do that).
Have any option to force input frame rate by 3?
(sorry for my bad English)
by setting -c:v mjpeg you are decoding and re-encoding the stream. set -c:v copy to copy the data without re-encoding it.
ffmpeg -re -i 'rtsp://user:password#10.10.10.30/rtsp_tunnel' -pix_fmt yuv420p -c:v libx264 -preset ultrafast -profile baseline -crf 18 -f h264 udp://0.0.0.0:3001

How to get better quality converting MP4 to WMV with ffmpeg?

I am converting MP4 files to WMV with these two rescaling commands:
ffmpeg -i test.mp4 -y -vf scale=-1:360 test1.wmv
ffmpeg -i test.mp4 -y -vf scale=-1:720 test2.wmv
I've also tried:
ffmpeg -g 1 -b 16000k -i test1.mp4 test1.wmv
However, the .wmv files that are produced are "blocky and grainy" as you can see here in a small section of a video screenshot:
These are the sizes:
test.mp4 - 106 MB
test1.wmv - 6 MB
test2.wmv - 16 MB
How can I increase the quality/size of the resulting .wmv files (the size of the .wmv files is of no concern)?
Consider the following command instead (some outdated commands in the final answer section):
ffmpeg -i test.mp4 -c:v wmv2 -b:v 1024k -c:a wmav2 -b:a 192k test1.wmv
REFERENCES
https://askubuntu.com/questions/352920/fastest-way-to-convert-videos-batch-or-single
You can simply use the -sameq parameter ("use same quantizer as source") which produces a much larger sized video file (227 MB) but with excellent quality.
ffmpeg -sameq -i test.mp4 -y -vf scale=-1:360 test1.wmv
In newer versions of ffmpeg flag '-sameq' has been removed. To achieve similar results one should use 'qscale' flag with 0 value:
ffmpeg -sameq -i test.mp4 -qscale 0 -vf scale=-1:360 test1.wmv
Working answer in 2020, producing an output video without blockiness:
ffmpeg -i input.mp4 -q:v 1 -q:a 1 output.wmv
One thing I discovered after many frustrating attempts of enhancing the final quality was that if you don't specify a bitrate, it'll use a quite low average. Try -b 1000k for a starting point, and experiment increasing or decreasing it until you reach the desired result. Your file will be quite bigger or smaller, accordingly.
I used this and it turned out quite well
ffmpeg -i "file1.mp4" -q:v 0 -c:v wmv2 -b:v 1024k -c:a wmav2 -b:a 192k test2.wmv

Resources