Using ffmpeg (or similar) to print detailed h264 information - ffmpeg

I have some h264 video in mpeg transport stream, and I suspect at certain points in the video it switches from 1080i/50Hz to 1080p/25Hz. I'd like to prove that using some video analysis tool. Can ffmpeg (or similar) print out such detailed decoding info? I've tried ffmpeg setting "-loglevel debug" but it prints no more info about the actual decoding.

ffprobe is a far easier solution and is included with FFmpeg:
$ ffprobe -show_frames -i input.mp4

Sorted it. In the end I put a few printfs into ffmpeg source to get the info I needed.

Related

ffmpeg -f sdl compares to ffmpeg -f h264 via UDP

I am very new to ffmpeg, and want to ask in ffmpeg -f sdl, what is the force format means and what is sdl?
I'm asking this because, when I try
ffmpeg -i udp://192.168.1.124:12345 -f h264 "test"
ffmpeg -i udp://192.168.1.124:12345 -f sdl "test"
if I use -f h264, it seems just receiving the stream and save to file "test"
however if I use -f sdl, it seems it will not store to a file, instead, it brings up a video player view and start playing the video directly.
however, this didn't make me think it has anything to do with force format(-f)?
I couldn't find the doc on https://ffmpeg.org/ffmpeg-formats.html. Can someone help on this? Thanks.
FFmpeg can write data to structured containers (AVI/MP4/MKV..) or raw streams (H264,M4V..) or devices (Decklink/SDL..). All of these are specified using -f. For file-based output, they are usually inferred via the extension, so -f can be omitted.
SDL2 is the library used by ffplay to render textures to display and also catch input keyboard/mouse events. If ffmpeg was compiled alongwith ffplay, SDL2 is linked with ffmpeg binary as well. But with ffmpeg, only video is rendered.

Using ffmpeg to convert an SEC file

I need to convert an SEC file into any video format that I can share and/or upload to Youtube. MP4, etc.
I'm a complete newbie at all things terminal. I've tried:
ffmpeg -i video.sec video.mp4
ffmpeg -i video.sec -bsf:v h264_mp4toannexb -c:v copy video.avi
ffmpeg -i video.sec -b 256k -vcodec h264 -acodec aac video.mp4
I don't understand what any of these mean, they're just examples I found online. However, whatever I try returns this error:
Invalid data found when processing input
Any thoughts? Thanks!
I had to add the following option so it would skip the SEC's custom header.
-skip_initial_bytes 48
i know this is old, but i was trying to figure this out as well, what ended up finally working for me was this command.
./ffmpeg -f h264 -i INPUT.sec -filter:v "setpts=4*PTS" OUTPUT.avi
the -f h264 was the part i was missing. and the -filter:v "setpts=4*PTS" part is to slow it back down to the original speed. you can also change the .avi at the end to whichever format works best for you.
i hope this helps someone out :)
OK, just to clear up some recent threads…
The Samsung DVR used here was an SRD-440. RB kindly sent me a file to test and he sent me a .BU file with an associated .db2 file. This was a bit of a surprise as in all older Samsung DVR’s, the .bu files can only be played back in the DVR. I mentioned this here, https://spreadys.wordpress.com/2014/07/21/ifsec-samsung-exports/
It appears that Samsung have caught on, and the BU file is now playable due to it being a H264/AVC Stream conforming to a standard profile. I have updated the IFSEC Post mentioned above to highlight this change.
Back to RB’s stream and the challenge was to get these files viewable in WMV format. They were all field based, at 704×288.
The speed of playback is controlled by the Samsung software, using the .db2 file. As such, the metadata and timing information in the video stream was wrong. This caused speed issues and then quality issues when attempting to correct this.
As a result, I found it necessary to force an input rate and generate a new Presentation Time Stamp BEFORE the input file.
The following FFmpeg string did the job…
ffmpeg -r 12 -fflags genpts -i FILE.bu -vf scale=704:528 -sws_flags lanczos -q:v 2 FILE.wmv
Remember, this is for preview – analysis would be completed differently due to the scaling, the interpolation method, and the WMV compression!
As its likely that RB may have quite a few .bu files in a folder, I placed this into a batch file to transcode the whole lot within a few minutes… more on batch files coming in a new post soon!
https://spreadys.wordpress.com/2014/07/21/ifsec-samsung-exports/
or
ffmpeg -i (name of file).sec (name of final file).mp4
ffmpeg -i (name of file).sec -filter:v "setpts=3.3*PTS" (name of final_file).mp4

