Loseless FFMPEG compression that supports windows media player - c++

I am trying to create a movie file (avi, mp4, etc as long as it support windows media player) from a sequence of png files using ffmpeg.I am using C++ "System("ffmpeg command")" to create the movie files once I create the png files (this shouldn't effect movie creation). I was able to create a .avi file using the following command,
ffmpeg.exe -r 30 -i frame_%7d.png test1.avi
Once you create the file it runs in windows media player but does not run in VLC. I have realized, it does lossy compression and the movie is not that high quality (quality decreases with frame rate). I want to have lossless compression (or no compression at all) but needs to be able to play in windows media player. So I tried the following commands,
ffmpeg.exe -framerate 30 -i frame_%7d.png -codec copy test2.avi
This file ran in VLC but didn't run in windows media player. Then I tried put in "-pix_fmt yuv420p" but still couldn't get it to run in windows media player.
ffmpeg.exe -framerate 30 -pix_fmt yuv420p -i frame_%7d.png -codec copy test2.avi
I have also tried using "ffv1" codec and it ran in VLC but not in windows media player
ffmpeg.exe -i frame_%7d.png -c:v ffv1 -qscale:v 0 test4.avi
So, how do I create a lossless movie file from a sequence of png files using ffmpeg that will run in windows media player?

Related

how to use a video stream as input in python/opencv programme

I am able to stream and receive webcam feed in two terminal via udp
command for streaming:
ffmpeg -i /dev/video0 -b 50k -r 20 -s 858x500 -f mpegts udp://127.0.0.1:2000
command for recieving:
ffplay udp://127.0.0.1:2000
Now i have to use this received video stream as input in python/opencv how can i do that.
I will be doing this using rtp and rstp as well.
But in case of rtsp it is essential to initiate the receiving terminal, but if I do that then port will become busy and my program will not be able to take the feed.How could it be resolved.
I am currently using opencv 2.4.13, python 2.7 in ubuntu 14.04
Check this tutorial, and use cv2.VideoCapture("udp://127.0.0.1:2000"). You will need to build opencv with FFmpeg so that it works.

I am using ffmpeg library in my program to record video and audio

I want to record video coming from a camcorder to a wmv file. I am using ffmpeg libraries and I have it saving the video as an "avi" file. However the requirements of the project is to output a wmv file. Can anyone help me discover how to set up the video and audio codecs?
You can configure for video codec as MPEG4 and audio codec as Windows media audio 2 to get the .wmv file format.
ffmpeg -i input.mp4 -b:v 2M -vcodec msmpeg4 -acodec wmav2 output.wmv
When you use ffmpeg to generate WMV format the output video quality may be slightly less than other format. So it is better to set the qscale value to get better quality video.

FFMPEG command for audio file streaming

I am trying to stream an audio file in mp3 format using the FFMPEG library to a remote computer, located on the same LAN as the sender. The command i used to stream at the sender is given below:
ffmpeg -re -f mp3 -i sender.mp3 -ar 8000 -f mulaw -f rtp rtp://10.14.35.23:1234
I got the below command on FFMPEG documentation page that generates audio and streams it to port number 1234 on remote computer
ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://10.14.35.23:1234
I thought i had made relevant changes to this so that the mp3 streaming command will work, but only to know encounter the error which reads
"Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"
Can anyone tell me what is the wrong parameter here and how to rectify it?
I could figure out the way to stream an audio file using FFMPEG. The command for the same is given below:
ffmpeg -re -f mp3 -i sender.mp3 -acodec libmp3lame -ab 128k -ac 2 -ar 44100 -f rtp rtp://10.14.35.23
Here the audio file 'sender.mp3' is located in the same folder as ffmpeg.exe. In case of a different folder, the full path should be mentioned in the command.

youtube-dl command saves as flv and not mp3

So below is my command that I am running. It should be converting it to mp3 but it still exports as a video in flv. What am I doing wrong?
$cmd = '/usr/local/bin/youtube-dl -o "%(title)s.%(ext)s" -x --audio-format mp3 -- '.escapeshellarg($url).'';
youtube-dl will download the video before converting it. Most likely, you don't have ffprobe or ffmpeg installed. Make sure both programs are available (i.e. you get a sensible output for ffprobe --help and ffmpeg --help).
You can directly download the .mp3 file from the youtube site.
For e.g in ubuntu terminal youtube-dl youtube.com/watch?v=qn6CMz18lkQ -f 141 .Most probably 141 is the .mp3 file format code for better quality.

how to convert and play a .h263 file?

I am working on ubuntu. I have a file.h263 and I don't know how to play it. I've tried ffmpeg -f msg0001.h263 -i file.avi but it didn;t work. Need some help please. I want to convert file.h263 in .avi or mp2 in order to play the file in an android phone. Got any advices? It would be best to have a c++ code. but i didn't find any example, nothing at all.
Please help. If you have a piece of code that does this I would appreciate.
Thx
You should be able to play H263 file and convert it to AVI as the following:
ffplay -i file.h263
ffmpeg -i file.h263 file.avi
For android playback you can keep video stream in H.263 and convert the file to 3GPP (.3gp) or MPEG-4 file format or change file format and codec to MPEG-4 and H.264. For example:
ffmpeg -i file.h263 -vcodec copy -f 3gp file-h263.3gp
ffmpeg -i file.h263 -vcodec h264 -f mp4 file-h264.mp4
See Android supported media formats for more information.
.h263 is old yet great format, and if your software player uses HW accelration to play video that majority of old videocards (including Nvidia, ATI) will provide you HW accelration for video playback for .h263 format files... now various use .h264 format... thus try to convert videos to .h264 format instead of avi...
i think what you are facing is a extension delima .... try renaming it to MP4, then various player will play it without problems..
you can also use vlc.. one of the best video players ever...
Beside GStreamer can play H263 files , and with gstreamer pipelines you can convert various format on flies...
though i usually use Handbreak to convert video files /DVD's, and it is available on windows, Mac as well as on linux ....
P.S. in Gstreamer, you might need to install plugins, install all 2... good, bad and ugly plugin. i am not sure in which .h263 comes in, but must be in one of these three......