.TS file to .mp3 using FFMPEG in windows phone - c#

Hi I am using ffmpeg for windows phone which was found here. With this I am trying to convert a .ts file to .mp3 file but the command that I am using is not working for this type of conversion, I have also noted that it works for certain other format conversions such as ts to wma, ts to ogg e.t.c . The commands that I have tried are
-i sourcewithfullpath.ts destinationwithfullpath.mp3
-i sourcewithfullpath.ts
-f destinationwithfullpath.mp3
-i sourcewithfullpath.ts
-c:a libmp3lame destinationwithfullpath.mp3
-i sourcewithfullpath.ts
-acodec mp3 destinationwithfullpath.mp3
most of these gave me an AccessViolationException while calling ffmpeg.Run()
Any help is appreciated.

I think Mulvya is right MP3 encoding is not included in this FFMPEG build but I figured out another way which does not satisfy the exact need still a good option
-i sourcewithfullpath.ts
-f destinationwithfullpath.mp2
FFMPEG does support mp2 format, the file was converted to mp2 audio and renamed to mp3, it is playable in the windows phone. Please note that the compression ratio of the mp2 format is not that good compared to mp3 format which means that the output file resulted in a much greater size which was almost double.

Related

Convert mp4 video to m3u8 format with C# ffmpack

I can convert the file with the extension mp4 in my hand from the code line related to PowerShell to m3u8 format.
ffmpeg -i inputVideo.mp4 -profile:v baseline -level 3.0 -s 960x540 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls outputVideo.m3u8
But I want to automate this process using C#. I did as written in the document on Microsoft's site, but I could not add the relevant parameters. Has anyone done anything like this before? or how can I follow a path.
https://learn.microsoft.com/en-us/powershell/scripting/developer/hosting/adding-and-invoking-commands?view=powershell-7&fbclid=IwAR05LjyIa8Yv5YFVh-HcbWH5YqmaeQKJ8LzaGsCQxjvJBIepdLAx7E39y7Y

How can I convert a regular WAV file to a 4bit WAV file using ffmpeg?

I have tried something along the lines of
C:\ffmpeg\ffmpeg -i "Blip_Select2.wav" -c:a wav -sample_fmt u8 "Blip_Select2_8bit.wav"
but I cannot figure out how to access a 4bit conversion.
I am using the audio for a c# project, 4 bit is sufficient and I prefer wav so I won't have to distribute a possibly restricted usage decoder with my files.
Just a heads up that -b 4 with sox seems to use MS ADPCM codec which encodes the difference between samples using 4 bits. If you want to produce a similar result using ffmpeg you can use:
ffmpeg -i sound.wav -codec:a adpcm_ms -f wav sound_4bit.wav
Ok, so I did manage to find a solution for this. It's a great command line utility similar to ffmpeg, called (Sound eXchange) SoX. It can be found here:
http://sox.sourceforge.net/
The command line that achieves converting to 4 bit wav is this:
sox "sound.wav" -b 4 "sound_4bit.wav"
It works perfectly and I did not notice any quality drop as the sampling rate is still 44100, while the size drops to 1/4.
An important note. This works well only if your audio is clean and not recorded too loud, such as correctly recorded voice speech (this is what I am using it for), but also works for music as long as it's not too loud.

How to handle differing .mp4 file types from different sources?

If I take a .mp4 recorded on my mobile (Samsung S5) and pass it through FFmpeg with the below command, the output file (fileX.avi) is a greyscale bitmap uncompressed video file.
The offset values in fileX.avi (output from FFmpeg) to allow me to locate the video frame data are always 5680 bytes for the file header.
And 62 bytes for the inter frame header.
The data is uncompressed RGB24 so i can easily calculate the size of a video frame from height x width x 3.
So my C# application can access the video frames in fileX.avi always at these above offsets.
(This works great).
My FFmpeg Command is:
ffmpeg.exe -i source.mp4 -b 1150 -r 20.97 -g 120 -an -vf format=gray -f rawvideo -pixfmt gray -s 384x216 -vcodec rawvideo -y fileX.avi
However... I recently took an .mp4 file from a different source (produced by Power Director 14 instead of direct from my mobile phone) and used this as the input source.mp4. But now the structure of fileX.avi differs as the offset values of 5680 + 62 bytes from the start in fileX.avi do not land me at the start of the video data frames.
There seems to be different file formats for .mp4 - and obviously if there are my crude offset approach will not work for them all. I suspected at the time I wrote the code my method was all too easy a solution!
So can anyone advise on the approach I should take now? Should I check the original .mp4 or the output file (fileX.avi) to determine a "file type" to which I can determine the different offsets?
At the very least I need to be able to identify the "type" of .mp4 file that works so I can declare the type that will work with my software.

Converting large (4gb) avi file to mpeg or mp4 format using C#

I have successfully converted avi files to Mpeg using NREco converter http://www.nrecosite.com/video_converter_net.aspx
But, the length (duration) of the converted video is never greater than 2mins, 35 secs.
I tried using ffmpeg command line utility (https://www.ffmpeg.org/download.html or http://ffmpeg.zeranoe.com/builds/ ffmpeg 64 bit static for windows) but the length was always less than or equal to 2mins, 35 seconds.
How to increase the duration of the ffmpeg converted video?
I tried the -t command but couldn't increase the length (duration) of the converted video. Original video is a 14mins 5 sec avi file.
ffmpeg -i inputAVIfilename outputMPEGfilename
ffmpeg -i inputAVIfilename -t 90000 outputMPEGfilename
The video file has only bitmap images. No sound tracks are required.
Please note that my dll would be used with both windows & web applications.
Converting of videos of from one format to other can be done either using software or hardware. In your case you are using ffmpeg which is software based solution. Generally speaking software based solutions are a lot slower, inefficient and has many operating system restrain, and I am suspecting you have reached that limit.
I suggest that you use cloud based solution such as Azure Media service or Elementals.

Optimum encoding standard for flowplayer to play mp4

I'm using flow player 3.1.1 for streaming videos to my browser.The videos are uploaded by the users and they may upload different formats. What will be solution to stream the videos as mp4 , what ever be the format they upload. I'm currently using ffmpeg commands.
ffmpeg -i "InputFile.mp4" -sameq -vcodec libx264 -r 35 -acodec libfaac -y "OutputFile.mp4"
But video files of more size(say 100mb) are taking a minute more for laoding in to the flowplayer and buffering. I think the problem with my encoding.
Welcome your valuable Suggestions!!!
The problem come from metadata. ffmpeg put this data at the end of file, for a progressive download you must move this data at the begininng. You can use MP4Box or qt-faststart after ffmpeg process.
MP4Box -inter 1000 file.mp4 or qt-faststart in.mp4 out.mp4

Categories