ffmpeg pipe to mediainfo

I need to get infos from the raw h264 track of a mkv file.
Some times ago, I used to extract the h264 raw stream, and analyze it by itself.
now, I would like to limit the disk usage, avoiding the extract process, so there are 2 choices:
use ffmpeg to pipe h264 to mediainfo
use a sort of ramdisk
I tried
ffmpeg -i original.mkv -map 0:v:0 -c copy -bsf:v h264_mp4toannexb -f h264 - | mediainfo -
but it returns none
where am I wrong?
mediainfo does not (yet) support pipes (-). You may want to add a feature request on MediaInfo tracker.
but... I don't see which kind of better metadata report you get with that, compared to 'mediainfo original.mkv', as MediaInfo supports parsing of H264 in MKV.

ffmpeg speed up video - Windows

In manual it says:
ffmpeg -i input.mkv -filter:v 'setpts=0.5*PTS' output.mkv
But when I run:
ffmpeg -i input.mp4 -filter:v 'setpts=0.5*PTS' speedup.mp4
I get an error:
[AVFilterGraph # 0000000002500600] No such filter: 'setpts=0.5*PTS'
Error opening filters!
Not sure if it means that filter can't be opened at all or simply this filter is not available.
How do I run it correctly? Or maybe my release does not support it, then where can I get the release that would work right? Win32/x64 binary
Use both setpts and atempo to speed up both video and audio:
ffmpeg -i input-video.mp4 -vf "setpts=0.68*PTS" -filter:a "atempo=1.467" output-video.mp4
From: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
You'll have to do the right math for the numbers, of course. The setpts needs to be smaller to make the video go faster, but atempo needs to be larger to speed up the audio.
Audio value needed = 1 / Video value
if you have your ffmpeg.exe (mine for windows) for ex you can list all the available filters with this command line, you can edit the txt file c:\filters.txt to see them.
ffmpeg -filters > c:\yfilters.txt
in mine i can se the filter SETPS (VIDEO TO VIDEO only):
setpts V->V Set PTS for the output video frame.
your command line is correct and work with the ffmpeg version that have this filter(try to download the latest version)
this command line works also for me :
ffmpeg -i video_input -vf "setpts=factor*PTS" video_output
the factor can be :
1.for speeding the video 0.2,0.4,0.6,0.8..(<1)
2.for slowing the video:1.2,1.4,1.6,1.8,2.0,3.0,4.0,5.0,10.0... (>1)
Try using double quotes. e.g. ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" speedup.mp4

Convert streaming MPEG-4 raw data to H.264

I've got a Sony network camera (SNC-RZ25N) that I am trying desperately to get data from in some meaningful format. The documentation says it sends MPEG-4 raw data, but is not more specific than than. I can capture a segment of the stream using curl ( http://techhead.biz/media/tsv.m4v ) and it will play using VLC and ffplay (though it plays too fast in ffplay).
After a day and a half of tinkering, I just discovered that I cannot use ffmpeg to convert this stream directly. For one, the only way ffmpeg accepts piped data as input (that I'm aware of) is in the 'yuv4mpegpipe' format.
I tried piping to ffmpeg using 'm4v' as the specified format, but it seems to want to read the entire stream before it begins processing.
Anyone know how I can do this? Using commandline tools? Open source libraries in ANY programming language? Simpler solutions are preferred, but any working solution would be great.
It appears mplayer can play your m4v file over HTTP, and at least with your sample file this works:
mkfifo /tmp/fifo
mplayer -benchmark -vo yuv4mpeg:file=/tmp/fifo http://techhead.biz/media/tsv.m4v
ffmpeg -f yuv4mpegpipe -i /tmp/fifo -vcodec libx264 -vpre libx264-hq /tmp/foo.mp4
(-benchmark tells mplayer to ignore frame duration, might or might not be needed)
Alternatively, with just mencoder:
mencoder -o /tmp/foo.avi -of avi -ovc x264 -x264encopts bitrate=250 http://techhead.biz/media/tsv.m4v
Finally, if you don't actually need H.264, you could just put the existing MPEG-ES data in whatever container format you need; MP4Box might be able to do this, and ffmpeg and mencoder can if they support the output format.

Resources