You are not logged in.

#1 2015-04-13 14:40:57

psjbeisler
Member
From: Pittsburgh
Registered: 2015-04-13
Posts: 10
Website

Ffmpeg question - best practice

I have a script i saved and have used for a while without any issues;

#!/bin/bash

for i in *.mkv
do
ffmpeg -i "$i" -acodec ac3 -vcodec copy "${i%.mkv}.mp4"
done

which gives me;

Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (ac3 (native) -> ac3 (native))

My question is, is it better for me to copy the audio instead and is AC3 -> AC3 going to give me an issue?
Sometimes i get AAC souce audio which is why i specify AC3

Offline

#2 2015-04-13 19:13:51

qubodup
Member
Registered: 2008-01-19
Posts: 66

Re: Ffmpeg question - best practice

AC3 is probably lossy, so you'll probably lose quality (and time re-encoding). You could check what the codec is:

codec=`ffprobe video.mkv 2>&1 >/dev/null |grep Stream.*Audio | sed -e 's/.*Audio: //' -e 's/[, ].*//'`
if [ $codec == "ac3" ]
then
echo copy ffmpeg with -c:a copy
else
echo encode ffmpeg with -c:a ac3
fi

In case you're doing this for YouTube: in my experience, mkv is just fine.

Offline

#3 2015-04-13 20:12:18

psjbeisler
Member
From: Pittsburgh
Registered: 2015-04-13
Posts: 10
Website

Re: Ffmpeg question - best practice

i stream all my videos and the Rpi , ps3 and android all seem to like the .mp4 container and the ac3 audio. but sounds like aside from just time, im not really losing much. just wasnt sure how ffmeg would handle encoding to the same format, figured it would be better to reencode it for the new container to make sure the time stamps were right and the audio lined up... that was the big thing.

Offline

#4 2015-04-15 09:34:23

Henrikx
Member
From: https://bbs.archlinux.de/
Registered: 2014-02-06
Posts: 22

Re: Ffmpeg question - best practice

You don´t need to reencode (Ac3 to AC3) becouse time stamps..

Try This:

ffmpeg -fflags genpts -i "Video.mkv" -acodec copy -vcodec copy "Video.mp4"

Offline

#5 2015-04-18 23:40:17

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: Ffmpeg question - best practice

psjbeisler wrote:

is AC3 -> AC3 going to give me an issue?

No, other than wasting time re-encoding. You probably wouldn't notice a difference in quality. If something weird happens, like a change in channel layout, then it should be reported upstream.

psjbeisler wrote:

Sometimes i get AAC souce audio which is why i specify AC3

AAC is the most common audio format for MP4 container, so stream copying it would be the best option.

qubodup wrote:

You could check what the codec is:

codec=`ffprobe video.mkv 2>&1 >/dev/null |grep Stream.*Audio | sed -e 's/.*Audio: //' -e 's/[, ].*//'`

You can avoid the redirection, grep, and sed (see FFmpeg Wiki: FFprobe Tips).

$ ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=nw=1:nk=1 input.mkv
aac

Note that only the first audio stream will be probed in this example. If there are others they will be ignored. Change "-select_streams a:0" to "-select_streams a" if you want to list all.

Last edited by DrZaius (2015-04-18 23:41:57)

Offline

#6 2015-04-18 23:47:07

psjbeisler
Member
From: Pittsburgh
Registered: 2015-04-13
Posts: 10
Website

Re: Ffmpeg question - best practice

DrZaius wrote:
psjbeisler wrote:

is AC3 -> AC3 going to give me an issue?

No, other than wasting time re-encoding. You probably wouldn't notice a difference in quality. If something weird happens, like a change in channel layout, then it should be reported upstream.

Thats pretty much what i was looking for.

Also i know there are some licensing issues of some kind with AC3, (Sony developed format wasn't it?) idk if that is the same with AAC (Apple maybe?) ...its been awhile since i played with audio formats but do more players handle AAC better than AC3. even in an mp4 container i thought i had issues w/ AAC audio. I thought like mkv, AAC had to be transcoded to play on some devices which i didnt think was the case w/ AC3.

Offline

#7 2015-04-19 00:03:01

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: Ffmpeg question - best practice

psjbeisler wrote:

Also i know there are some licensing issues of some kind with AC3, (Sony developed format wasn't it?) idk if that is the same with AAC (Apple maybe?)

Nobody cares about general users decoding and encoding for personal use. Don't let "licensing" FUD become a factor in your decision.

...its been awhile since i played with audio formats but do more players handle AAC better than AC3.

Probably. It's much more common.

psjbeisler wrote:

even in an mp4 container i thought i had issues w/ AAC audio. I thought like mkv, AAC had to be transcoded to play on some devices which i didnt think was the case w/ AC3.

How can the issue be duplicated?

Offline

#8 2015-04-19 00:09:08

psjbeisler
Member
From: Pittsburgh
Registered: 2015-04-13
Posts: 10
Website

Re: Ffmpeg question - best practice

psjbeisler wrote:

even in an mp4 container i thought i had issues w/ AAC audio. I thought like mkv, AAC had to be transcoded to play on some devices which i didnt think was the case w/ AC3.

How can the issue be duplicated?

I guess i can do an mp4 file w/ AAC and and another mp4 with AC3 and find out, but thanks that pretty much cleared everything up for me.

i did run into an issue with a player on Android telling me it couldnt do the AC3 audio because of a licensing issue, so its a lil more than FUD at that point but, it was only that once and it worked again shortly after... idk.

Last edited by psjbeisler (2015-04-19 00:09:33)

Offline

Board footer

Powered by FluxBB