The length is decreased on overwriting an mp3 file using FFmpeg command - audio

I am trying to compress an audio file and I use -y command to overwrite the existing file. But problem is that that command decreases the duration of the audio file.
I am using the following command:
ffmpeg -y -i D:\audio\Blues.mp3 -ab 64 D:\audio\Blues.mp3
Is there any way to resolve this within ffmpeg? Thanks.

You can't read from a file and write to it at the same time with FFmpeg.
Write to a different file, then delete the original afterwards.

Related

How to recover corrupted MP4

After moving some mp4 from computer to USB stick, I discovered that my mp4 are corrupted. I guess USB stick is guilty.
However I would like to recover those MP4 files and I tried ffmpeg but without any success.
As I work under Linux, I tried:
ffmpeg -i corrupted_video_file.mp4 -c copy fixed_video_file.mp4
Is there another way to fix corrupted mp4 files or any other tool ?
thx

batch conversion from .h264 to .avi using ffmpeg [duplicate]

This question already has answers here:
How do you convert an entire directory with ffmpeg?
(34 answers)
Closed 2 years ago.
I am completing a project in which I have mountains of .h264 video files that all need to be converted into good quality .avi files. They need to be .avi because I'm using DeepLabCut on them after.
I have been able to do this file by file with the code:
ffmpeg -i practicevid_5.h264 -q:v 6 practicevid_5_2.avi
However, I would ideally like to be able to convert an entire folder of these files to save time. Please let me know if you can help out with this.
If you are using bash:
cd /the/dir/the/h264/videos/are/in
for input in *.h264; do ffmpeg -i $input -q:v 6 ${input/.h264/_2.avi}; done
In Windows default shell:
for %%input in (*.h264) do ffmpeg %%input -q:v 6 %input:.h264=_2.avi%
Couldn't test the windows sample, as i do not have a windows machine !

Monitoring directory changes with iwatch - getting new file's name not the full path?

Im using iwatch to monitor changes in the directory - as soon as new video file is added to the directory I grab that file and using ffmpeg add overlay sound to it. Here is the script:
iwatch -e close_write -c "/root/bin/ffmpeg -i %f -i /var/www/video/sound.mp3 -map 0 -map 1 -codec copy -shortest /var/www/new/video/${%f:15}" /var/www/video
But I have a problem. I move newly created file to a different directory and I need to save it with the same file name, but iwatch has only %f variable which returns full path. Knowing that the first part of the path will always be "/var/www/video/" , I can use ${%f:15} to get substring with the file name.
But the script below doesn't work - bash says "bad substitution". So the problem is here - when I try to move the file to the new directory:
/var/www/new/video/${%f:15}
What is correct syntax, way to achieve my goal?
You can use the output of the basename command:
/var/www/new/video/`basename %f`

converting a .wma to .flac using PHP? possible?

I have a linux server, I am looking to convert a .wma file to .flac file 16k
Is there a way I can do this using a PHP Script to control the server?
I was thinking .wma to .wav then .flac would be easier, but not sure how...
Any help is greately appreciated.
You can invoke the command line through PHP so that it just works as a safe interface to remote users.
Keeping that in mind you can use the ffmpeg library to go right from .wma to .flac using:
ffmpeg -i sample.wma -acodec flac -aq 100 sample.flac
You'll want to have something to manage file names and getting/serving the files, etc but that doesn't seem to be the hurdle in this case.

windows SOX MP4/FFMPEG support

i'm trying to use SOX to cut certain mp3s, convert them to different formats and add fade in-out to the files.
It works fine with mp3 to mp3 but when i try to convert it from an MP3 to an m4r i get the error: "sox FAIL formats: no handler for file extension `m4r'".
I'm using SOX in windows so how can i install the ffmpeg package on top of the SOX so it knows waht to do with the m4r format?
on the same machine i can use ffmpeg to convert from mp3 to m4r just fine. It sucks that ffmpeg doesn't offer FADE for audio.
You may download and install ffmpeg library for audacity and then copy avcodec-52.dll avformat-52.dll avutil-50.dll swscale-0.dll to sox installation directory. Thus you can use sox as :
sox -t ffmpeg youFile.wma yourFile.wav

Resources