Export to mp4 via movie file out top?

Is it possible to export to mp4 via the moviefileout top?
No matter what codec I select (even with h.264) I can only export to mov and I don’t see any option to export to mp4?
On the wiki it says you can export to mp4 https://docs.derivative.ca/Movie_File_Out_TOP.
Do I have to change any setting? Do I have to install a codec (I’m on Win 10)?

If I am not completely mistaken you can just rename the file to mp4. Quicktime is just a container and doesn’t say much about the codec used. Note however, that the h.264 and h.265 are realtime codecs which will only work when using a fairly recent NVIDIA GPU.

1 Like

Yep, that’s correct. You can just change the extension to write to a different container format. Note that .mp4 doesn’t support MP3 audio though, so you can’t write out MP3 audio to that file if you need a .mp4 container.

Hi Malcolm, thanks this is helpful for my current project. But is there a way to have it record directly to a .mp4 without a manual filename change afterwards? When i change the extension in the moviefileout top to test.mp4 the files are unreadable, zero kb in filesize. I’m just trying to eliminate as many manual processes as possible and have it natively result in .mp4 files.

1 Like

I have also been looking for an answer to this for a while. Even when changing the file names the files don’t seem as compatible with everything as mp4s straight out from Adobe Media Encoder.

I had the same problem for an installation (I needed .mp4 as to read it directly on web page) and yes, changing name is not changing the encapsulation.
i made a python script, using subprocess module (thank you Matthew Ragan!) with ffmpeg python library and the mp4 obtained was perfect

@jacqueshoepffner would you be so kind to share an example of the script? is it within Touch?

Hello,
Old project… But I found some elements.
The system was working fine on Windows. I tried for another installation to use it on macOs (M1, Monterey) and I was unable to run it.
On this occasion I was using remote desktop and command line ffmpeg to run each night the transcoding and the send to ftp…

External Python script to transcode mov to mp4 (transcodeVideo.py)

from ffmpy import FFmpeg

from pythonosc.udp_client import SimpleUDPClient
ip = "127.0.0.1"
port = 11001
client = SimpleUDPClient(ip, port)
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-p','--pat', default='F:/captures/21-11-20/20h.mov')
parser.add_argument('-t','--tar', default='F:/captures/21-11-20/20h.mp4')
args = parser.parse_args()
pat = args.pat
tar = args.tar
client.send_message("/path", pat)
client.send_message("/target", tar)
ff = FFmpeg(inputs={pat:None},outputs={tar:'-c:a mp2 -c:v h264'})
ff.run()

External Python script to load files to FTP ( sendFtp04.py)

import pysftp

from pythonosc.udp_client import SimpleUDPClient
ip = "127.0.0.1"
port = 11000
client = SimpleUDPClient(ip, port)
#client.send_message("/test", 200)

from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-p','--pat', default='F:/captures/21-11-21/12h.mp4')
parser.add_argument('-t','--tar', default='/lamp0/web/vhosts/www.mutationcinema.fr/htdocs/21-11-21/12h.mp4')
args = parser.parse_args()
pat = args.pat
tar = args.tar
#client.send_message("/path", pat)
#client.send_message("/target", tar)

myHostname = "sftp.xxxxxxx.net"
myUsername = "xxxxxx"
myPassword = "xxxxxxxxxxx"


with pysftp.Connection(host=myHostname, username=myUsername, password=myPassword) as sftp:
    client.send_message("/message", "Connection succesfully established ... ")
    client.send_message("/path", pat)
    client.send_message("/target", tar)
    sftp.put(pat, tar)

The transcode subprocess

import subprocess
# search data in table
path = op('lastRecord')[1, 'path']
# add args tags
p = "-p="+str(path)
# list of args
my_args = [p]
# python script address
cmd_python_script = '{}/transcodeVideo.py'.format(project.folder)
# add args
command_list = ['python', cmd_python_script] + my_args
# create python subprocess
p=subprocess.Popen(command_list, shell = True)
# store the process ref
me.store('process', p)

the send FTP subprocess

import subprocess
# search data in table
path = op('forSftp')[1, 'path']
target = op('forSftp')[1, 'target']
# add args tags
pat = "-p="+str(path)
tar = "-t="+str(target)
# list of args
my_args = [pat,tar]
# python script address
cmd_python_script = '{}/sendFtp04.py'.format(project.folder)
# add args
command_list = ['python', cmd_python_script] + my_args
# create python subprocess
p=subprocess.Popen(command_list, shell = True)
# store the process ref
me.store('process', p)

I’ve just tested and if I change the filename in the movie file out before I record, it records a .mp4 just fine. Do you not get the same results? Note that .mp4 does not support all audio codecs though, such as MP3. You can record ALAC or Vorbis into it though.

Hi Malcolm, thank you! It works!

I had to omit me.fileSuffix and instead append the ‘.mp4’ in quotations and saves me any need to postprocess/rename manually.

I noticed when i omit me.fileSuffix and use .mp4 I no longer get incrementing file outputs, it just overwrites. Is there a way to do a unique Suffix but retain the .mp4 file extension?

without having filename.8.mov.mp4 as a result each time? which is of course confusing to users.

Hi jreodica,
you will need to create a new filename for each export.
Usually keeping a count number that increments each time you hit record in the moviefileout.
There’s many ways to do that, python, pure op…
Attached is an idea, maybe it inspires you. It is a small script that increments a constantCHOP value every time is run.
CountIncrement.toe (4.1 KB)

Hi Malcolm :slight_smile:

I’m trying in a M1 Mac:
just changing the extension to .mp4 and choosing vorbis for audio: file is created, it plays correctly in VLC but no audio on Quicktime or Safari. Playing it back in TD is very distorted.
Are there plans to implement VideoToolbox for Mac?
Or maybe a way to tell the internal ffmpeg in MovieFileOut to use it?
Capture in mov and then use Jacques’ subprocess idea would work, but I need to spit files really quick so I would prefer a faster method. Any ideas?

1 Like

@VanTa thanks van, ok yes indeed I’ll do another increment solution. Was just curious if there was a way to modify me.fileSuffix without the dependence on only .mov’s, perhaps me.fileSuffixMp4 or similar.

You can just do this
‘Foldername/filename’ + str(me.fileSuffix).replace(‘.mov’,‘.mp4’)

In the upcoming 2023.30000 series (or 2024.20000 likely by the time it’s out), there is a new ‘Movie Container’ parameter in the Movie File Out TOP which makes this easier to control.

2 Likes