Batch file to use FFMPEG to generate single "PIP" video from Front/Read

bpsmicro

Active Member
Joined
Jul 13, 2017
Messages
236
Reaction score
109
Country
Canada
I found some web pages that discussed FFMPEG commands to take a Front & Rear video file and combine into a single file with a PIP rear view (similar to how the Blackvue Viewer app looks).

I decided to create a .CMD file, suitable for use with Windows, to allow me to automatically generate such a video from my download folder. I'm sharing this with the community here. The attached Zip includes the .cmd itself and a ReadMe.txt explaining how to set it up. You'll need to download FFMPEG.exe separately (not included).

This isn't a full-fledged video editor app, merely a quick'n'dirty way to merge your Front & Rear views into a single file for easy sharing.

I'm not an FFMPEG expert by any means, so if you want to change the options to suit your own personal preferences, you're pretty much on your own. :)

Enjoy;
Brad.

Update 8 Oct 2018:
More tweaking. PIP_Join can now have passed in either a folder path, or any file within that folder, and properly "calculate" which folder to work in. Remember that PIP_Join works against all of the recordings in the selected folder, so choose carefully.
Also added a variable inside PIP.cmd for the Front/Rear scale. Set 'scale' to 2.0 for the DR650S, and 3.0 (default) for the DR750S to get the rear PIP size close to that of the BV viewer.

Update 6 Aug 2018:
Attached is an updated version of the Zip with a slightly tweaked PIP.cmd, and the addition of a new PIP_Join.cmd. Again using ffmpeg (which I can't attach due to size restrictions).
PIP_Join.cmd works on a full folder of videos. It's highly recommended you copy the videos (Front/Rear) you want to merge into a separate folder on your PC, and definitely don't run this on your microSD directly. The .cmd makes a list of all videos in the folder (in order), runs PIP.cmd to merge the Front/Rear (mostly as before), and then concatenates them all into a single mega-video.
Last night I ran this against a full 6-hour drive down the Newfoundland west coast, taking 150+ separate segments (34Gig) from my 650s-2ch and merging into a single 17Gig .mp4. Played it with VLC (which allowed me to run at 16x speed) with nary a glitch. Somehow, ffmpeg's concat process magically dealt with the overlap between segments without me having to do anything.

I would be very interested in hearing results from 750s and 900s users. In particular, I'd imagine there may be changes required to deal with the h.265 4k videos from the 900s. Or maybe it'll "downscale" and still mostly work. Not sure what to expect.
Other comments appreciated, but this isn't going to get much more user-friendly and if you don't know how to open a CMD shell in Windows and traverse folders, you may have some learning to do. :)
 

Attachments

  • Brad_PIP_Join_Blackvue.zip
    3.5 KB · Views: 229
Last edited:
I found some web pages that discussed FFMPEG commands to take a Front & Rear video file and combine into a single file with a PIP rear view (similar to how the Blackvue Viewer app looks).

I decided to create a .CMD file, suitable for use with Windows, to allow me to automatically generate such a video from my download folder. I'm sharing this with the community here. The attached Zip includes the .cmd itself and a ReadMe.txt explaining how to set it up. You'll need to download FFMPEG.exe separately (not included).

This isn't a full-fledged video editor app, merely a quick'n'dirty way to merge your Front & Rear views into a single file for easy sharing.

I'm not an FFMPEG expert by any means, so if you want to change the options to suit your own personal preferences, you're pretty much on your own. :)

Enjoy;
Brad.

Hmm, no idea. I'm on Win10 64-bit and it's working fine for me. What error are you seeing? What exact command-line are you using? It should be (in your sample) "PIP 20180131_114948".

TPVpaID.png


rQnFo4c.png


can you make full tutorials step by step video/picture..
 
I'm going to tweak the .cmd to do a better job of logging what it thinks is wrong. It uses some funky "math" to deconstruct path & filenames from what's passed in. Stand by...
 
Attached is a fresh Zip with some better "debugging" added for error detection.
I have the sneaking feeling your problem is with how your SendTo shortcut got added, because the .cmd should already log more than what you're seeing.
Follow this article, which is a fairly simple description of adding a shortcut to SendTo, and double-check what you have.

Update 6 Aug 2018: See first message in the thread for the latest Zip.
 
Last edited:
Attached is a fresh Zip with some better "debugging" added for error detection.
I have the sneaking feeling your problem is with how your SendTo shortcut got added, because the .cmd should already log more than what you're seeing.
Follow this article, which is a fairly simple description of adding a shortcut to SendTo, and double-check what you have.
sMqzwCm.png


its working.. thanks
 
Is there any way to adjust the size of the overlay video? I've tried it for a clip, but it makes the rear recording too large for my taste.
 
Edit the .cmd file in your favorite text editor and play with the 'scale=' command. Right now it's 1.7, but I don't recall if you want that to go up or down to shrink the Rear image. If you run 'ffmpeg -?' in a command shell it gives you some help. Post the number you end up sticking with.
 
Edit the .cmd file in your favorite text editor and play with the 'scale=' command. Right now it's 1.7, but I don't recall if you want that to go up or down to shrink the Rear image. If you run 'ffmpeg -?' in a command shell it gives you some help. Post the number you end up sticking with.
I've played around with the number a bit, and I've found that setting the number to somewhere around 3.0 makes it look more like the BlackVue Viewer's PIP. I'm probably going to adjust that a bit more, but for now, that's a pretty good number to use.
20180517_131231_E_PIP.mp4_snapshot_00.25_[2018.05.23_01.07.33].jpg
 
I've updated the the Zip to include additional functionality, including concatenating multiple videos into one. Check the first message of the thread for details and the new Zip.

Brad.
 
Hi there, love your script.
Just recently bought my own DR750S-2CH

I've gotten your PIP.cmd to work just fine, by making shortcuts in "shell:sendto" - adjusted scale to fit my prefered PIP-ratio

However when i use your PIP_Join.cmd, I get the following error:
PIPJoin.jpg

It happens even when i right-click one, or select all and then right-click, send to, and then the shortcut for PIP_Join under "Send To"

Best Regards,

Lasse
 
Hmmm. Let me play around a bit and see if I can persuade that to work properly. Hopefully I can reproduce what you're seeing. It's *supposed* to take the file name(s) passed in and calculate the folder from that ("d:\test2" in your example), but that seems to have failed.
 
Yeah I am not an expert in using cmd commands, so when I opened the file, I had no idea what i actually was looking at :ROFLMAO:
 
Apologies for the excessive delay in working on this. I've since traded my DR650S for a DR750S, so now I can compare settings. I did find the glitch in PIP_Join, which expected a folder name parameter. Now it'll accept a folder or any file(s) within that folder and calculate accordingly.
Updated Zip is attached to the first message in the thread.
 
Newbie here. I'm trying out this script for the first time. Is there anyway to move the PIP to the bottom left hand corner (like in BV Viewer), as opposed to where it is now (top left)? This way the PIP appears over the dashboard area, which is fine, instead of blocking the view of the side. Thanks a bunch.
 
The .cmd uses ffmpeg. You can edit the command itself to tweak the settings, but you'll need to play with it to figure out the exact combination yourself. I believe the one you need to tweak is overlay=0:0, but you'll have to play with it.
 
Brad... thanks for putting this together, just found it today and putting together clips from a 2 hour drive over the weekend.

so far the pip is work with the matching front and rear files, but it only does one at a time. is this working as intended or is it supposed to combine each pair in the entire folder where the video files are stored?

thx
 
It's a 2-step process. PIP.cmd only does front+rear. PIP_Join.cmd calls into PIP.cmd to join up all the files in the specified folder, and *then* concats that result into your one mega-file. I kept the two .cmd files separate for maximum flexibility when using. Both should echo to your console the steps as they follow them.
 
thanks Brad, i just discovered that and was testing before i replied, and the pip_join is working perfectly! 200 files to go!
 
Back
Top