FFMPEG - Strange issue with video copy - windows

I'm new here.
I have a set of TIF frames that equal 1 minute and 25 seconds of a video.
I'm attempting to copy the frames without re-encoding using the "-c:v copy" function to avoid visible quality loss for a process I'm doing on my side. The command is as follows:
ffmpeg -r 23.977 -i %06d.tif -c:v copy out.mkv
However for some reason, the timing does not seem to be accurate and the video is slightly desynced from the original, ending at 1 minute and 22 seconds instead.
When I use the following command:
ffmpeg -r 23.977 -i %06d.tif out.mkv
It comes out with the proper timing at 1 minute and 25 seconds, however, I did not appreciate the quality loss that came with it.
Is there a workaround to this or is there something I'm missing?
I used both Command Line and Windows Terminal.

In general, it would make sense to transcode when you go from tiff to video format. (I'm surprised it actually works.) You can set encoding quality to your own liking. See [this FFmpeg Wiki article[(https://trac.ffmpeg.org/wiki/Encode/H.264).

Related

Using FFMPEG I get an error when trying to insert a fade after about 35 mins in a long video - is this possible?

I have a source video that is an hour long from which I want to extract a couple of minutes towards the end and add a video fade in at the start of the cropped section.
Using FFMPEG, I'm specifying the following command:
ffmpeg -i MyLongVideo.mp4 -q:v 0 -y -ss 00:50:00.000 -to 00:52:00.000 -vf "fade=t=in:st=3000.0:d=1.0, scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2" ./testoutput.ts
This is intended to crop from the source video from 50:00.000 to 52:00.00 and fade in from the 50th minute for 0.5 seconds (so at 3000 seconds in - st=3000.0).
This command that we build programmatically, works on shorter videos or when you crop from before about 35 minutes. For this longer video though I get an error that says:
[fade # 0000025399981e80] Value 3000.000000 for parameter 'st' out of range [0 - 2147.48]
The 2147.48 is around the 35 minutes in seconds which explains why this command works for shorter videos or on crops earlier than 35 minutes.
I've seen a number of other issues with FFMPEG talking about this 'magic' 2147.48 number with parameter values. Is this some sort of hard limit?
Is there a way to do what I want to do? I could do this in two passes - extract the section of video and then add the fade, but I'd rather do it in one command if possible - and it works for shorter/earlier crops.
Get a ffmpeg build from after Nov 12 2018 or before Oct 7 2018. There was a regression in the builds in between.

ffmpeg progress is freezing frames when scene change

I'm capturing data from IP camera with RTSP protocol with ffmpeg with command:
ffmpeg -rtsp_transport tcp -progress /media/kamip/stats.txt -i rtsp://192.168.1.220:554/live/h264/ch0
-c:v copy -c:a copy -strict 1 -map 0 -f segment -strftime 1
-segment_time 1800 /media/kamip/cam_%d_%m_%Y_%H_%M_%S.mkv
I'm using this for 5 cameras. One is different type and it is in different location.
Because ffmpeg does not support reconnect I'm writing status to /media/kamip/stats.txt file. In another script I'm parsing this output and every 30 seconds I'm checking if frame number changed, if yes - it is ok, if not, I'm restarting above command.
The problem is only in the night. When is quite dark and suddenly lights on, for example when car is parking, the /media/kamip/stats.txt is showing the same frame number, so my script is recognizing this as a lost connection (video freeze)
I tried "-strict 1" option and I think it is better (one false alarm per day instead of 10 per day), so I think this may be related to ffmpeg, not camera/video source, especially because the video is fine even frame number reported by ffmpeg is still the same. Also VLC does not have this kind of problem (but I cannot use it currently for this camera)
I found that ffmpeg has build-in scene change detector, but it should works only when encoding video (I'm using "copy" option for audio and video)?
I'm thinking about different way of analyzing the video capturing, but this "-progress" in ffmpeg should works fine - and it is working fine for other cameras for few years).
I also do not see any errors,
when I encoded one cutted file with "-loglevel debug" I saw only information like below:
[libx264 # 0x25d77a0] scene cut at 174 Icost:2049115 Pcost:2006553
ratio:0.0208 bias:0.1387 gop:54 (imb:3186 pmb:168)
ffmpeg in latest version
ffmpeg version 3.3.3-1ubuntu1~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
any help will be appreciated

ffmpeg - automatically chopped?

I have an ISO file that I would like to encode it out to mp4 in parts so it's easier to upload to youtube. I am not sure how it handles with chapters etc in this iso file. I have tried
ffmpeg -i file.iso newfile.mp4
which works great however it's one large file.
I have google and read some where that says if you put a % within the output file, it should automatically give you parts of the video based on the -t you set, so I went ahead and did this
ffmpeg -i file.iso -t 30 newfile%.mp4
however, the above does not work as it only give me 30 seconds with the file name: newfile%.mp4
Thanks for your time and hoping I can get some help with this. Thank you in advance!
You can use -t and -ss in conjunction to do this with a script.
Here is one: http://grapsus.net/blog/post/A-script-for-splitting-videos-using-ffmpeg

Live transcoding and streaming of MP4 works in Android but fails in Flash player with NetStream.Play.FileStructureInvalid error

Recently I had a task to use ffmpeg as a transcoding as well a streaming tool. The task was to convert the file from a given format to MP4 and immediately stream it, by capturing it from stdout. So far so good. The streaming works well with the native player of android tabs as well as the VLC player. The issue is with the flash player. It gives the following error:
NetStream.Play.FileStructureInvalid : Adobe Flash cannot import files that have invalid file structures.
ffmpeg flags used are
$ ffmpeg -loglevel quiet -i somefile.avi -vbsf h264_mp4toannexb -vcodec libx264 \
-acodec aac -f MP4 -movflags frag_keyframe+empty_moov -re - 2>&1
As noted in the docs for -movflags
The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4 file has all the metadata about all packets stored in one location (written at the end of the file, it can be moved to the start for better playback using the qt-faststart tool). A fragmented file consists of a number of fragments, where packets and metadata about these packets are stored together. Writing a fragmented file has the advantage that the file is decodable even if the writing is interrupted (while a normal MOV/MP4 is undecodable if it is not properly finished), and it requires less memory when writing very long files (since writing normal MOV/MP4 files stores info about every single packet in memory until the file is closed). The downside is that it is less compatible with other applications.
Either switch to a flash player that can handle fragmented MP4 files, or use a different container format that supports streaming better.
Also, -re is an input-only option, so it would make more sense to specify it before the input, instead of before the output.

FFMPEG not able to extract thumbnails of images larger than .6 MB

ffmpeg.exe -i "imageLarge.jpg" -y -f mjpeg -s 72x92 -vframes 1 -an thumbnail7292.jpg
We are using this command to generate thumbnails of image files using FFmpeg but found that it is not able to generate thumbnails of files larger than .6 MB can somebody suggest something on this.
It isn't clear what exactly the problem with ffmpeg is, but in any case I'd recommend using the convert utility from imagemagick. It's much simpler:
convert imageLarge.jpg -resize 72x92 thumbnail7292.jpg
If you give a description of the actual error, then more people will be able to help you.
EDIT
The OP's error is:
swScaler: Compile time max width is 2048
change VOF/VOFW and recompile
Cannot get resampling context
It's quite clear what the problem is. Your JPEG files are too big for your current build of ffmpeg. You will have to recompile ffmpeg or get a newer version if you want to work with larger images.
This is from src/libswscale/swscale_internal.h (version: FFmpeg SVN-r26402).
#if ARCH_X86
#define VOFW 5120
#else
#define VOFW 2048 // faster on PPC and not tested on others
#endif
That's the file you need to edit if you want to change the limits.
What version of ffmpeg are you using? This problem seems to have been addressed over a year ago.
If you don't want to rebuild ffmpeg, you could just use convert, like I originally advised.

Resources