Skip to content

Instantly share code, notes, and snippets.

@jdye64
Created June 23, 2015 03:59
  • Star 12 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jdye64/ca07e01ff3d8e93210c3 to your computer and use it in GitHub Desktop.
Convert .dav files in current directory to .mp4
#!/usr/bin/python
print "Converting all of the .dav files in this current directory into .mp4 files using ffmpeg"
import os
from subprocess import call
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
ext = f.split(".")[-1]
if ext == "dav" or ext == "DAV":
mp4Name = f.replace("dav", "mp4")
print "Converting: " + f
call(['ffmpeg', '-y', '-i', f, "-vcodec", "libx264", "-crf", "24", mp4Name])
print "Converted: " + f
@lgg
Copy link

lgg commented Nov 13, 2019

ffmpeg dav to mp4
clear ffmpeg command: ffmpeg -y -i file.dav -vcodec libx264 -crf 24 file.mp4

@AmrHash
Copy link

AmrHash commented Jul 2, 2021

it's not working as intended even after editing to fit python

@lgg
Copy link

lgg commented Jul 2, 2021

@AmrHash did you try to manually convert a single file with pure ffmpeg command? ffmpeg -y -i file.dav -vcodec libx264 -crf 24 file.mp4

@linuxqali
Copy link

ffmpeg dav to mp4 clear ffmpeg command: ffmpeg -y -i file.dav -vcodec libx264 -crf 24 file.mp4

it`s work for me.thanks.

@ram1123
Copy link

ram1123 commented Jul 23, 2023

It works for me too. Thank you.

Just that now, the print statement should be updated to python3 :)

I updated here: https://gist.github.com/ram1123/bf8921377949c3b19f82ce14e1ea95a0/revisions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment