Reputation: 107
I have a drone which produces squashed videos (720x240). They are intended to be viewed at (720x480). I wrote a Python script that converts all files from the SD card into my Videos folder. The full script is below:
import os import subprocess
SRC = "D:/VIDEO/" TRG = "C:/Users/Adam/Videos/drone/"
print "Converting all drone videos from SD card." files = os.listdir(SRC) for f in files: print "File: D:/VIDEO/"+f
print "Target dir: "+TRG for f in files: print "Processing "+f newext = f[:f.find(".")]+".mp4" subprocess.call(["C:/Program Files/VideoLAN/VLC/vlc.exe", "-vvv", f, "--sout=#transcode{vcodec=h264,width=720,height=480,canvas-width=720,canvas-height=480,vb=800,fps=30,acodec=none,deinterlace=true}:standard{access=file,mux-video=mjpeg,dst=\""+TRG+newext+"\"}", "vlc://quit"], cwd=SRC)
Everything works, and I end up with .mp4 files that play just fine. However, despite being shown as being 720x480, they still display as 720x240, e.g. the actual visible video was not stretched to the desired dimensions.
The equivalent VLC command I am running is: vlc.exe -vvv FILE --sout=#transcode{vcodec=h264,width=720,height=480,canvas-width=720,canvas-height=480,vb=800,fps=30,acodec=none,deinterlace=true}:standard{access=file,mux-video=mjpeg,dst=DEST_FILE} vlc://quit
Am I doing something wrong? This is my first time using the VLC command line. Thanks, Adam
My system: MS Surface Pro 3 (intel i5, 256GB SSD, 8GB RAM) VLC x64 2.1.5
Upvotes: 0
Views: 2554
Reputation: 107
I have since fixed this part of my problem by looking at the output of VLC when the transcoding is done manually.
The working code is below:
import os
import subprocess
SRC = "D:/VIDEO/"
TRG = "C:/Users/Adam/Videos/drone/"
def parseYN(ask, default=None):
yes = ["Y", "y", "Yes", "yes", "YES"]
no = ["N", "n", "No", "no", "NO"]
uin = raw_input (ask)
for y in yes:
if uin == y:
return True
for n in no:
if uin == n:
return False
return default
DELETE = parseYN("Delete videos after conversion? (y/N)", False)
AVI_INDEX = parseYN("Form AVI index before transcoding? (Y/n)", True)
SET_TIME = parseYN("Change modification time of new files to that of original ones? (Y/n)", True)
print "Converting all drone videos from SD card."
files = os.listdir(SRC)
for f in files:
print "File: D:/VIDEO/"+f
print "Target dir: "+TRG
print "\n-----\n"
for f in files:
print "Processing "+f
newext = f[:f.find(".")]+".mp4"
print "VLC Command: \n"+"C:/Program Files/VideoLAN/VLC/vlc.exe "+f+" --avi-index="+str(AVI_INDEX).lower()+" --intf=dummy vcd://"\
" --sout=#transcode{vcodec=h264{cabac,loopfilter,keyint=10},deblock=0:0,vb=2400,vfilter=hqdn3d,fps=60,scale=Auto,width=720,height=480,acodec=none}:std{access=file,mux-video=mjpeg,dst=\""+TRG+newext+"\"}"\
" --no-qt-error-dialogs "+" vlc://quit"
subprocess.call(["C:/Program Files/VideoLAN/VLC/vlc.exe", f, "--avi-index="+str(AVI_INDEX).lower(), "--intf=dummy vcd://",
"--sout=#transcode{vcodec=h264{cabac,loopfilter,keyint=10},deblock=0:0,vb=2400,vfilter=hqdn3d,fps=60,scale=Auto,width=720,height=480,acodec=none}:std{access=file,mux-video=mjpeg,dst=\""+TRG+newext+"\"}",
"--no-qt-error-dialogs", "vlc://quit"], cwd=SRC)
if SET_TIME:
stat = os.stat(SRC+f)
os.utime(TRG+newext, (stat[8], stat[9]))
print "Set modification time to "+str(stat[8])
if DELETE:
os.remove(SRC+f)
print "File removed from card."
print "File processed.\n"
print "All files processed."
Upvotes: 0