In a previous entry ( Link) I mentioned that by using the ‘grep’ command within the command line in Linux, you are able to select specific information and only output that from a FFprobe result. Grep stands for global / regular expression / print. This avoids having a lot of unnecessary data. Whilst dealing with the video format here, I was pushed into finding the Windows answer!
.mp4 is a hugely common file extension but when dealing with proprietary surveillance video streams, the existence of a common file extension means very little. Each file had a simple naming convention of Ch01_DateTime.mp4. They also came with a player TVR_Player.exe.
The player has a common interface and is very similar to the Alien DVR Export Player and LJD Colossus Player. There are a few menu differences though; in particular, the LJD has an option for rewrapping into avi. Loading the mp4 files supplied here into both of the other players produced a negative result. The player that they came with had an interesting option though, ‘drop B Frames’. Why an evidential export player should even allow you to drop frames is a little bit worrying but I digress….
The video files appeared to play fine within the supplied player and a nice surprise was that it also displayed frame numbers. Due to the amount of video files, playing each one within the supplied player would be time consuming.
Analysing the video data within FFprobe verified the total number of frames along with some useful information on the video dimension, duration and encoding .
I used the command:
ffprobe -show_streams -count_frames -pretty input.mp4 > out.txt
This resulted in a .txt file detailing all the information about the video along with the number of read frames:
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
Before tidying the video streams up, I wanted to verify their GOP structure. By using the following ffprobe command, the resulting text file details all information about every single frame in the video – A LOT OF DETAIL!
ffprobe -show_frames -pretty in.mp4 > out.txt
In Linux, it is possible to alter the output by using Grep command but in windows, there is another method…..Windows Powershell.
This can be found in all Win7 and Win8 machines, hidden away in the Accessories. There is an Integrated Scripting Enviroment (ISE) that allows you to save commands and then run them as standalone commands. For this job though I kept with the basic Powershell and used Cmdlets!
Cmdlets are very similar to using the individual commands in ffmpeg so once you get to grips with that you are good to go!
You can see a list of all the Cmdlets here:
The script I needed to get rid of all the unnecessary information was
Get-Content C:\Users\David\Desktop\gop\in.txt | Select-String “pict_type”,”coded_picture_number” | Out-File C:\Users\David\Desktop\gop\out.txt
Breaking this down…..I needed to get the content from the in.txt file, I needed to select only the strings documented in the variable, I needed to output a file called out.txt
etc etc etc……
It turned out I had a 60 frame Gop!
( I am working on using the ConvertTo-Html Cmdlet to output both FFprobe results into a single, formatted and headed HTML report. I will keep you posted on that one!)
The original mp4’s would not play well in Virtualdub or any other standard video tool so now that we had identified Duration, Frame count, GOP structure etc, it was back into FFmpeg to rewrap.
ffmpeg -i in.mp4 -vsync drop -f avi -vcodec copy -r 15 out.avi
This did the job nicely and the resulting avi played and scrubbed perfectly. However – I had a fair few to do. One at a time would have been tedious so I quickly wrote a FFmpeg preset using the command above in Another GUI. This is another handy tool and works really well with many other command line programs, not just FFmpeg. Another bonus is that it can run several processes concurrently.
The result was a folder full of video that had not been transcoded but was being read correctly and all dropped straight into Forevid with no effort……and because I knew the GOP structure I could navigate to I frames using Forevids frame number function.
The powershell is definitely going to become a very handy tool!