When using youtube-dl with ffmpeg, what merge extension(mkv/mp4) can get best sound quality - audio

I use youtube-dl -F to display all video/audio list, and choose best video/audio source myself.
Then I use youtube-dl -f [video code]+[audio code] to download and automatically merge them.
As question title, when I use --merge-output-format, what output extension should be chosen then I can get a file with best sound quality. Is mkv? Or is most suitable merge extension related to the extension of video/audio source?
By the way, my using player is PotPlayer.

It doesn't really matter
MKV or MP4 can accept all of the video and audio formats currently available on YouTube (H.264 or VP9 or AV1 video, AAC or Opus audio). Exception is if you are using a really old ffmpeg.
youtube-dl is just re-muxing the video and audio with --merge-output-format. Like a copy and paste. There is no re-encoding so there is no generation loss.
If you choose an incompatible output format, then it will fail with ERROR: Stream #1:0 -> #0:1 (copy) or similar.
Use whichever you prefer or works best for your player/device.

Related

Incorrect values for song length (duration) in Mp3tag after ffmpeg FLAC to MP3 conversion

The problem
As per this post, I use the following command to convert a flac file to mp3 while keeping all metadata:
ffmpeg -i input.flac -ab 320k -map_metadata 0 -id3v2_version 3 output.mp3
When inspecting the converted mp3 file by right-clicking it, going to properties and then details, everything looks in order. The value for "Length" is correct.
When inspecting the converted mp3 file with Mp3tag, the value for "Length" is different. From my testing, the "Length" value is consistently about 28% of what it is supposed to be.
Normally, this isn't an issue. Most music players I use, read the correct length value, same as Windows. However, I've recently discovered that Spotify Mobile for some reason ignores the length value that can be seen in the Windows panel and uses the one that can be seen in Mp3tag.
I want to figure out what command I should use so that after the flac file has been converted to mp3, Mp3tag shows the correct length, and there by, Spotify Mobile reads the correct length as well.
What I have tried
1.
After converting the file to Mp3, I've tried reencoding the mp3 file into a... mp3 file using the following command:
ffmpeg -i original.mp3 -c:v copy -c:a mp3 -vn -ar 44100 -ac 2 -b:a 320k copy.mp3
As can be seen in the image above, this fixes the issue and the length is showing correctly in Mp3tag and in Spotify Mobile.
Issues with this: Reencoding reduces quality and I don't know how to combine the previous flac conversion command and this one into one line.
2.
I tried https://cloudconvert.com/flac-to-mp3 and it worked. The length is displayed correctly in Mp3tag. (What commands did they use on the server???)
Issues with this: I don't want to rely on a cloud service for conversion, I have a lot of files to convert and I'd prefer it to be done locally.
Some demo files
Here is a folder with a flac file, a bad mp3 file (wrong length) and a good mp3 file. It looks like if you preview the music in google drive, it also plays the wrong length for the bad mp3 (39s not 2m19s), while vlc, groove player, spotify (desktop not mobile) all play the correct full length (2m19s) for the bad mp3 file.
Folder: here's the link
It seems I had an outdated version of ffmpeg... (ffmpeg version git-2020-05-23-26b4509) I updated to the latest version and the issue went away. Learned my lesson the hard way.
Would still appreciate an explanation on why this was happening. I'm curious. Why were there two values for length?

exporting ogg videos from video slideshow (mp4) and audio (wav) using ffmpeg in python

I have tried to find a solution already, but just cannot make it work. I want to export an .ogg-video by combining a video slideshow (mp4) with an audio file (wav) by using ffmpeg in python. The audio is shorter than the video and should have an offset of 2000 milliseconds, so that it starts approximately in the middle of the video. The code that I tried is essentially this:
subprocess.call('ffmpeg.exe -itsoffset 0 -i slideshows/slideshow.mp4 -itsoffset 2000 -i sounds/audio.wav -codec:v libtheora -codec:a libvorbis output.ogg', shell= True)
FYI: I need to create a couple of different video formats from the video and audio input, so substituting the ogg with a different format is no option. I have already successfully created .mp4-video-files and .webm-video-files from the material, but need the .ogg in addition. Also, Power Point does not like any of the exported videos, maybe this might be relevant for finding the problem here (I also unsuccessfully tried to fix this issue).

Merge mp3 files without recode and make cue sheet pointing to individual tracks?

I have a lot audiobooks, each one is usually split into 20-60 files. It's not comfortable to navigate with audio players if I want to group them into some sets by genre (with [Album artist] ID3 tag set to "Various Artists").
Is there free windows or linux tool or set of tools, whose could do the following?
Merge the audiobook files to one mp3 without recoding
Carefully build correct CUE sheet with original ID3 tags pointing to former chapters inside new solid mp3 file.
You can easily join mp3 by simple concatenating them.
cat file1.mp3 file2.mp3 file3.mp3 file4.mp3 file5.mp3 > file-all.mp3
Tags can be extracted with ffprobe:
ffprobe file1.mp3
Cue sheets is text files, you can read about its format here:
https://en.wikipedia.org/wiki/Cue_sheet_(computing)
Since here questions related to programming, I will not post complete solution.
Don't use MP3, use Matroska (MKV). It supports all of these chapters and what not.
FFmpeg and mkvmerge are tools you can use for this. Use -c:a copy and the audio won't be re-encoded. (MKV support MP3 as a codec.)

How to combine a .MP4 video with a .WAV audio to create a new .MP4 video using ffmpeg from command line arguments?

I want to merge a .WAV audio file with a .MP4 video file to create a new .MP4 video file.
And i am currently using the following codes to do that :
ffmpeg -i input_vid.mp4 -i input_audio.wav -vcodec copy -acodec copy output.mp4
But it is only creating output.mp4 file but no videos embedded with that means if i am playing that output.mp4 file then nothing is playing.
And i don't know where i am doing wrong so that it is creating like this.
I know this type of questions already asked by may persons but that didn't help me much so if anybody can find where i am doing wrong or how to solve this problem please help me to solve my problem.
Remove -acodec copy. That option forces a direct copy of the WAV bytes into MP4's audio track.
A valid audio MP4 must contain an MPEG audio track (mp3 or aac). Once you remove -acodec copy then FFmpeg will still copy the video (picture) part but also automatically encode from WAV to AAC for you. AAC is the standar audio codec inside MP4 files (can add MP3 too since all 3 formats are compatible MPEG files).

MPlayer — changing brightness/ contrast to video file and save output

I need to change brightness and contrast to a video permanently, I tried this:
mplayer -vf eq=50:50 a.mp4 -dumpstream
mv stream.dump b.mp4
But it saves as a file which look likes the original file. Any idea?
You want to use mencoder to transcode the video to apply the video filter eq=50:50. When you use -dumpstream with mplayer, it simply dumps the stream while the video filter is being applied to playback. Take a look at the mencoder options, but you'll need to chose a video codec and some options for that codec (like bitrate). Then you can apply the brightness and contrast filter.

Resources