Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help: Output of a valid XDCAM HD422 #966

Open
SchwartzWare opened this issue Apr 18, 2018 · 7 comments
Open

Help: Output of a valid XDCAM HD422 #966

SchwartzWare opened this issue Apr 18, 2018 · 7 comments

Comments

@SchwartzWare
Copy link

SchwartzWare commented Apr 18, 2018

Hello,
I want to ouput a valid MXF in the XDCAM HD422 format.
I already got it to ouput the MXF with the video and MediaInfo recognizes that its a XDCAM HD422 but its not fully valid so I can't import it into Vegas Pro.
When I set the flag "ilme" it is interlaced as intended but bottom first. It needs to be top first. But when I set parameter "top" to 1 it gets ignored. When I try this with a standalone version of FFMPEG it works. The next problem would be that a valid XDCAM HD422 need to audio tracks. How can I achieve this?

Here the questions in short:

  1. How can I set the field order of the video interlacing to "top field first"?
  2. How can I add those 2 audio tracks with JavaCV?

Thanks in advance.


Valid XDCAM HD422 encoded with Adobe Media Encoder:
image

My current output (Don't wonder about the differentz file size. It's not the same source.):
image

@saudet
Copy link
Member

saudet commented Apr 18, 2018 via email

@SchwartzWare
Copy link
Author

This is the command of the FFMPEG behavior I want to reproduce in JavaCV:
ffmpeg -t 5 -loop 1 -i input.png -f lavfi -i anullsrc=channel_layout=mono:sample_rate=48000 -vcodec mpeg2video -s 1920x1080 -b:v 50000k -minrate 50000k -maxrate 50000k -r 25 -flags ilme -top "1" -pix_fmt yuv422p -profile:v 0 -level:v 2 -acodec pcm_s24le -ar 48000 -shortest -map 0:0 -map 1:0 -map 1:0 output.mxf
It converts an image to a valid 'XDCAM HD422' MXF video file.

As mentioned before I can export a video file yet. But its not valid. In Java the 'input.png' would be a BufferedImage. A workaround would be to export a uncompressed video and then execute the command directly with FFMPEG. But it would be slicker if it would run inside JavaCV without a temp file.

I don't really know where to start.

@saudet
Copy link
Member

saudet commented Apr 30, 2018 via email

@saudet
Copy link
Member

saudet commented Apr 30, 2018

For starters, read the source code of FFmpegFrameRecorder and try to understand how it works.

@SchwartzWare
Copy link
Author

Maybe I will try this when I have enough spare time but for now I used a fairly new library called Jaffree to do what I wanted to do. For my case it was easier to use and worked out of the box.

Anyway thank you for your help, until now.

@saudet
Copy link
Member

saudet commented Mar 24, 2019

BTW, with commit bytedeco/javacpp-presets@13ffffd the ffmpeg program itself now gets bundled, so we can use it easily from Java. For this case, we could do something like the following:

   String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
   ProcessBuilder pb = new ProcessBuilder(ffmpeg, "-t", "5", "-loop", "1", "-i", "input.png", "-f", "lavfi", "-i", "anullsrc=channel_layout=mono:sample_rate=48000", "-vcodec", "mpeg2video", "-s", "1920x1080", "-b:v", "50000k", "-minrate", "50000k", "-maxrate", "50000k", "-r", "25", "-flags", "ilme", "-top", ""1"", "-pix_fmt", "yuv422p", "-profile:v", "0", "-level:v", "2", "-acodec", "pcm_s24le", "-ar", "48000", "-shortest", "-map", "0:0", "-map", "1:0", "-map", "1:0", "output.mxf");
   pb.inheritIO().start().waitFor();

Please give it a try with 1.5-SNAPSHOT before the release: http://bytedeco.org/builds/

@saudet
Copy link
Member

saudet commented Dec 29, 2021

FYI, the JavaCPP Presets for FFmpeg and Jaffree are fully complimentary.
Something like this should work just fine out of the box:

     String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
     FFmpeg.atPath(Paths.get(ffmpeg).getParent())...

This way, we don't need to have FFmpeg installed on the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants