
Recherche avancée
Autres articles (15)
-
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...) -
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community. -
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...)
Sur d’autres sites (4401)
-
ffmpeg - maintain video quality as I apply multi-pass workflow, each includes decoding and encoding again, in video editing
27 septembre 2020, par QRrabbitI'm using FFMPEG libraries do do some video manipulation, and due to complexity of filters and image overlaying, I have to run the process in multiple passes.
This means, my process is as such :
Open original video, decode it, run -complex_filter, recompress the video in whichever format the original video was encoded.
Open the output from the first pass, run another -complex_filter, etc-etc.
Sometimes I have to do the above 3-4 times. My concern is that the video, with every compression is losing quality - obvious signs of that is the file is shrinking in size with every pass.


With the above, I have two questions :


- 

-
Would it make sense to, after first manipulation, instead of saving the video in its original format, I chose some format that is lossless, and then perform my passes one after the other, knowing that the quality remains the same, then on the final pass I recompress one-time into the format of the source. If so, what format of a video would you recommend ? ProRes 4444 ? Any other formats I shell consider ? Any parameters I should set and carry-over from encoding to encoding ?


-
With every step I carry over all extra streams of audio and other meta data.
Wouldn't it be more efficient to strip everything except the video, run my video passages over and over and not to need for adding -c:a copy and c:s copy ? Then on my final run, merge all streams from the original source to the output file ? If yes, how will I carry the ffmpeg command specifically ? I have a video that has 1 video stream + 15 audio streams + some extra tmcd which my ffmpeg cannot read.








Thank you.


Edit 1 :


if the input video has a video codec = dvvideo, and if dimensions of the video is 1280x1080, that means the video doesn't have a typical square pixels.
I first need to resize the video, in doing so I scale the video up. Then I can run my filters :


pass-1 : -vf scale=1920x1080 (this step is skipped if the video is of a normal x to y ratio)
pass-2 : -filter_complex : which calls my special filter that adds some proprietary watermark to a video
pass-3 : -filter_complex : "0overlay=5:21:enable='between(t,2,3)+between(t,4,5)+between(t,6,8)'" (sole objective is to inserts an icon.png at a location near where the watermark was placed in previous step.)
pass-4 : -vf scale=1280x1080 (this step scales the video back, if pass-1 was executed)


I could probably rewrite my 'C' filter code at some point in the future to accommodate this logic of checking for 1280x1080, as well as inserting this icon.png, and do it all in one step, but for right now, I thought just using 2-step process if a normal video, or a 4 passes if needs scaling, and utilize something of a lossless format as a temp file solution (I arbitrary chose ProRes 4444 v5, but open to suggestions), should minimize the losses during recompression to the video.


Steps 1 and 4 are conditional, and only applicable if :
if vcodec == 'dvvideo' and aspect_ratio < 1.2 : # 1280x1080 ratio has about 1.16
I run steps 1->4. Otherwise only steps 2 & 3 :


Step1 :


ffmpeg -i in.mov -vf scale=1920x1080 -map 0:v? -map 0:a? -map 0:s? -map_metadata 0 -b:v 115084915 -maxrate 115084915 -minrate 115084915 -c:v prores_ks -profile:v 5 -preset ultrafast -crf 0 -c:a copy -timecode 00:00:00.00 -c:s copy -y step2.mov



Step2 :


ffmpeg -i step2.mov -filter_complex " myFilter=enable='between(t,0,30)':x=15:y=25:size=95:etc-etc..." -map 0:v? -map 0:a? -map 0:s? -map_metadata 0 -b:v 115084915 -maxrate 115084915 -minrate 115084915 -c:v prores_ks -profile:v 5 -preset ultrafast -crf 0 -c:a copy -timecode 00:00:00.00 -c:s copy -y step3.mov



Step3 :


ffmpeg -i step3.mov -i icon.png -filter_complex "[0][1]overlay=15:20:enable='between(t,1,3.600)+between(t,4,5.500)+between(t,6,20)' " -map 0:v? -map 0:a? -map 0:s? -map_metadata 0 -b:v 115084915 -maxrate 115084915 -minrate 115084915 -c:v prores_ks -profile:v 5 -preset ultrafast -crf 0 -c:a copy -timecode 00:00:00.00 -c:s copy -y step4.mov



Step4 :


ffmpeg -i step4.mov -map 0:v? -vf scale=1280x1080 -map 0:a? -map 0:s? -c:v dvvideo -pix_fmt yuv422p -b:v 115084915 -maxrate 115084915 -minrate 115084915 -r 29.97 -top 1 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -vtag dvh6 -map_metadata 0 -c:a copy -timecode 00:00:00.00 -c:s copy -y final-output.mov



