Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th March 2014, 18:59   #1  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
Using FFMPEG to encode to Blu-ray format

Hello,

I have been tearing my hair out trying to find the optimal way to encode an already x264 compressed 720p29.97 video file into a Bluray compatible format using ffmpeg. There are lots of resources for using the stand-alone x264.exe, but I want to retain the audio track in my file, so I believe ffmpeg would be the best way to go (please correct me if I'm wrong).

Ideally I would like to use ffmpeg so that I can also use the libfdk_aac audio encoder. Here is the command that I have built from various resources including the sticky at the top of this forum:

ffmpeg -i [filein] -c:v libx264 -level:v 4.1 -preset veryslow -tune film -crf 16 -r 59.94 -x264opts bluray-compat=1:weightp=0:bframes=3:ref=3:nal-hrd=vbr:vbv-maxrate=40000:vbv-bufsize=30000:keyint=60:b-pyramid=strict:slices=4:tff=1:aud=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:sar=1/1 -c:a copy [fileout]

I am comparing the output of this command with that of multiAVCHD's built-in transcoding and have found the quality of the multiAVHCD built-in transcoding noticably better. However, I would like to do this through the command line instead of GUI so I can automate.

Could anyone please review my ffmpeg command and indicate why I am not able to get the same quality as I can with the multiAVHCD transcode process? I know that multiAVHCD uses AVISynth scripts, but shouldn't I be able to achieve the same thing with the ffmpeg cli?

I also need to use ffmpeg to create a letterboxed DVD-format of the same file. I honestly haven't spent a lot of time on figuring out how to crop/resize appropriately and whether anything besides the "target ntsc-dvd" flag is required for compatibility, but if someone has the command line handy for it I'd really appreciate that.

Thank you!
lyinawake is offline   Reply With Quote
Old 25th March 2014, 19:37   #2  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
You'd probably want to know;
a. what version of x264 are both using
b. are the encoding commands exactly the same
c. there could be something silly happening with -r 59.94 < just guessing
__________________
certain other member

Last edited by smok3; 25th March 2014 at 19:40.
smok3 is offline   Reply With Quote
Old 25th March 2014, 20:11   #3  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
Thanks for the response. Good points.

a.) I'd think my version is newer than multiAVCHD's version as that was last built in 2012 and I cross-compiled my ffmpeg on Dec 2013. However I'm not certain what the version # of my x264 is... My memory of the cross-compile and how I wound up doing it is unfortunately foggy

b.) No, multiAVCHD uses AVISynth scripts and I'm using ffmpeg CLI so I'd imagine they'd be quite different. However, I should probably try to intercept the script while multiAVCHD is whirring away and see what's in the guts...

c.) 720p Blu-ray doesn't support 29.97fps so the best thing I can think to do is go to 59.94fps so I don't lose any frames.
lyinawake is offline   Reply With Quote
Old 25th March 2014, 23:29   #4  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
b. I meant the x264 command line (That should have little/none to do with avisynth).
__________________
certain other member
smok3 is offline   Reply With Quote
Old 27th March 2014, 15:55   #5  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,049
Quote:
Originally Posted by lyinawake View Post
b.) No, multiAVCHD uses AVISynth scripts and I'm using ffmpeg CLI so I'd imagine they'd be quite different.
-x264opts should be the same, ffmpeg in your case is a x264 frontend, avisynth is used to process raw video
just copy x264 settings from multiAVCHD - if raw video is same quality then results should be comparable (assumption that x264 same version is used) - if this is different then perhaps raw video quality is different - avisynth perform way better raw video processing than ffmpeg.

Quote:
Originally Posted by lyinawake View Post
c.) 720p Blu-ray doesn't support 29.97fps so the best thing I can think to do is go to 59.94fps so I don't lose any frames.
check http://mewiki.project357.com/wiki/X264_Settings#pulldown settings - perhaps framerate conversion is not required.
use -x264opts to pass pulldown to ffmpeg
pandy is offline   Reply With Quote
Old 27th March 2014, 16:14   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
It's --pulldown double with x264.exe

https://sites.google.com/site/x264bluray/home/720p-encoding

But not all options are available in ffmpeg libx264; not sure if the pulldown options are available. Sometimes -x264-params works, but -x264opts doesn't for ffmpeg libx264. For example, -x264-params open-gop=1 works, but -x264opts open-gop=1 doesn't get passed
poisondeathray is offline   Reply With Quote
Old 28th March 2014, 02:05   #7  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Odd, that's normally libav behavior, they don't understand -x264opts. ffmpeg supports both for libav compatibility. Well, use whatever works.
foxyshadis is offline   Reply With Quote
Old 2nd May 2014, 19:32   #8  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
I've had no luck as of yet. Adobe Encore is still seeing my output as non-compliant and having to transcode it again. Here is my latest set of commands:

Code:
    x264options = "bluray-compat=1:force-cfr=1:weightp=0:bframes=3:ref=3:nal-hrd=vbr:vbv-maxrate=40000:vbv-bufsize=30000:keyint=60:b-pyramid=strict:slices=4:tff=1:aud=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:sar=1/1"
    strCmd = "ffmpeg.exe -y -i " & INPUT_PATH & INPUT_FILE & " -c:v libx264 -level:v 4.1 -preset veryslow -tune film -crf 16 -r 59.94 -x264opts " & x264options & " -x264-params " & x264options & " -c:a copy " & OUTPUT_NAME
I am now trying to push everything through both x264opts and x264-params. I am unable to use the pulldown options references in the "x264 for Bluray" pages, so this is as close as I seem to be able to get to what they've suggested.

Does anyone know how I would go about using x264.exe instead of ffmpeg to be able to handle the audio stream as well? Or would I need to move to AVISynth to be able to do this? It's a damn shame, but what I'm trying to do just doesn't seem possible with ffmpeg...
lyinawake is offline   Reply With Quote
Old 2nd May 2014, 20:00   #9  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
One thing that sticks out is -r 59.94 . 59.94 is an approximation, it should be 60000/1001. Also "TFF" implies interlaced encoding.

Why do you care about x264 handling/passing audio? You're going to be importing elementary streams anyway

Last edited by poisondeathray; 2nd May 2014 at 20:45.
poisondeathray is offline   Reply With Quote
Old 2nd May 2014, 21:06   #10  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
Quote:
Originally Posted by poisondeathray View Post
One thing that sticks out is -r 59.94 . 59.94 is an approximation, it should be 60000/1001. Also "TFF" implies interlaced encoding.
...and you can only have interlaced in BD at <=30 fps. 50/59.94 is progressive only, and not available at 1080p.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 2nd May 2014, 21:30   #11  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by benwaggoner View Post
...and you can only have interlaced in BD at <=30 fps. 50/59.94 is progressive only, and not available at 1080p.
His source was 720p29.97 ; I'm assuming he's not upscaling it

And that must be a typo because you can have native progressive BD <= 30 FPS eg.1080p24, 1080p23.976 , 720p24, 720p23.976



And it works in ffmpeg for Encore passthrough for the 720p59.94 case when those 2 suggestions are implemented. Make sure you export elementary stream. The pulldown options don't work in ffmpeg libx264 - or at least I couldnt' figure the switches out . That was for a real 59.94 video. For your video you have to use actual frame duplicates

Last edited by poisondeathray; 2nd May 2014 at 21:37.
poisondeathray is offline   Reply With Quote
Old 3rd May 2014, 23:21   #12  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
Quote:
And that must be a typo because you can have native progressive BD <= 30 FPS eg.1080p24, 1080p23.976 , 720p24, 720p23.976
I meant that if fps >30, than only progressive scan can be used, and frame size can't be 1080.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book

Last edited by benwaggoner; 5th May 2014 at 22:28. Reason: Fixed QUOTE
benwaggoner is offline   Reply With Quote
Old 5th May 2014, 18:06   #13  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
Oh, that damn "tff=1"! Thank you very much folks. I think that's going to do it. Testing is pending but all of my videos were actually interlaced and I didn't even notice. That's what I get for copying someone else's switches without double-checking each one. Oy. I'll post back with the results. And I also changed my fps to 60000/1001 to be more exact.

And about x264.exe handling audio, I'm afraid you're talking over my head with the mention of "passing elementary streams", but if you have the patience, I would very much appreciate the education. All I know is that x264.exe will only touch my video, so the output is going to be a video stream. With FFMPEG, I can address audio and video in one command and the output is going to have video and audio streams, so that 1 file can go right in to Encore and get written to a Bluray. How would I go about doing the same with x264.exe to create a file with audio and video streams? It is a moot point if you guys have solved my ffmpeg issue (which I believe you have), but I'd like to figure out my way around all this stuff a little better.

Thank you!!
lyinawake is offline   Reply With Quote
Old 5th May 2014, 18:38   #14  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
@lyinawake

