Converting .mp4 to .264 using FFmpeg

3

I am completely new to FFmpeg and am trying to convert my test.mp4 to (it has to be specifically) a .h264 file.

I have tried the following in Terminal:

ffmpeg -i test.mp4 -c:v libx264 test.h264

but get the following back: command not found

I tried directing it to my desktop as followed:

~/Bureaublad/media$ ./ffmpeg -i test.mp4 -c:v libx264 test.h264

But then got back: No such file or directory

Can someone please help me out?

Amy

Posted 2016-10-29T14:04:12.053

Reputation: 31

There is no such thing as a .h264 file. Do you perhaps want the raw H264 data stream? What’s the output of ffprobe test.mp4? It could already contain the desired data, you’d just have to demux it. // Also, what operating system are you using? You should install ffmpeg properly via its package manager, if possible. – Daniel B – 2016-10-29T14:38:04.733

I haven't heard of a .h264 either, but I'm looking at one atm, which is a video that can't be opened by OS but can be played via the Raspberry. Only this type can be played by the Raspberry (perhaps this is the Raw h264 data stream you are talking about?) Operating system: OS X El Capitan 10.11.6. – Amy – 2016-10-29T16:45:21.160

On OS X/macOS, I recommend using Homebrew to install ffmpeg. Also, what command are you using on the Pi to play the movie?

– Daniel B – 2016-10-29T17:39:46.883

Oh my, I thought it would be so easy, haha! The thing is, I have no idea. I used it from someone who already arranged/programmed a video loop thing etc on the SD card. The only thing I had to do was to convert my video to .h624. The video on the USB atm is in this format and works obviously as it's playing right now. I shall have a look right now and see what I can find of the SD card. – Amy – 2016-10-29T18:09:04.650

Answers

3

try this: ffmpeg -i test.mp4 -an -vcodec libx264 -crf 23 test.h264

source: https://ffmpeg.org/pipermail/ffmpeg-user/2012-May/006647.html

Joe

Posted 2016-10-29T14:04:12.053

Reputation: 31

Thanks for replying. Unfortunately I get the same error back! .. Have I perhaps forgotten something major? – Amy – 2016-10-29T15:57:37.890

which error are you getting? "no such file or directory" or "command not found"? – Joe – 2016-10-29T15:59:15.140

"Command not found" – Amy – 2016-10-29T16:35:09.483

are you using Windows or Linux? – Joe – 2016-10-29T17:03:57.350

I am using MacOs – Amy – 2016-10-29T17:19:19.553

I never used MacOs, it seems you didn't install ffmpeg the right way. – Joe – 2016-10-29T18:08:32.973

2

Your issues have nothing to do with converting video and everything to do with the location of the ffmpeg binary.

I assumed you downloaded ffmpeg from evermeet.cx. That's fine, and I often provide that link to other macOS users to get a recent version.

Downloading the .dmg link may be easier than the .7z, because macOS can extract the .dmg without third-party tools.

Once extracted you can move the ffmpeg file into /usr/local/bin (it will ask for a password to do so). You can then just run the ffmpeg command from any directory.

Alternatively, you can move it wherever you want, but you'll have to provide the full path to the location, such as ~/Downloads/ffmpeg -i ... or first navigate to the directory that it is in and then run ./ffmpeg -i ... (note the ./ prefix).

llogan

Posted 2016-10-29T14:04:12.053

Reputation: 31 929

Finder can't find such /usr/local/bin! I tried your alternative option ~/Downloads/ffmpeg -i ...

But rather did it like this: ~/Bureaublad/ffmpeg -i test.mp4 -c:v libx264 test.h264

? – Amy – 2016-10-29T18:56:16.190

@Amy You're probably using Finder which is too dumbed down for this type of use (it probably hides non-typical directories). Use Terminal. If you must use Finder then press Command+Shift+G, then enter /usr/local/bin. Did the alternative location work for you? You showed your command but didn't say if it worked. – llogan – 2016-10-29T20:21:02.197

Ok, so! It seemed I didn't install ffmpeg properly, which I have done now. (through homebrew and terminal) which seems to work. I then tried to use ffmpeg -i test.mp4 -c:v libx264 test.h264 in terminal and it still didn't work. However this time it seems to run ffmpeg first and then give me the (no such file or directory!) error. So I'm one step further, haha. Does this mean I'm doing something wrong in terms of file names? (swapping them for example?) – Amy – 2016-10-30T10:26:47.550

O, and to answer your previous question: I haven't tried this yet, no. Should I do this anyway? (I don't know how in this case, for I installed ffmpeg through Homebrew and terminal and therefor have not got a file to extract :) ) – Amy – 2016-10-30T11:12:04.573

@Amy You have to provide the correct path to the input file in your ffmpeg command. As is, your ffmpeg command would expect test.mp4 to be in the current directory. As for the "alternative location", no, you don't need to do any of that since you apparently now already got ffmpeg installed via homebrew. – llogan – 2016-10-30T19:48:21.197