Since I post my entire set of ffmpeg commands, maybe someone could recommend how to make my output match input so that I don't lose timecode entry :


-
-
Revision b0c146eea9 : [svc] 1. Add two pass RC options in vp9_spatial_scalable_encoder. 2. Add r
28 février 2014, par Minghai ShangChanged Paths :
Modify /examples.mk
Modify /examples/vp9_spatial_scalable_encoder.c
Modify /vpx/exports_enc
Modify /vpx/src/svc_encodeframe.c
Modify /vpx/svc_context.h
[svc] 1. Add two pass RC options in vp9_spatial_scalable_encoder.
2. Add read/write for RC stats file
The two pass RC for svc does not work yet. This is just the first
step. We need further development to make it working.
Change-Id : I8ef0e177dff0b5ed3c97a916beea5123717cc6f2 -
Video Encoding issue
6 octobre 2014, par pbellemaI’m making an app that records small videos and concatenates them together (like Vine).
If I record a video without concatenation there are no problems.
But if I assemble recordings, two problems appear : records disappear or they are cut out.When I start to record :
private boolean prepareVideoRecorder(){
if (mCamera != null) {
mMediaRecorder = new MediaRecorder();
Camera.Parameters p = mCamera.getParameters();
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
//mMediaRecorder.setOrientationHint(90);
Log.i("MY_LOG", "set preview display");
mMediaRecorder.setMaxDuration(8000);
// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mMediaRecorder.setProfile(profile);
mMediaRecorder.setVideoSize(profile.videoFrameWidth,profile.videoFrameHeight);
// Step 4: Set output file
mMediaRecorder.setOutputFile(getOutputMediaFile().toString());
if (mFrontCamera) {
mMediaRecorder.setPreviewDisplay(mFrontPreview.getHolder().getSurface());
} else {
mMediaRecorder.setPreviewDisplay(mBackPreview.getHolder().getSurface());
}
// Step 6: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d("MY_LOG", "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d("MY_LOG", "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
} else {
Log.i("MY_LOG", "camera null");
return false;
}And when I stop :
private void stopRecording(boolean forcedStop) {
mRecording = false;
try {
mMediaRecorder.stop();
releaseMediaRecorder();
mCamera.lock();
rotateVideo(mPaths.size() - 1, mFrontCamera);
if (forcedStop) manageVideos(forcedStop);
} catch (RuntimeException e) {
Log.i("MY_LOG", "Exception" + e.toString());
}
}and when I finish, those are my concatenation functions :
private void manageVideos(boolean forcedStop) {
if (mPaths.size() > 1 || forcedStop) {
String mediaStorageDirPath = Helper.getMediaStorageDirPath();
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
final String path = mediaStorageDirPath + File.separator +
"APPEND_"+ timeStamp + ".mp4";
finalVideo = path;
ffmpegAppend(path);
} else {
finalVideo = mPaths.get(0);
if (!isProcessingFFmpeg) {
goToSubtitleFragment(finalVideo);
}
}
}
private void ffmpegAppend(String path) {
String mediaStorageDirPath = Helper.getMediaStorageDirPath();
String filePath = mediaStorageDirPath + File.separator + "append.txt";
try {
File f = new File(filePath);
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(f));
BufferedWriter writer = new BufferedWriter(out);
for (int i = 0; i < mPaths.size(); i++) {
writer.write("file '" + mPaths.get(i) + "'");
writer.newLine();
}
writer.close();
String cmd = "ffmpeg -f concat -i " + filePath + " -c copy " + path;
mCmd.add(cmd);
manageCommands();
} catch (Exception e) {
}
}
private void manageCommands() {
if (!isProcessingFFmpeg && mCmd.size() > 0) {
new FFmpegTask().execute(mCmd.get(0));
}
}
private class FFmpegTask extends AsyncTask {
protected Integer doInBackground(String... cmd) {
isProcessingFFmpeg = true;
int fileCount = cmd.length;
Processor p = new Processor(Helper.getEncodingLibraryPath(getActivity()), getActivity());
for (String c : cmd) {
String[] strArr = c.split(" ");
p.process(strArr);
}
return fileCount;
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(Integer result) {
StackTraceElement[] ste = Thread.currentThread().getStackTrace();
isProcessingFFmpeg = false;
if (mCmd.size() > 0) {
mCmd.remove(0);
}
if (mCmd.size() > 0) {
new FFmpegTask().execute(mCmd.get(0));
} else if (isFinished) {
goToSubtitleFragment(finalVideo);
}
}
}Do you see where the problems might be coming from ?
Thanks to you.