You're going off topic ("Using ffmpeg..."). Please open a new thread for your new topic.
Guest is offline   Reply With Quote
Old 12th July 2014, 04:49   #15  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
I've been trying and trying and thought I was on to something when it was pointed out I was using a flag that triggered interlacing in my output, but after fixing that issue there is still nothing that I can seem to do to get an output from ffmpeg to go into Encore without requiring transcoding. I am now working with elementary streams because Encore really hates taking anything that isn't elementary or that it can't transcode. I have also used Encore to transcode a file, found that resulting file, ran MediaInfo against it and compared my output. Nothing different other than MediaInfo sees my ReFrames @ 3 while the Encore transcode was @ 4. I've tried fiddling with various switches in the command but can't seem to get my ReFrames to read "4" though I hear around various forums that the ReFrame reading from MediaInfo is to be taken with a grain of salt due to the various ways there are to count the reference frames in a video.

My current theory is that Encore will not accept a video that isn't encoded using the MainConcept H.264 encoder. If that is the case then I am a sad panda. I'm hoping that someone on here can prove my theory incorrect.

@poisondeathray - You mentioned you were able to get this to work. Are you 100% positive that you were successful in getting 720p59.94 into Encore without it triggering a transcode? Would you be able to post your ffmpeg.exe or x264.exe command?
lyinawake is offline   Reply With Quote
Old 12th July 2014, 13:29   #16  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
You can read about example x264.exe command-lines here:
http://www.x264bluray.com/home/720p-encoding (also apply --fps 60000/1001 to be sure)
Also read:
http://forum.doom9.org/showthread.php?t=154533
sneaker_ger is offline   Reply With Quote
Old 14th July 2014, 18:53   #17  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
Thanks for the reply. I've tried the x264 encode instead of going through FFMPEG and Encore still doesn't want to take the video file in. It says it's untranscoded and wants to transcode it itself. Also am fairly well versed with the second article you posted, but I am suspecting it's not the switches I'm using.

Has anyone actually brought a supposedly blu-ray compliant file that was encoded with x264 and not had Encore squawk about it?
lyinawake is offline   Reply With Quote
Old 14th July 2014, 19:07   #18  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Yes it works in encore . DVDA still has problems with x264 MBAFF, but both MBAFF and progressive variants work in Encore

When you look at "untranscoded" make sure you are looking at the blu-ray status, not the DVD status (I know it sounds stupid, but many people make this mistake)
poisondeathray is offline   Reply With Quote
Old 14th July 2014, 23:38   #19  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
Yup, I'm doing encore. Just redid an x264 transcode to elementary stream and it actually went into Encore this time (thanks @sneaker_ger for the tip to include the --fps flag), but it still says it's an untranscoded file when I apply the following commands to my 720p59.94 mp4 ~3minute file:

x264 --bitrate 8000 --preset veryslow --tune film --bluray-compat --fps 60000/1001 --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 60 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 1 -o out.264 input.mp4

x264 --bitrate 8000 --preset veryslow --tune film --bluray-compat --fps 60000/1001 --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 60 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 1 -o out.264 input.mp4

x264 --bitrate 8000 --preset veryslow --tune film --bluray-compat --fps 60000/1001 --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 60 --open-gop --slices 4 --colorprim "bt709" --transfer "bt709" --colormatrix "bt709" --sar 1:1 --pass 2 -o out.264 input.mp4

@poisondeathray Thanks for confirming you're having success with x264. I have a love/hate relationship with the fact that this is working for you. I feel like I'm taking crazy pills, but on the other hand, you're giving me hope that this is possible. I am definitely looking at the Blu-ray columns. I'm only doing progressive (despite my first attempt where I was using an interlaced flag), so I SHOULD be having success.

I've also got threads on the Adobe forums trying to get their heads on this, but so far no responses. The forum members on there appear to be asking or providing guides for using something called x264pro or a standalone MainConcept encoder as a way to get files primed for Encore through command-line.
lyinawake is offline   Reply With Quote
Old 15th July 2014, 00:15   #20  |  Link
lyinawake
Registered User
 
Join Date: Mar 2014
Posts: 14
Alright... after looking closer at my output from x264.exe, I've found out that somehow, I got a 10-bit version of x264.exe. Blu-ray no likey 10-bit encodes. It's working... It's finally working...

Now, a minor annoyance, is that I'm not able to do this from ffmpeg, but I found output in x264.exe that may explain it:

resize [warning]: converting from yuv420p101e to yuv420p161e

Anyone know what's the 101e (from ffmpeg) vs 161e (from x264)? Googling either value results in 1 and 0 results in Google respectively. I mean, I have a way forward now, which I didn't before, so it's not a biggie, but while my hands are this dirty with the topic of "command-line generated blu-ray compliant files", I may was well learn the remaining 1% of what the heck is going on.

Thanks you guys. It's awesome to know you're out there putting effort into helping strangers on the internet.
lyinawake is offline   Reply With Quote
Reply

Tags
blu-ray, ffmpeg

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.