I have learned through Google, that to change video containers without losing quality I can run the following command:
ffmpeg -i videofile.mkv -codec copy videofile.mp4
This has worked great for a number of video files I have. However, I am having an issue with three of them (1 mkv file and 2 avi files). When I run that command against them, the video is there, but there is no sound. There is sound in the original video file.
Any ideas how to put the video in a new container while retaining the audio track?
Thanks. Brian
The .mp4 container is not compatible with the audio codecs of the problem files. This should be evident from the logs. So the audio channels of the problem files have to be transcoded to something allowed in .mp4, eg. aac:
ffmpeg -i videofile.mkv -c:v copy -c:a aac videofile.mp4
Maybe the container mp4 it doesn’t compatible whith codec of your input video mkv and avi
By the way, you can try
ffmpeg -i videofile.mkv -c:v copy -c:a copy videofile.mp4
Check this documentation.
https://en.m.wikipedia.org/wiki/Comparison_of_video_codecs
https://trac.ffmpeg.org/wiki/Map
Related
I am using ffmpeg to create an hls stream. The source is an mkv with multiple audio tracks. I have tried using -map to specify the audio stream as well. I also found that when I point ffmpeg to any other audio stream in the file it works. It's just the first audio stream that does not. At one point I replaced -c copy with -acodec aac -ac 6 on the first stream and I got sound which is great but I am only looking to copy the stream and not re-encode it. The next thing I tried was using other mkv videos I have. All are reflecting the same issue. The mkv's by itself play both audio and video fine in VLC. When playing the output.m3u8 in VLC the option to choose different audio tracks is greyed out. Here is the command I'm using:
ffmpeg -i "./video.mkv" -ss 00:00:00 -t 00:00:30 -c copy -f hls "output.m3u8"
I want the audio of my hls stream to reflect that of the mkv source:
Although what I get returned from the command above gives me no sound and shows me this in mediaInfo:
I've aslo noticed that hls does not support pcm. Is it possible dash could work with this stream because it is pcm?
HLS segments can be either MPEG-TS or fragmented MP4. Neither officially support PCM audio, so you'll have to convert it.
DASH uses fragmented MP4 as segment format.
A have a hand full of .avi files which I would like to convert to .mp4. Cobbling together everything I have found on the Internet, I end up with something like this:
ffmpeg -i something.avi -c:v copy -c:a copy something.mp4
What I get is playable on VLC player, but, of course, that will play anything I through at it. However, I cannot play it using QuickLook in the Finder or with the QuickTime player.
In some cases I get video, but no sound. In some other cases I get garbled video.
I am guessing that the audio or video codec inside the .avi file is incompatible with MacOS, and that the copy instruction above is not appropriate. In that case I guess that I would actually need to reencode the audio or video.
If this sounds incoherent, I admit I know very little about video files.
What would be the best settings to try to produce an MP4 which works natively on MacOS?
"What would be the best settings to try to produce an MP4 which works natively on MacOS?"
Check this useful guide.
You can try the below command as a starting point (audio track will / should be auto-detected & converted):
ffmpeg -i something.avi -c:v libx264 -crf 22 -pix_fmt yuv420p something.mp4
I loop over some files and convert them with ffmpeg. I provide -vcodec h264. When the input video already is encoded with that codec: will the video stream be copied? How to make sure it's not reencoded in that case? Is it what -sameq was used previously?
You need to use -c:v copy if you want the raw H.264 stream to be passed on without re-encoding:
ffmpeg -i myh264file.mp4 -c:v copy -c:a copy myh264output.mp4
-c:a copy will also copy the audio
-c copy will copy both audio and video as in:
ffmpeg -i myh264file.mp4 -c copy myh264output.mp4
Detecting H.264 streams is not straight forward. You will need to code this.
For the -sameq settings please refer to this statement.
I would recommend upgrading to a recent version of ffmpeg if it is not already done as -vcodec is not used anymore, now it is -c:v.
The documentation on ffmpeg could help you.
I've got a problem with streaming audio on my website. I thought I could put the MP3 file inside an MP4 container with h264 codec, so I can use pseudo-streaming ability of mp4 codec.
The code I'm using to convert my files is:
ffmpeg -i 1.mp3 -y -b:a 32K -vn 1.mp4
Pseudo-streaming (seeking in not-loaded parts of media) now works in HTML5 player but not in any Flash media players such as JWPlayer or FlowPlayer.
I've tested my files on both Apache server with h264 module enabled and Nginx with mod_mp4 enabled, but without any lucks.
I tried MP4Box, QTIndexSwapper and even creating a real video file by mixing of an image loop and my audio file.
ffmpeg -y -i joojoo.png -i 2.mp3 -vcodec mjpeg havij.mp4
MP4Box -add havij.mp4 -isma havij_new.mp4
What am I doing wrong? What can I do to make it work?
You have to hint the file. Check out mp4box -hint
We're converting a bunch of .RM files to .MP4 and wondered what the best way is. Here are the details:
Convert the files to H.264.
Keep the filename but add .mp4 to the end.
Also extract a JPG image of the video at about 5 seconds in for each file and name it the original filename + .jpg.
This is on a Windows system. Is there a free tool you recommend for this? Thank you.
ffmpeg is pretty much the defacto standard app for transcoding video.
http://www.ffmpeg.org/
Convert to h264/mp4:
ffmpeg.exe -i inputFile.rm -vcodec libx264 -s 320x240 -acodec libfaac outputFile.mp4